-
Notifications
You must be signed in to change notification settings - Fork 0
/
ui.html
413 lines (338 loc) · 12.8 KB
/
ui.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ColorBlendr Figma Plugin</title>
<style id="figma-style">
.figma-light body {
background-color: white;
color: #000000;
}
.figma-dark body {
background-color: #161B26;
color: #CECFD2;
}
body {
font-family: 'inter', sans-serif;
background-color: var(--figma-color-bg);
color: var(--figma-color-text);
padding: 8px;
overflow-x: hidden;
font-size: 13px;
font-weight: normal;
}
/* Global Form style */
.form-group {
display: flex;
flex-direction: column;
align-items: flex-start;
margin-bottom: 16px;
width: 100%;
}
.figma-light .form-group label.mainlabel {
margin-right: 16px;
margin-bottom: 8px;
color: #344054;
}
.figma-dark .form-group label.mainlabel {
margin-right: 16px;
margin-bottom: 8px;
color: #CECFD2;
}
/* Dropdown selection */
select {
width: 100%;
height: 34px;
border-radius: 6px;
border: 1px solid #cccccc;
font-size: 14px;
transition: border 0.3s;
padding-left: 8px;
position: relative;
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAUCAMAAACtdX32AAAAdVBMVEUAAAD///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAhMdQaAAAAJ3RSTlMAAAECAwQGBwsOFBwkJTg5RUZ4eYCHkJefpaytrsXGy8zW3+Do8vNn0bsyAAAAYElEQVR42tXROwJDQAAA0Ymw1p9kiT+L5P5HVEi3qJn2lcPjtIuzUIJ/rhIGy762N3XaThqMN1ZPALsZPEzG1x8LrFL77DHBnEMxBewz0fJ6LyFHTPL7xhwzWYrJ9z22AqmQBV757MHfAAAAAElFTkSuQmCC);
background-position: 100%;
background-repeat: no-repeat;
background-size: 22px 14px;
-webkit-appearance: none !important;
}
.figma-light select {
border: 1px solid #D0D5DD;
background-color: #FFFFFF;
color: #667085;
box-shadow: 0px 1px 2px 0px rgba(16, 24, 40, 0.05);
}
.figma-dark select {
border: 1px solid #333741;
background-color: #1F242F;
color: #85888E;
box-shadow: 0px 1px 2px 0px rgba(16, 24, 40, 0.05);
}
select:focus, select:hover {
border: 1px solid #cccccc;
outline: none;
}
/* Text and color input */
input[type="text"],
input[type="number"] {
padding: 8px;
border: 1px solid #d4d4d4;
height: 34px;
border-radius: 6px;
background-color: #ffffff;
color: #1a1a1a;
width: 100%;
}
.input-group {
display: flex;
align-items: center;
gap: 4px;
width: 100%;
}
.input-group input[type="text"] {
width: auto;
flex-grow: 1;
}
/* Radio selection style */
.radio-group {
width: 100%;
display: flex;
}
.radio-group {
flex-wrap: wrap;
width: 100%;
justify-content: space-between;
height: 34px;
border-radius: 6px;
}
.radio-group label.radio-card {
width: calc(50% - 7px);
margin: 0;
padding: 0;
height: 34px;
border-radius: 6px;
}
.radio-group .radio-card span {
display: flex;
align-items: center;
border: 1px solid #cccccc;
padding: 0px;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.3s ease;
width: 100%;
margin: 0;
font-size: 13px;
height: 34px;
border-radius: 6px;
}
.radio-card span:hover {
border-color: #027BEB;
}
.radio-card input[type='radio'] {
display: none;
}
.radio-card input[type='radio']:checked + span {
color: #027BEB;
width: 100%;
background-color: rgba(0,123,255, 0.1);
border-color: #027BEB;
}
.radio-card input[type='radio']:checked ~ svg path {
fill: #027BEB;
}
.radio-card input[type='radio']:checked ~ svg {
color: #027BEB;
}
.radio-card input[type='radio']:checked {
background-color: rgba(0,123,255, 0.1);
border-color: #027BEB;
}
.radio-card svg {
margin-right: 4px;
margin-left: 8px;
}
.radio-card svg {
vertical-align: middle;
fill: currentColor;
}
/* Button style */
.button-group {
display: block;
margin-top: 24px;
}
.button-group button {
padding: 12px 16px;
margin-left: 0;
font-weight: 500;
border: none;
border-radius: 6px;
cursor: pointer;
transition: background-color 0.3s ease;
width: 100%;
font-size: 14px;
}
.button-group button.primary {
background-color: #007aff;
color: #ffffff;
}
.button-group button.secondary {
background-color: transparent;
color: #007aff;
border: 1px solid #007aff;
display: none;
}
.button-group button.secondary:hover {
background-color: #eaeef0;
}
/* 2 columns inputs */
.tints-view {
display: flex;
flex-wrap: wrap;
width: 100%;
justify-content: space-between;
}
.tints-view .form-group {
width: calc(50% - 5px);
margin: 0;
}
/* Color picker */
.input-group.colorPickerG {
padding: 0;
margin: 0;
border: 1px solid #d4d4d4;
border-radius: 4px;
}
.input-group.colorPickerG input {
padding: 8px;
border: 0;
border-radius: 4px;
background-color: #ffffff;
color: #1a1a1a;
-webkit-border-top-left-radius: 4px;
-webkit-border-bottom-left-radius: 4px;
-moz-border-radius-topleft: 4px;
-moz-border-radius-bottomleft: 4px;
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
}
.input-group.colorPickerG input[type="color"] {
padding: 0;
border: 0;
border-radius: 4px;
background-color: #ffffff;
width: 48px;
margin: 0;
height: 32px;
margin-right: 2px;
border: none;
cursor: pointer;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
background-color: transparent;
}
.input-group.colorPickerG input[type="color"]::-webkit-color-swatch {
border-radius: 2px;
border: 0;
}
.input-group.colorPickerG input[type="color"]::-moz-color-swatch {
border-radius: 2px;
border: 0;
}
</style>
</head>
<body>
<div class="form-group">
<label for="colorPicker" class="mainlabel">Base color</label>
<div class="input-group colorPickerG">
<input type="text" id="hexColorInput" value="#7B61FF" placeholder="#ffffff" pattern="^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$">
<input type="color" id="colorPicker" value="#7B61FF">
</div>
</div>
<div class="form-group">
<label for="nameInput" class="mainlabel">Color name</label>
<input type="text" id="nameInput" placeholder="Primary">
</div>
<div class="form-group">
<label for="numTintsInput" class="mainlabel">Number of tints</label>
<select id="numTintsInput" class="ds-input">
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10" selected>10</option>
</select>
</div>
<div class="form-group">
<label class="mainlabel">Layout direction</label>
<div class="radio-group">
<label class="radio-card">
<input type="radio" name="layoutDirection" value="HORIZONTAL" checked>
<span>
<svg xmlns="http://www.w3.org/2000/svg" height="18" viewBox="0 -960 960 960" width="18"><path d="M207.858-432Q188-432 174-446.142q-14-14.141-14-34Q160-500 174.142-514q14.141-14 34-14Q228-528 242-513.858q14 14.141 14 34Q256-460 241.858-446q-14.141 14-34 14Zm272 0Q460-432 446-446.142q-14-14.141-14-34Q432-500 446.142-514q14.141-14 34-14Q500-528 514-513.858q14 14.141 14 34Q528-460 513.858-446q-14.141 14-34 14Zm272 0Q732-432 718-446.142q-14-14.141-14-34Q704-500 718.142-514q14.141-14 34-14Q772-528 786-513.858q14 14.141 14 34Q800-460 785.858-446q-14.141 14-34 14Z"/></svg>
Horizontal
</span>
</label>
<label class="radio-card">
<input type="radio" name="layoutDirection" value="VERTICAL">
<span>
<svg xmlns="http://www.w3.org/2000/svg" height="18" viewBox="0 -960 960 960" width="18"><path d="M479.858-160Q460-160 446-174.142q-14-14.141-14-34Q432-228 446.142-242q14.141-14 34-14Q500-256 514-241.858q14 14.141 14 34Q528-188 513.858-174q-14.141 14-34 14Zm0-272Q460-432 446-446.142q-14-14.141-14-34Q432-500 446.142-514q14.141-14 34-14Q500-528 514-513.858q14 14.141 14 34Q528-460 513.858-446q-14.141 14-34 14Zm0-272Q460-704 446-718.142q-14-14.141-14-34Q432-772 446.142-786q14.141-14 34-14Q500-800 514-785.858q14 14.141 14 34Q528-732 513.858-718q-14.141 14-34 14Z"/></svg>
Vertical
</span>
</label>
</div>
</div>
<div class="tints-view">
<div class="form-group">
<label for="ellipseSizeInput" class="mainlabel">Item size</label>
<input type="number" id="ellipseSizeInput" min="50" max="200" step="10" value="120">
</div>
<div class="form-group">
<label for="itemSpacingInput" class="mainlabel">Item spacing</label>
<input type="number" id="itemSpacingInput" min="0" max="100" step="8" value="32" placeholder="32">
</div>
</div>
<div class="button-group">
<button id="cancelButton" class="secondary">Cancel</button>
<button id="createButton" class="primary">Generate Tints</button>
</div>
<script>
const colorPicker = document.getElementById('colorPicker');
const hexColorInput = document.getElementById('hexColorInput');
colorPicker.addEventListener('input', () => {
hexColorInput.value = colorPicker.value;
});
hexColorInput.addEventListener('input', () => {
if (hexColorInput.validity.valid) {
colorPicker.value = hexColorInput.value;
}
});
document.getElementById('cancelButton').addEventListener('click', () => {
parent.postMessage({ pluginMessage: { type: 'cancel' } }, '*');
});
document.getElementById('createButton').addEventListener('click', () => {
const color = colorPicker.value;
const name = document.getElementById('nameInput').value;
const numTints = parseInt(document.getElementById('numTintsInput').value);
const ellipseSize = parseInt(document.getElementById('ellipseSizeInput').value, 10);
const layoutDirection = document.querySelector('input[name="layoutDirection"]:checked').value;
const itemSpacing = parseInt(document.getElementById('itemSpacingInput').value, 10);
parent.postMessage({
pluginMessage: {
type: 'create-tints',
color,
name,
numTints,
ellipseSize,
layoutDirection,
itemSpacing
}
}, '*');
});
</script>
</body>
</html>