1
1
import React , { memo , useCallback } from 'react'
2
- import PropTypes from 'prop-types'
3
2
import styled from 'styled-components'
4
3
import Control from './Control'
5
4
import PropertyHeader from './PropertyHeader'
@@ -10,30 +9,23 @@ const size = 36
10
9
const center = size / 2
11
10
const markerSize = 6
12
11
13
- const Row = styled . div `
14
- display: grid;
15
- grid-template-columns: 60px ${ size } px auto;
16
- grid-column-gap: 9px;
17
- align-items: center;
18
- max-width: 240px;
19
- margin-bottom: 5px;
20
- `
21
-
22
- const Circle = styled . circle `
23
- fill: ${ ( { theme } ) => theme . colors . background } ;
24
- strokewidth: 1px;
25
- stroke: ${ ( { theme } ) => theme . colors . border } ;
26
- `
27
-
28
- const Line = styled . line `
29
- stroke: ${ ( { theme } ) => theme . colors . accent } ;
30
- `
31
-
32
- const Marker = styled . circle `
33
- fill: ${ ( { theme } ) => theme . colors . accent } ;
34
- `
12
+ interface AngleControlProps {
13
+ id : string
14
+ property : {
15
+ description ?: string
16
+ }
17
+ flavors : ( 'svg' | 'html' | 'canvas' | 'api' ) [ ]
18
+ currentFlavor : 'svg' | 'html' | 'canvas' | 'api'
19
+ value : number
20
+ options : {
21
+ start ?: number
22
+ min ?: number
23
+ max ?: number
24
+ }
25
+ onChange : ( v : number ) => void
26
+ }
35
27
36
- const AngleControl = memo ( ( { id, property, flavors, currentFlavor, value, options, onChange } ) => {
28
+ export const AngleControl = memo ( ( { id, property, flavors, currentFlavor, value, options, onChange } : AngleControlProps ) => {
37
29
const start = options . start || 0
38
30
const min = options . min || 0
39
31
const max = options . max || 360
@@ -73,18 +65,25 @@ const AngleControl = memo(({ id, property, flavors, currentFlavor, value, option
73
65
)
74
66
} )
75
67
76
- AngleControl . propTypes = {
77
- id : PropTypes . string . isRequired ,
78
- property : PropTypes . object . isRequired ,
79
- flavors : PropTypes . arrayOf ( PropTypes . oneOf ( [ 'svg' , 'html' , 'canvas' , 'api' ] ) ) . isRequired ,
80
- currentFlavor : PropTypes . oneOf ( [ 'svg' , 'html' , 'canvas' , 'api' ] ) . isRequired ,
81
- value : PropTypes . number . isRequired ,
82
- options : PropTypes . shape ( {
83
- start : PropTypes . number ,
84
- min : PropTypes . number ,
85
- max : PropTypes . number ,
86
- } ) . isRequired ,
87
- onChange : PropTypes . func . isRequired ,
88
- }
68
+ const Row = styled . div `
69
+ display: grid;
70
+ grid-template-columns: 60px ${ size } px auto;
71
+ grid-column-gap: 9px;
72
+ align-items: center;
73
+ max-width: 240px;
74
+ margin-bottom: 5px;
75
+ `
89
76
90
- export default AngleControl
77
+ const Circle = styled . circle `
78
+ fill: ${ ( { theme } ) => theme . colors . background } ;
79
+ stroke-width: 1px;
80
+ stroke: ${ ( { theme } ) => theme . colors . border } ;
81
+ `
82
+
83
+ const Line = styled . line `
84
+ stroke: ${ ( { theme } ) => theme . colors . accent } ;
85
+ `
86
+
87
+ const Marker = styled . circle `
88
+ fill: ${ ( { theme } ) => theme . colors . accent } ;
89
+ `
0 commit comments