|
@@ -36,12 +36,28 @@ import QuickSizeSelect from './quick-size-select'
|
36
|
36
|
import QuickdashSelect from './quick-dash-select'
|
37
|
37
|
import Tooltip from 'components/tooltip'
|
38
|
38
|
|
|
39
|
+const breakpoints = { '@initial': 'mobile', '@sm': 'small' } as any
|
|
40
|
+const handleStylePanelOpen = () => state.send('TOGGLED_STYLE_PANEL_OPEN')
|
|
41
|
+const handleColorChange = (color) => state.send('CHANGED_STYLE', { color })
|
|
42
|
+const handleRotateCcw = () => () => state.send('ROTATED_CCW')
|
|
43
|
+const handleIsFilledChange = (dash) => state.send('CHANGED_STYLE', { dash })
|
|
44
|
+const handleDuplicate = () => state.send('DUPLICATED')
|
|
45
|
+const handleHide = () => state.send('TOGGLED_SHAPE_HIDE')
|
|
46
|
+const handleLock = () => state.send('TOGGLED_SHAPE_LOCK')
|
|
47
|
+const handleAspectLock = () => state.send('TOGGLED_SHAPE_ASPECT_LOCK')
|
|
48
|
+const handleMoveToBack = () => state.send('MOVED', { type: MoveType.ToBack })
|
|
49
|
+const handleMoveBackward = () =>
|
|
50
|
+ state.send('MOVED', { type: MoveType.Backward })
|
|
51
|
+const handleMoveForward = () => state.send('MOVED', { type: MoveType.Forward })
|
|
52
|
+const handleMoveToFront = () => state.send('MOVED', { type: MoveType.ToFront })
|
|
53
|
+const handleDelete = () => state.send('DELETED')
|
|
54
|
+
|
39
|
55
|
export default function StylePanel(): JSX.Element {
|
40
|
56
|
const rContainer = useRef<HTMLDivElement>(null)
|
41
|
57
|
const isOpen = useSelector((s) => s.data.settings.isStyleOpen)
|
42
|
58
|
|
43
|
59
|
return (
|
44
|
|
- <StylePanelRoot ref={rContainer} isOpen={isOpen}>
|
|
60
|
+ <StylePanelRoot dir="ltr" ref={rContainer} isOpen={isOpen}>
|
45
|
61
|
{isOpen ? (
|
46
|
62
|
<SelectedShapeStyles />
|
47
|
63
|
) : (
|
|
@@ -50,10 +66,10 @@ export default function StylePanel(): JSX.Element {
|
50
|
66
|
<QuickSizeSelect />
|
51
|
67
|
<QuickdashSelect />
|
52
|
68
|
<IconButton
|
53
|
|
- bp={{ '@initial': 'mobile', '@sm': 'small' }}
|
|
69
|
+ bp={breakpoints}
|
54
|
70
|
title="Style"
|
55
|
71
|
size="small"
|
56
|
|
- onClick={() => state.send('TOGGLED_STYLE_PANEL_OPEN')}
|
|
72
|
+ onClick={handleStylePanelOpen}
|
57
|
73
|
>
|
58
|
74
|
<Tooltip label="More">
|
59
|
75
|
<ChevronDown />
|
|
@@ -99,21 +115,18 @@ function SelectedShapeStyles(): JSX.Element {
|
99
|
115
|
<Panel.Header side="right">
|
100
|
116
|
<h3>Style</h3>
|
101
|
117
|
<IconButton
|
102
|
|
- bp={{ '@initial': 'mobile', '@sm': 'small' }}
|
|
118
|
+ bp={breakpoints}
|
103
|
119
|
size="small"
|
104
|
|
- onClick={() => state.send('TOGGLED_STYLE_PANEL_OPEN')}
|
|
120
|
+ onClick={handleStylePanelOpen}
|
105
|
121
|
>
|
106
|
122
|
<X />
|
107
|
123
|
</IconButton>
|
108
|
124
|
</Panel.Header>
|
109
|
125
|
<Content>
|
110
|
|
- <ColorPicker
|
111
|
|
- color={commonStyle.color}
|
112
|
|
- onChange={(color) => state.send('CHANGED_STYLE', { color })}
|
113
|
|
- />
|
|
126
|
+ <ColorPicker color={commonStyle.color} onChange={handleColorChange} />
|
114
|
127
|
<IsFilledPicker
|
115
|
128
|
isFilled={commonStyle.isFilled}
|
116
|
|
- onChange={(isFilled) => state.send('CHANGED_STYLE', { isFilled })}
|
|
129
|
+ onChange={handleIsFilledChange}
|
117
|
130
|
/>
|
118
|
131
|
<Row>
|
119
|
132
|
<label htmlFor="size">Size</label>
|
|
@@ -125,10 +138,10 @@ function SelectedShapeStyles(): JSX.Element {
|
125
|
138
|
</Row>
|
126
|
139
|
<ButtonsRow>
|
127
|
140
|
<IconButton
|
128
|
|
- bp={{ '@initial': 'mobile', '@sm': 'small' }}
|
|
141
|
+ bp={breakpoints}
|
129
|
142
|
disabled={!hasSelection}
|
130
|
143
|
size="small"
|
131
|
|
- onClick={() => state.send('DUPLICATED')}
|
|
144
|
+ onClick={handleDuplicate}
|
132
|
145
|
>
|
133
|
146
|
<Tooltip label="Duplicate">
|
134
|
147
|
<CopyIcon />
|
|
@@ -138,7 +151,7 @@ function SelectedShapeStyles(): JSX.Element {
|
138
|
151
|
<IconButton
|
139
|
152
|
disabled={!hasSelection}
|
140
|
153
|
size="small"
|
141
|
|
- onClick={() => state.send('ROTATED_CCW')}
|
|
154
|
+ onClick={handleRotateCcw}
|
142
|
155
|
>
|
143
|
156
|
<Tooltip label="Rotate">
|
144
|
157
|
<RotateCounterClockwiseIcon />
|
|
@@ -146,10 +159,10 @@ function SelectedShapeStyles(): JSX.Element {
|
146
|
159
|
</IconButton>
|
147
|
160
|
|
148
|
161
|
<IconButton
|
149
|
|
- bp={{ '@initial': 'mobile', '@sm': 'small' }}
|
|
162
|
+ bp={breakpoints}
|
150
|
163
|
disabled={!hasSelection}
|
151
|
164
|
size="small"
|
152
|
|
- onClick={() => state.send('TOGGLED_SHAPE_HIDE')}
|
|
165
|
+ onClick={handleHide}
|
153
|
166
|
>
|
154
|
167
|
<Tooltip label="Toogle Hidden">
|
155
|
168
|
{isAllHidden ? <EyeClosedIcon /> : <EyeOpenIcon />}
|
|
@@ -157,10 +170,10 @@ function SelectedShapeStyles(): JSX.Element {
|
157
|
170
|
</IconButton>
|
158
|
171
|
|
159
|
172
|
<IconButton
|
160
|
|
- bp={{ '@initial': 'mobile', '@sm': 'small' }}
|
|
173
|
+ bp={breakpoints}
|
161
|
174
|
disabled={!hasSelection}
|
162
|
175
|
size="small"
|
163
|
|
- onClick={() => state.send('TOGGLED_SHAPE_LOCK')}
|
|
176
|
+ onClick={handleLock}
|
164
|
177
|
>
|
165
|
178
|
<Tooltip label="Toogle Locked">
|
166
|
179
|
{isAllLocked ? <LockClosedIcon /> : <LockOpen1Icon />}
|
|
@@ -168,10 +181,10 @@ function SelectedShapeStyles(): JSX.Element {
|
168
|
181
|
</IconButton>
|
169
|
182
|
|
170
|
183
|
<IconButton
|
171
|
|
- bp={{ '@initial': 'mobile', '@sm': 'small' }}
|
|
184
|
+ bp={breakpoints}
|
172
|
185
|
disabled={!hasSelection}
|
173
|
186
|
size="small"
|
174
|
|
- onClick={() => state.send('TOGGLED_SHAPE_ASPECT_LOCK')}
|
|
187
|
+ onClick={handleAspectLock}
|
175
|
188
|
>
|
176
|
189
|
<Tooltip label="Toogle Aspect Ratio Lock">
|
177
|
190
|
{isAllAspectLocked ? <AspectRatioIcon /> : <BoxIcon />}
|
|
@@ -180,10 +193,10 @@ function SelectedShapeStyles(): JSX.Element {
|
180
|
193
|
</ButtonsRow>
|
181
|
194
|
<ButtonsRow>
|
182
|
195
|
<IconButton
|
183
|
|
- bp={{ '@initial': 'mobile', '@sm': 'small' }}
|
|
196
|
+ bp={breakpoints}
|
184
|
197
|
disabled={!hasSelection}
|
185
|
198
|
size="small"
|
186
|
|
- onClick={() => state.send('MOVED', { type: MoveType.ToBack })}
|
|
199
|
+ onClick={handleMoveToBack}
|
187
|
200
|
>
|
188
|
201
|
<Tooltip label="Move to Back">
|
189
|
202
|
<PinBottomIcon />
|
|
@@ -191,10 +204,10 @@ function SelectedShapeStyles(): JSX.Element {
|
191
|
204
|
</IconButton>
|
192
|
205
|
|
193
|
206
|
<IconButton
|
194
|
|
- bp={{ '@initial': 'mobile', '@sm': 'small' }}
|
|
207
|
+ bp={breakpoints}
|
195
|
208
|
disabled={!hasSelection}
|
196
|
209
|
size="small"
|
197
|
|
- onClick={() => state.send('MOVED', { type: MoveType.Backward })}
|
|
210
|
+ onClick={handleMoveBackward}
|
198
|
211
|
>
|
199
|
212
|
<Tooltip label="Move Backward">
|
200
|
213
|
<ArrowDownIcon />
|
|
@@ -202,10 +215,10 @@ function SelectedShapeStyles(): JSX.Element {
|
202
|
215
|
</IconButton>
|
203
|
216
|
|
204
|
217
|
<IconButton
|
205
|
|
- bp={{ '@initial': 'mobile', '@sm': 'small' }}
|
|
218
|
+ bp={breakpoints}
|
206
|
219
|
disabled={!hasSelection}
|
207
|
220
|
size="small"
|
208
|
|
- onClick={() => state.send('MOVED', { type: MoveType.Forward })}
|
|
221
|
+ onClick={handleMoveForward}
|
209
|
222
|
>
|
210
|
223
|
<Tooltip label="Move Forward">
|
211
|
224
|
<ArrowUpIcon />
|
|
@@ -213,10 +226,10 @@ function SelectedShapeStyles(): JSX.Element {
|
213
|
226
|
</IconButton>
|
214
|
227
|
|
215
|
228
|
<IconButton
|
216
|
|
- bp={{ '@initial': 'mobile', '@sm': 'small' }}
|
|
229
|
+ bp={breakpoints}
|
217
|
230
|
disabled={!hasSelection}
|
218
|
231
|
size="small"
|
219
|
|
- onClick={() => state.send('MOVED', { type: MoveType.ToFront })}
|
|
232
|
+ onClick={handleMoveToFront}
|
220
|
233
|
>
|
221
|
234
|
<Tooltip label="More to Front">
|
222
|
235
|
<PinTopIcon />
|
|
@@ -224,10 +237,10 @@ function SelectedShapeStyles(): JSX.Element {
|
224
|
237
|
</IconButton>
|
225
|
238
|
|
226
|
239
|
<IconButton
|
227
|
|
- bp={{ '@initial': 'mobile', '@sm': 'small' }}
|
|
240
|
+ bp={breakpoints}
|
228
|
241
|
disabled={!hasSelection}
|
229
|
242
|
size="small"
|
230
|
|
- onClick={() => state.send('DELETED')}
|
|
243
|
+ onClick={handleDelete}
|
231
|
244
|
>
|
232
|
245
|
<Tooltip label="Delete">
|
233
|
246
|
<Trash2 size="15" />
|