@rogieking/figui3 1.0.10 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fig.css +96 -125
- package/fig.js +26 -14
- package/package.json +1 -1
package/fig.css
CHANGED
|
@@ -572,16 +572,16 @@ input[type=text][list] {
|
|
|
572
572
|
}
|
|
573
573
|
}
|
|
574
574
|
|
|
575
|
-
input[list]:hover,
|
|
576
|
-
input[list]:active,
|
|
577
|
-
input[list]:focus,
|
|
575
|
+
input[type=text][list]:hover,
|
|
576
|
+
input[type=text][list]:active,
|
|
577
|
+
input[type=text][list]:focus,
|
|
578
578
|
select {
|
|
579
579
|
background-image: var(--icon-chevron);
|
|
580
580
|
background-position: calc(100% - 0.25rem) center;
|
|
581
581
|
background-repeat: no-repeat;
|
|
582
582
|
}
|
|
583
583
|
|
|
584
|
-
input[list],
|
|
584
|
+
input[type=text][list],
|
|
585
585
|
select {
|
|
586
586
|
padding-right: 1.5rem;
|
|
587
587
|
}
|
|
@@ -637,20 +637,12 @@ input[type=button] {
|
|
|
637
637
|
background-color: var(--figma-color-bg-selected);
|
|
638
638
|
}
|
|
639
639
|
|
|
640
|
-
&[selected=true] {
|
|
641
|
-
background-color: var(--figma-color-bg-selected);
|
|
642
|
-
}
|
|
643
|
-
|
|
644
640
|
&:focus {
|
|
645
641
|
outline: 0;
|
|
646
642
|
background-color: transparent;
|
|
647
643
|
box-shadow: inset 0 0 0 1px var(--figma-color-border-selected);
|
|
648
644
|
}
|
|
649
|
-
}
|
|
650
645
|
|
|
651
|
-
&[variant="ghost"][icon][selected=true],
|
|
652
|
-
&[variant="ghost"][icon][selected=true]>button {
|
|
653
|
-
color: var(--figma-color-icon-brand);
|
|
654
646
|
}
|
|
655
647
|
|
|
656
648
|
&[variant="ghost"][disabled=true],
|
|
@@ -734,6 +726,11 @@ input[type=button] {
|
|
|
734
726
|
&[inline=false] {
|
|
735
727
|
padding: 0;
|
|
736
728
|
}
|
|
729
|
+
|
|
730
|
+
&[selected]:not([selected=false]) {
|
|
731
|
+
color: var(--figma-color-icon-brand);
|
|
732
|
+
background-color: var(--figma-color-bg-selected);
|
|
733
|
+
}
|
|
737
734
|
}
|
|
738
735
|
|
|
739
736
|
fig-button>button {
|
|
@@ -1167,49 +1164,63 @@ details {
|
|
|
1167
1164
|
*/
|
|
1168
1165
|
|
|
1169
1166
|
|
|
1167
|
+
.fig-slider,
|
|
1168
|
+
fig-slider {
|
|
1169
|
+
--slider-height: 1rem;
|
|
1170
|
+
--slider-percent: calc(var(--slider-complete) * 100%);
|
|
1171
|
+
--slider-handle-shadow: inset 0 0 0 4px var(--figma-color-icon-onbrand),
|
|
1172
|
+
inset 0 0 0 5px rgba(0, 0, 0, 0.1),
|
|
1173
|
+
0px 0 0 0.75px rgba(0, 0, 0, 0.1),
|
|
1174
|
+
0px 1px 3px 0px rgba(0, 0, 0, 0.1),
|
|
1175
|
+
0px 3px 8px 0px rgba(0, 0, 0, 0.1),
|
|
1176
|
+
0px 0px 0.5px 0px rgba(0, 0, 0, 0.18);
|
|
1177
|
+
--slider-handle-shadow-focus: inset 0 0 0 4px var(--figma-color-icon-onbrand),
|
|
1178
|
+
inset 0 0 0 5px rgba(0, 0, 0, 0.1),
|
|
1179
|
+
0px 0 0 0.75px rgba(0, 0, 0, 0.1),
|
|
1180
|
+
0px 1px 3px 0px rgba(0, 0, 0, 0.1),
|
|
1181
|
+
0px 3px 8px 0px rgba(0, 0, 0, 0.1),
|
|
1182
|
+
0px 0px 0.5px 0px rgba(0, 0, 0, 0.18),
|
|
1183
|
+
0 0 0 1px var(--border-selected);
|
|
1170
1184
|
|
|
1171
|
-
|
|
1185
|
+
display: inline-flex;
|
|
1186
|
+
align-items: center;
|
|
1172
1187
|
|
|
1173
|
-
.slider {
|
|
1174
|
-
|
|
1175
|
-
display: block;
|
|
1188
|
+
.fig-slider-input-container {
|
|
1189
|
+
height: var(--slider-height);
|
|
1176
1190
|
position: relative;
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
margin: 0 -5px !important;
|
|
1180
|
-
--slider-percent: calc(var(--slider-complete) * (100% - 5px));
|
|
1181
|
-
--color-percent: calc(var(--slider-complete) * (100%));
|
|
1182
|
-
--slider-handle-shadow: inset 0 0 0 4px var(--figma-color-icon-onbrand),
|
|
1183
|
-
inset 0 0 0 5px rgba(0, 0, 0, 0.1),
|
|
1184
|
-
0px 0 0 0.75px rgba(0, 0, 0, 0.1),
|
|
1185
|
-
0px 1px 3px 0px rgba(0, 0, 0, 0.1),
|
|
1186
|
-
0px 3px 8px 0px rgba(0, 0, 0, 0.1),
|
|
1187
|
-
0px 0px 0.5px 0px rgba(0, 0, 0, 0.18);
|
|
1188
|
-
--slider-handle-shadow-focus: inset 0 0 0 4px var(--figma-color-icon-onbrand),
|
|
1189
|
-
inset 0 0 0 5px rgba(0, 0, 0, 0.1),
|
|
1190
|
-
0px 0 0 0.75px rgba(0, 0, 0, 0.1),
|
|
1191
|
-
0px 1px 3px 0px rgba(0, 0, 0, 0.1),
|
|
1192
|
-
0px 3px 8px 0px rgba(0, 0, 0, 0.1),
|
|
1193
|
-
0px 0px 0.5px 0px rgba(0, 0, 0, 0.18),
|
|
1194
|
-
0 0 0 1px var(--border-selected);
|
|
1191
|
+
display: block;
|
|
1192
|
+
width: 100%;
|
|
1195
1193
|
|
|
1196
|
-
|
|
1197
|
-
|
|
1194
|
+
/* Track */
|
|
1195
|
+
&::before {
|
|
1196
|
+
content: '';
|
|
1197
|
+
background: var(--figma-color-bg-brand);
|
|
1198
|
+
position: absolute;
|
|
1199
|
+
left: 0;
|
|
1200
|
+
top: 0;
|
|
1201
|
+
bottom: 0;
|
|
1202
|
+
border-radius: 0.5rem;
|
|
1203
|
+
min-width: var(--slider-height);
|
|
1204
|
+
width: calc(var(--slider-percent) + (1 - var(--slider-complete)) * var(--slider-height));
|
|
1205
|
+
max-width: 100%;
|
|
1198
1206
|
}
|
|
1207
|
+
}
|
|
1199
1208
|
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1209
|
+
&[type=hue],
|
|
1210
|
+
&[type=opacity] {
|
|
1211
|
+
.fig-slider-input-container {
|
|
1212
|
+
&::before {
|
|
1213
|
+
display: none;
|
|
1214
|
+
}
|
|
1204
1215
|
}
|
|
1205
1216
|
}
|
|
1206
1217
|
|
|
1207
1218
|
/* Chromium */
|
|
1208
|
-
|
|
1209
|
-
height:
|
|
1219
|
+
input[type=range] {
|
|
1220
|
+
height: var(--slider-height);
|
|
1210
1221
|
appearance: none;
|
|
1211
1222
|
-webkit-appearance: none;
|
|
1212
|
-
border-radius:
|
|
1223
|
+
border-radius: calc(var(--slider-height)/2);
|
|
1213
1224
|
display: block;
|
|
1214
1225
|
width: 100%;
|
|
1215
1226
|
cursor: grab;
|
|
@@ -1223,18 +1234,14 @@ details {
|
|
|
1223
1234
|
|
|
1224
1235
|
&:focus {
|
|
1225
1236
|
outline: none;
|
|
1226
|
-
|
|
1227
|
-
&::-webkit-slider-thumb {
|
|
1228
|
-
box-shadow: var(--slider-handle-shadow-focus);
|
|
1229
|
-
}
|
|
1230
1237
|
}
|
|
1231
1238
|
|
|
1232
1239
|
&::-webkit-slider-thumb {
|
|
1233
1240
|
appearance: none;
|
|
1234
1241
|
-webkit-appearance: none;
|
|
1235
1242
|
border-radius: 0.5rem;
|
|
1236
|
-
height:
|
|
1237
|
-
width:
|
|
1243
|
+
height: var(--slider-height);
|
|
1244
|
+
width: var(--slider-height);
|
|
1238
1245
|
aspect-ratio: 1;
|
|
1239
1246
|
border: none;
|
|
1240
1247
|
position: relative;
|
|
@@ -1255,15 +1262,11 @@ details {
|
|
|
1255
1262
|
}
|
|
1256
1263
|
|
|
1257
1264
|
&::-webkit-slider-runnable-track {
|
|
1258
|
-
height:
|
|
1265
|
+
height: var(--slider-height);
|
|
1259
1266
|
background-color: transparent;
|
|
1260
|
-
border-radius:
|
|
1267
|
+
border-radius: calc(var(--slider-height)/2);
|
|
1261
1268
|
box-shadow: inset 0 0 0 1px var(--figma-color-bordertranslucent);
|
|
1262
|
-
background:
|
|
1263
|
-
linear-gradient(to right, var(--figma-color-bg-brand) 0%, var(--figma-color-bg-brand) var(--slider-percent), var(--figma-color-bg-secondary) var(--slider-percent));
|
|
1264
|
-
background-size: 100% 100%, 100% 100%;
|
|
1265
|
-
background-position: 75% middle, left middle;
|
|
1266
|
-
background-repeat: no-repeat;
|
|
1269
|
+
background: var(--figma-color-bg-secondary);
|
|
1267
1270
|
}
|
|
1268
1271
|
|
|
1269
1272
|
&.hue::-webkit-slider-runnable-track {
|
|
@@ -1273,51 +1276,34 @@ details {
|
|
|
1273
1276
|
&.opacity::-webkit-slider-runnable-track {
|
|
1274
1277
|
background: linear-gradient(to right, transparent, var(--color)), var(--checkerboard);
|
|
1275
1278
|
}
|
|
1276
|
-
|
|
1277
|
-
&.gradient {
|
|
1278
|
-
border-radius: 0.125rem;
|
|
1279
|
-
|
|
1280
|
-
&::-webkit-slider-thumb {
|
|
1281
|
-
transform: scale(1.5) translateY(-1.25rem);
|
|
1282
|
-
opacity: 0.5;
|
|
1283
|
-
}
|
|
1284
|
-
}
|
|
1285
|
-
|
|
1286
|
-
&.gradient::-webkit-slider-runnable-track {
|
|
1287
|
-
border-radius: 0.125rem;
|
|
1288
|
-
background: var(--bg-hue);
|
|
1289
|
-
}
|
|
1290
1279
|
}
|
|
1291
1280
|
|
|
1292
1281
|
/* Firefox */
|
|
1293
|
-
|
|
1294
|
-
height:
|
|
1282
|
+
input[type=range] {
|
|
1283
|
+
height: var(--slider-height);
|
|
1295
1284
|
appearance: none;
|
|
1296
1285
|
-webkit-appearance: none;
|
|
1297
|
-
border-radius:
|
|
1286
|
+
border-radius: calc(var(--slider-height)/2);
|
|
1298
1287
|
display: block;
|
|
1299
1288
|
width: 100%;
|
|
1289
|
+
cursor: grab;
|
|
1300
1290
|
cursor: -moz-grab;
|
|
1301
1291
|
background-color: transparent;
|
|
1302
1292
|
|
|
1303
1293
|
&:active {
|
|
1294
|
+
cursor: grabbing;
|
|
1304
1295
|
cursor: -moz-grabbing;
|
|
1305
1296
|
}
|
|
1306
1297
|
|
|
1307
1298
|
&:focus {
|
|
1308
1299
|
outline: none;
|
|
1309
|
-
|
|
1310
|
-
&::-moz-range-thumb {
|
|
1311
|
-
box-shadow: var(--slider-handle-shadow-focus);
|
|
1312
|
-
}
|
|
1313
1300
|
}
|
|
1314
1301
|
|
|
1315
1302
|
&::-moz-range-thumb {
|
|
1316
1303
|
appearance: none;
|
|
1317
|
-
-webkit-appearance: none;
|
|
1318
1304
|
border-radius: 0.5rem;
|
|
1319
|
-
height:
|
|
1320
|
-
width:
|
|
1305
|
+
height: var(--slider-height);
|
|
1306
|
+
width: var(--slider-height);
|
|
1321
1307
|
aspect-ratio: 1;
|
|
1322
1308
|
border: none;
|
|
1323
1309
|
position: relative;
|
|
@@ -1338,15 +1324,11 @@ details {
|
|
|
1338
1324
|
}
|
|
1339
1325
|
|
|
1340
1326
|
&::-moz-range-track {
|
|
1341
|
-
height:
|
|
1327
|
+
height: var(--slider-height);
|
|
1342
1328
|
background-color: transparent;
|
|
1343
|
-
border-radius:
|
|
1329
|
+
border-radius: calc(var(--slider-height)/2);
|
|
1344
1330
|
box-shadow: inset 0 0 0 1px var(--figma-color-bordertranslucent);
|
|
1345
|
-
background:
|
|
1346
|
-
linear-gradient(to right, var(--figma-color-bg-brand) 0%, var(--figma-color-bg-brand) var(--slider-percent), var(--figma-color-bg-secondary) var(--slider-percent));
|
|
1347
|
-
background-size: 100% 100%, 100% 100%;
|
|
1348
|
-
background-position: 75% middle, left middle;
|
|
1349
|
-
background-repeat: no-repeat;
|
|
1331
|
+
background: var(--figma-color-bg-secondary);
|
|
1350
1332
|
}
|
|
1351
1333
|
|
|
1352
1334
|
&.hue::-moz-range-track {
|
|
@@ -1356,49 +1338,38 @@ details {
|
|
|
1356
1338
|
&.opacity::-moz-range-track {
|
|
1357
1339
|
background: linear-gradient(to right, transparent, var(--color)), var(--checkerboard);
|
|
1358
1340
|
}
|
|
1359
|
-
|
|
1360
|
-
&.gradient {
|
|
1361
|
-
border-radius: 0.125rem;
|
|
1362
|
-
|
|
1363
|
-
&::-webkit-slider-thumb {
|
|
1364
|
-
transform: scale(1.5) translateY(-1.25rem);
|
|
1365
|
-
opacity: 0.5;
|
|
1366
|
-
}
|
|
1367
|
-
}
|
|
1368
|
-
|
|
1369
|
-
&.gradient::-moz-range-track {
|
|
1370
|
-
border-radius: 0.125rem;
|
|
1371
|
-
background: var(--bg-hue);
|
|
1372
|
-
}
|
|
1373
1341
|
}
|
|
1374
1342
|
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
animation: sync both linear reverse;
|
|
1391
|
-
animation-timeline: --thumb;
|
|
1392
|
-
animation-range: contain;
|
|
1393
|
-
}
|
|
1343
|
+
datalist {
|
|
1344
|
+
--dot-size: calc(var(--slider-height)/4);
|
|
1345
|
+
position: absolute;
|
|
1346
|
+
inset: 0;
|
|
1347
|
+
display: flex;
|
|
1348
|
+
background: transparent;
|
|
1349
|
+
align-items: center;
|
|
1350
|
+
margin: 0;
|
|
1351
|
+
border: 0;
|
|
1352
|
+
appearance: none;
|
|
1353
|
+
padding: 0 calc((var(--slider-height)/2) - var(--dot-size)/2);
|
|
1354
|
+
height: var(--slider-height);
|
|
1355
|
+
pointer-events: none;
|
|
1356
|
+
justify-content: space-between;
|
|
1357
|
+
width: 100%;
|
|
1394
1358
|
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1359
|
+
& option {
|
|
1360
|
+
appearance: none;
|
|
1361
|
+
width: var(--dot-size);
|
|
1362
|
+
height: var(--dot-size);
|
|
1363
|
+
aspect-ratio: 1;
|
|
1364
|
+
margin: 0;
|
|
1365
|
+
padding: 0;
|
|
1366
|
+
border: 0;
|
|
1367
|
+
border-radius: 100%;
|
|
1368
|
+
font-size: 0;
|
|
1369
|
+
background: var(--figma-color-icon-tertiary);
|
|
1370
|
+
display: block;
|
|
1398
1371
|
}
|
|
1399
1372
|
}
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
1373
|
}
|
|
1403
1374
|
|
|
1404
1375
|
/* Popovers/Dialogs */
|
package/fig.js
CHANGED
|
@@ -512,7 +512,7 @@ class FigSlider extends HTMLElement {
|
|
|
512
512
|
}
|
|
513
513
|
|
|
514
514
|
let html = ''
|
|
515
|
-
let slider = `<div class="slider">
|
|
515
|
+
let slider = `<div class="fig-slider-input-container">
|
|
516
516
|
<input
|
|
517
517
|
type="range"
|
|
518
518
|
${this.disabled ? "disabled" : ""}
|
|
@@ -521,6 +521,7 @@ class FigSlider extends HTMLElement {
|
|
|
521
521
|
step="${this.step}"
|
|
522
522
|
class="${this.type}"
|
|
523
523
|
value="${this.value}">
|
|
524
|
+
${this.innerHTML}
|
|
524
525
|
</div>`
|
|
525
526
|
if (this.getAttribute("text")) {
|
|
526
527
|
html = `${slider}
|
|
@@ -535,16 +536,23 @@ class FigSlider extends HTMLElement {
|
|
|
535
536
|
} else {
|
|
536
537
|
html = slider
|
|
537
538
|
}
|
|
539
|
+
|
|
538
540
|
this.innerHTML = html
|
|
539
541
|
|
|
540
542
|
this.textInput = this.querySelector("input[type=number]")
|
|
541
|
-
this.slider = this.querySelector('.slider')
|
|
542
543
|
|
|
543
544
|
this.input = this.querySelector('[type=range]')
|
|
544
|
-
this.input.addEventListener("input", this.
|
|
545
|
+
this.input.addEventListener("input", this.handleInput.bind(this))
|
|
546
|
+
this.handleInput()
|
|
547
|
+
|
|
548
|
+
this.datalist = this.querySelector('datalist')
|
|
549
|
+
if (this.datalist) {
|
|
550
|
+
this.datalist.setAttribute("id", this.datalist.getAttribute("id") || uniqueId())
|
|
551
|
+
this.input.setAttribute('list', this.datalist.getAttribute("id"))
|
|
552
|
+
}
|
|
545
553
|
|
|
546
554
|
if (this.textInput) {
|
|
547
|
-
this.textInput.addEventListener("
|
|
555
|
+
this.textInput.addEventListener("input", this.handleTextInput.bind(this))
|
|
548
556
|
}
|
|
549
557
|
}
|
|
550
558
|
static get observedAttributes() {
|
|
@@ -577,24 +585,28 @@ class FigSlider extends HTMLElement {
|
|
|
577
585
|
if (this.textInput) {
|
|
578
586
|
this.textInput[name] = newValue
|
|
579
587
|
}
|
|
588
|
+
this.handleInput()
|
|
580
589
|
break;
|
|
581
590
|
}
|
|
582
591
|
}
|
|
583
592
|
}
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
this.slider.style.setProperty('--slider-percent', `${complete * 100}%`)
|
|
593
|
+
handleTextInput() {
|
|
594
|
+
if (this.textInput) {
|
|
595
|
+
this.input.value = Number(this.textInput.value)
|
|
596
|
+
this.handleInput()
|
|
589
597
|
}
|
|
590
598
|
}
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
599
|
+
|
|
600
|
+
handleInput() {
|
|
601
|
+
let min = Number(this.input.min)
|
|
602
|
+
let max = Number(this.input.max)
|
|
603
|
+
let val = Number(this.input.value)
|
|
604
|
+
this.value = val
|
|
605
|
+
let complete = (val - min) / (max - min)
|
|
606
|
+
this.style.setProperty("--slider-complete", complete)
|
|
594
607
|
if (this.textInput) {
|
|
595
|
-
this.textInput.value =
|
|
608
|
+
this.textInput.value = val
|
|
596
609
|
}
|
|
597
|
-
this.syncProps()
|
|
598
610
|
}
|
|
599
611
|
}
|
|
600
612
|
window.customElements.define('fig-slider', FigSlider);
|
package/package.json
CHANGED