@oicl/openbridge-webcomponents 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- package/.release-it.json +1 -1
- package/.storybook/preview.ts +0 -1
- package/CHANGELOG.md +13 -1
- package/__snapshots__/application-topbar--inactive.png +0 -0
- package/__snapshots__/button-button--raised-disabled.png +0 -0
- package/__snapshots__/input-slider--no-icons.png +0 -0
- package/__snapshots__/input-slider--no-value.png +0 -0
- package/__snapshots__/line-corner-line--primary.png +0 -0
- package/__snapshots__/line-example--air.png +0 -0
- package/__snapshots__/line-example--connector.png +0 -0
- package/__snapshots__/line-example--electric.png +0 -0
- package/__snapshots__/line-example--fluid.png +0 -0
- package/__snapshots__/line-horizontal-line--primary.png +0 -0
- package/__snapshots__/line-vertical-line--complex.png +0 -0
- package/__snapshots__/line-vertical-line--primary.png +0 -0
- package/custom-elements.json +764 -399
- package/dist/automation/corner-line/corner-line.d.ts +22 -0
- package/dist/automation/corner-line/corner-line.d.ts.map +1 -0
- package/dist/automation/corner-line/corner-line.js +161 -0
- package/dist/automation/corner-line/corner-line.js.map +1 -0
- package/dist/automation/horizontal-line/horizontal-line.d.ts +15 -0
- package/dist/automation/horizontal-line/horizontal-line.d.ts.map +1 -0
- package/dist/automation/horizontal-line/horizontal-line.js +110 -0
- package/dist/automation/horizontal-line/horizontal-line.js.map +1 -0
- package/dist/automation/index.d.ts +20 -0
- package/dist/automation/index.d.ts.map +1 -0
- package/dist/automation/index.js +42 -0
- package/dist/automation/index.js.map +1 -0
- package/dist/automation/vertical-line/vertical-line.d.ts +15 -0
- package/dist/automation/vertical-line/vertical-line.d.ts.map +1 -0
- package/dist/automation/vertical-line/vertical-line.js +111 -0
- package/dist/automation/vertical-line/vertical-line.js.map +1 -0
- package/dist/components/brilliance-menu/brilliance-menu.d.ts.map +1 -1
- package/dist/components/brilliance-menu/brilliance-menu.js +2 -0
- package/dist/components/brilliance-menu/brilliance-menu.js.map +1 -1
- package/dist/components/slider/slider.css.js +20 -0
- package/dist/components/slider/slider.css.js.map +1 -1
- package/dist/components/slider/slider.d.ts +8 -0
- package/dist/components/slider/slider.d.ts.map +1 -1
- package/dist/components/slider/slider.js +44 -18
- package/dist/components/slider/slider.js.map +1 -1
- package/dist/components/top-bar/top-bar.css.js +5 -1
- package/dist/components/top-bar/top-bar.css.js.map +1 -1
- package/dist/components/top-bar/top-bar.d.ts.map +1 -1
- package/dist/components/top-bar/top-bar.js +8 -8
- package/dist/components/top-bar/top-bar.js.map +1 -1
- package/package.json +18 -25
- package/src/automation/corner-line/corner-line.stories.ts +31 -0
- package/src/automation/corner-line/corner-line.ts +167 -0
- package/src/automation/horizontal-line/horizontal-line.stories.ts +28 -0
- package/src/automation/horizontal-line/horizontal-line.ts +100 -0
- package/src/automation/index.ts +41 -0
- package/src/automation/line.stories.ts +142 -0
- package/src/automation/vertical-line/vertical-line.stories.ts +71 -0
- package/src/automation/vertical-line/vertical-line.ts +104 -0
- package/src/components/brilliance-menu/brilliance-menu.ts +2 -0
- package/src/components/slider/slider.css +20 -0
- package/src/components/slider/slider.stories.ts +20 -1
- package/src/components/slider/slider.ts +43 -19
- package/src/components/top-bar/top-bar.css +4 -0
- package/src/components/top-bar/top-bar.ts +10 -8
- package/src/palettes/variables.css +64 -43
- package/script/svg-instruments/convert-svg.ts +0 -246
- package/script/svg-instruments/environment.d.ts +0 -7
- package/script/svg-instruments/exports.ts +0 -82
- package/script/svg-instruments/figma-types.ts +0 -804
- package/script/svg-instruments/figmaImport.ts +0 -79
- package/script/svg-instruments/main.ts +0 -109
@@ -17,8 +17,9 @@
|
|
17
17
|
--border-edge-color: rgba(0, 0, 0, .050);
|
18
18
|
--border-solid-color: rgb(51, 51, 51);
|
19
19
|
--border-icon-outline-color: rgba(0, 0, 0, .500);
|
20
|
+
--border-silhouette-color: rgb(255, 255, 255);
|
20
21
|
--instrument-enhanced-primary-color: rgb(26, 45, 255);
|
21
|
-
--instrument-enhanced-secondary-color: rgb(
|
22
|
+
--instrument-enhanced-secondary-color: rgb(37, 76, 147);
|
22
23
|
--instrument-enhanced-tertiary-color: rgba(46, 79, 138, .300);
|
23
24
|
--instrument-regular-primary-color: rgb(13, 13, 13);
|
24
25
|
--instrument-regular-secondary-color: rgb(89, 89, 89);
|
@@ -122,13 +123,13 @@
|
|
122
123
|
--on-flat-active-color: rgb(13, 13, 13);
|
123
124
|
--on-flat-neutral-color: rgba(0, 0, 0, .650);
|
124
125
|
--on-flat-disabled-color: rgba(0, 0, 0, .300);
|
125
|
-
--selected-enabled-background-color: rgb(
|
126
|
+
--selected-enabled-background-color: rgb(37, 76, 147);
|
126
127
|
--selected-enabled-border-color: rgba(0, 0, 0, .00);
|
127
|
-
--selected-hover-background-color: rgb(
|
128
|
+
--selected-hover-background-color: rgb(27, 55, 106);
|
128
129
|
--selected-hover-border-color: rgba(0, 0, 0, .00);
|
129
|
-
--selected-pressed-background-color: rgb(
|
130
|
+
--selected-pressed-background-color: rgb(16, 34, 65);
|
130
131
|
--selected-pressed-border-color: rgba(0, 0, 0, .00);
|
131
|
-
--selected-focused-background-color: rgb(
|
132
|
+
--selected-focused-background-color: rgb(37, 76, 147);
|
132
133
|
--selected-focused-border-color: rgba(0, 110, 225, .300);
|
133
134
|
--selected-disabled-background-color: rgba(0, 0, 0, .200);
|
134
135
|
--selected-disabled-border-color: rgba(0, 0, 0, .00);
|
@@ -174,6 +175,19 @@
|
|
174
175
|
--on-device-active-color: rgb(255, 255, 255);
|
175
176
|
--on-device-neutral-color: rgba(0, 0, 0, .450);
|
176
177
|
--on-device-disabled-color: rgb(179, 179, 179);
|
178
|
+
--notification-enabled-background-color: rgb(26, 45, 255);
|
179
|
+
--notification-enabled-border-color: rgba(0, 0, 0, .300);
|
180
|
+
--notification-hover-background-color: rgb(0, 19, 229);
|
181
|
+
--notification-hover-border-color: rgba(0, 0, 0, .300);
|
182
|
+
--notification-pressed-background-color: rgb(0, 15, 178);
|
183
|
+
--notification-pressed-border-color: rgba(0, 0, 0, .500);
|
184
|
+
--notification-focused-background-color: rgb(26, 45, 255);
|
185
|
+
--notification-focused-border-color: rgba(37, 76, 147, .500);
|
186
|
+
--notification-disabled-background-color: rgb(26, 45, 255);
|
187
|
+
--notification-disabled-border-color: rgba(0, 0, 0, .00);
|
188
|
+
--on-notification-active-color: rgb(255, 255, 255);
|
189
|
+
--on-notification-neutral-color: rgba(255, 255, 255, .600);
|
190
|
+
--on-notification-disabled-color: rgba(255, 255, 255, .300);
|
177
191
|
--running-enabled-background-color: rgb(0, 138, 23);
|
178
192
|
--running-enabled-border-color: rgba(0, 0, 0, .100);
|
179
193
|
--running-hover-background-color: rgb(27, 111, 27);
|
@@ -318,7 +332,7 @@
|
|
318
332
|
--icon-02-chevron-down: url('data:image/svg+xml,<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d=" M18 9.41L16.59 8L12 12.58L7.41 8L6 9.41L12 15.41L18 9.41Z" fill="rgba(0, 0, 0, .650)"/></svg>');
|
319
333
|
|
320
334
|
}
|
321
|
-
|
335
|
+
|
322
336
|
:root[data-obc-theme=day] {
|
323
337
|
--element-active-color: rgb(26, 26, 26);
|
324
338
|
--element-neutral-color: rgba(0, 0, 0, .590);
|
@@ -364,24 +378,20 @@
|
|
364
378
|
--alert-warning-color: rgb(246, 148, 0);
|
365
379
|
--alert-alarm-color: rgb(223, 27, 27);
|
366
380
|
--alert-critical-alarm-color: rgb(229, 0, 229);
|
367
|
-
--alert-limit-primary-color: rgba(0, 0, 0, .
|
368
|
-
--alert-limit-secondary-color: rgba(0, 0, 0, .
|
381
|
+
--alert-limit-primary-color: rgba(0, 0, 0, .080);
|
382
|
+
--alert-limit-secondary-color: rgba(0, 0, 0, .080);
|
369
383
|
--automation-device-primary-color: rgb(255, 255, 255);
|
370
384
|
--automation-device-secondary-color: rgb(112, 112, 112);
|
371
385
|
--automation-device-tertiary-color: rgb(0, 0, 0);
|
372
386
|
--automation-device-primary-inverted-color: rgb(15, 15, 15);
|
373
387
|
--automation-device-secondary-inverted-color: rgb(102, 102, 102);
|
374
388
|
--automation-device-tertiary-inverted-color: rgb(128, 128, 128);
|
375
|
-
--automation-button-primary-color: rgb(255, 255, 255);
|
376
|
-
--automation-button-tertiary-color: rgba(0, 0, 0, .200);
|
377
|
-
--automation-button-primary-inverted-color: rgb(224, 224, 224);
|
378
|
-
--automation-button-tertiary-inverted-color: rgba(0, 0, 0, .100);
|
379
389
|
--automation-pipe-primary-color: rgb(255, 255, 255);
|
380
|
-
--automation-pipe-secondary-color:
|
381
|
-
--automation-pipe-tertiary-color:
|
390
|
+
--automation-pipe-secondary-color: rgb(143, 143, 143);
|
391
|
+
--automation-pipe-tertiary-color: rgb(51, 51, 51);
|
382
392
|
--automation-pipe-primary-inverted-color: rgb(224, 224, 224);
|
383
|
-
--automation-pipe-secondary-inverted-color:
|
384
|
-
--automation-pipe-tertiary-inverted-color:
|
393
|
+
--automation-pipe-secondary-inverted-color: rgb(179, 179, 179);
|
394
|
+
--automation-pipe-tertiary-inverted-color: rgb(143, 143, 143);
|
385
395
|
--automation-pipe-overlay-color: rgba(0, 0, 0, .200);
|
386
396
|
--automation-pipe-disabled-color: rgba(0, 0, 0, .100);
|
387
397
|
--automation-acid-alkalis: rgb(231, 193, 244);
|
@@ -423,7 +433,7 @@
|
|
423
433
|
--raised-disabled-border-color: rgba(0, 0, 0, .100);
|
424
434
|
--on-raised-active-color: rgb(255, 255, 255);
|
425
435
|
--on-raised-neutral-color: rgba(255, 255, 255, .700);
|
426
|
-
--on-raised-disabled-color: rgba(0, 0, 0, .
|
436
|
+
--on-raised-disabled-color: rgba(0, 0, 0, .300);
|
427
437
|
--indent-enabled-background-color: rgba(0, 0, 0, .050);
|
428
438
|
--indent-enabled-border-color: rgba(0, 0, 0, .050);
|
429
439
|
--indent-hover-background-color: rgba(0, 0, 0, .100);
|
@@ -444,7 +454,7 @@
|
|
444
454
|
--flat-pressed-background-color: rgba(0, 0, 0, .120);
|
445
455
|
--flat-pressed-border-color: rgba(0, 0, 0, .00);
|
446
456
|
--flat-focused-background-color: rgba(0, 0, 0, .00);
|
447
|
-
--flat-focused-border-color:
|
457
|
+
--flat-focused-border-color: rgb(153, 206, 255);
|
448
458
|
--flat-disabled-background-color: rgba(0, 0, 0, .00);
|
449
459
|
--flat-disabled-border-color: rgba(0, 0, 0, .00);
|
450
460
|
--flat-activated-background-color: rgba(0, 0, 0, .050);
|
@@ -593,17 +603,20 @@
|
|
593
603
|
--font-ui-overline-size: 12px;
|
594
604
|
--font-ui-overline-weight: semibold;
|
595
605
|
--font-ui-overline-line-height: 24px;
|
606
|
+
--font-ui-overline-new-size: 16px;
|
607
|
+
--font-ui-overline-new-weight: semibold;
|
608
|
+
--font-ui-overline-new-line-height: 24px;
|
596
609
|
--font-ui-button-size: 16px;
|
597
|
-
--font-ui-button-weight:
|
610
|
+
--font-ui-button-weight: Medium;
|
598
611
|
--font-ui-button-line-height: 24px;
|
599
612
|
--font-ui-body-active-size: 16px;
|
600
|
-
--font-ui-body-active-weight:
|
613
|
+
--font-ui-body-active-weight: semibold;
|
601
614
|
--font-ui-body-active-line-height: 24px;
|
602
615
|
--font-ui-body-size: 16px;
|
603
616
|
--font-ui-body-weight: regular;
|
604
617
|
--font-ui-body-line-height: 24px;
|
605
618
|
--font-ui-label-active-size: 12px;
|
606
|
-
--font-ui-label-active-weight:
|
619
|
+
--font-ui-label-active-weight: semibold;
|
607
620
|
--font-ui-label-active-line-height: 16px;
|
608
621
|
--font-ui-label-size: 12px;
|
609
622
|
--font-ui-label-weight: regular;
|
@@ -617,6 +630,15 @@
|
|
617
630
|
--font-instrument-label-l-size: 64px;
|
618
631
|
--font-instrument-label-l-weight: regular;
|
619
632
|
--font-instrument-label-l-line-height: 80px;
|
633
|
+
--font-instrument-value-regular-size: 16px;
|
634
|
+
--font-instrument-value-regular-weight: Medium;
|
635
|
+
--font-instrument-value-regular-line-height: 24px;
|
636
|
+
--font-instrument-value-enhanced-size: 36px;
|
637
|
+
--font-instrument-value-enhanced-weight: Medium;
|
638
|
+
--font-instrument-value-enhanced-line-height: 48px;
|
639
|
+
--font-instrument-value-double-size: 72px;
|
640
|
+
--font-instrument-value-double-weight: Medium;
|
641
|
+
--font-instrument-value-double-line-height: 96px;
|
620
642
|
--font-instrument-value-s-size: 16px;
|
621
643
|
--font-instrument-value-s-weight: semibold;
|
622
644
|
--font-instrument-value-s-line-height: 24px;
|
@@ -658,12 +680,11 @@
|
|
658
680
|
--shadow-floating: 0px 4px 16px 0px rgba(0, 0, 0, .300);
|
659
681
|
--shadow-overlay: 0px 8px 32px 0px rgba(0, 0, 0, .400);
|
660
682
|
--shadow-focused: 0px 0px 0px 4px rgb(0, 59, 148);
|
661
|
-
|
662
683
|
--icon-02-chevron-up: url('data:image/svg+xml,<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M6 14.0002L7.41 15.4102L12 10.8302L16.59 15.4102L18 14.0002L12 8.00016L6 14.0002Z" fill="rgba(0, 0, 0, 0.55)"/></svg>');
|
663
684
|
--icon-02-chevron-down: url('data:image/svg+xml,<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M18 9.41L16.59 8L12 12.58L7.41 8L6 9.41L12 15.41L18 9.41Z" fill="rgba(0, 0, 0, 0.55)"/></svg>');
|
664
685
|
|
665
686
|
}
|
666
|
-
|
687
|
+
|
667
688
|
:root[data-obc-theme=dusk] {
|
668
689
|
--element-active-color: rgb(242, 242, 242);
|
669
690
|
--element-neutral-color: rgba(255, 255, 255, .550);
|
@@ -684,7 +705,7 @@
|
|
684
705
|
--border-silhouette-color: rgb(0, 0, 0);
|
685
706
|
--border-icon-outline-color: rgba(0, 0, 0, .500);
|
686
707
|
--border-solid-color: rgb(51, 51, 51);
|
687
|
-
--instrument-enhanced-primary-color: rgb(
|
708
|
+
--instrument-enhanced-primary-color: rgb(94, 213, 253);
|
688
709
|
--instrument-enhanced-secondary-color: rgb(86, 150, 199);
|
689
710
|
--instrument-enhanced-tertiary-color: rgba(92, 139, 193, .200);
|
690
711
|
--instrument-regular-primary-color: rgb(230, 230, 230);
|
@@ -841,6 +862,19 @@
|
|
841
862
|
--on-device-active-color: rgb(255, 255, 255);
|
842
863
|
--on-device-neutral-color: rgb(123, 123, 123);
|
843
864
|
--on-device-disabled-color: rgb(84, 84, 84);
|
865
|
+
--notification-enabled-background-color: rgb(94, 213, 253);
|
866
|
+
--notification-enabled-border-color: rgba(0, 0, 0, .500);
|
867
|
+
--notification-hover-background-color: rgb(154, 229, 254);
|
868
|
+
--notification-hover-border-color: rgba(0, 0, 0, .100);
|
869
|
+
--notification-pressed-background-color: rgb(17, 163, 212);
|
870
|
+
--notification-pressed-border-color: rgba(0, 0, 0, .200);
|
871
|
+
--notification-focused-background-color: rgb(94, 213, 253);
|
872
|
+
--notification-focused-border-color: rgb(247, 247, 247);
|
873
|
+
--notification-disabled-background-color: rgb(94, 213, 253);
|
874
|
+
--notification-disabled-border-color: rgba(0, 0, 0, .00);
|
875
|
+
--on-notification-active-color: rgb(0, 0, 0);
|
876
|
+
--on-notification-neutral-color: rgba(0, 0, 0, .600);
|
877
|
+
--on-notification-disabled-color: rgba(0, 0, 0, .200);
|
844
878
|
--running-enabled-background-color: rgb(19, 138, 0);
|
845
879
|
--running-enabled-border-color: rgba(0, 0, 0, .100);
|
846
880
|
--running-hover-background-color: rgb(23, 168, 0);
|
@@ -906,19 +940,6 @@
|
|
906
940
|
--on-critical-alarm-active-color: rgb(255, 255, 255);
|
907
941
|
--on-critical-alarm-neutral-color: rgba(255, 255, 255, .700);
|
908
942
|
--on-critical-alarm-disabled-color: rgba(255, 255, 255, .300);
|
909
|
-
--notification-enabled-background-color: rgb(129, 212, 254);
|
910
|
-
--notification-enabled-border-color: rgba(0, 0, 0, .500);
|
911
|
-
--notification-hover-background-color: rgb(90, 191, 242);
|
912
|
-
--notification-hover-border-color: rgba(0, 0, 0, .100);
|
913
|
-
--notification-pressed-background-color: rgb(60, 167, 221);
|
914
|
-
--notification-pressed-border-color: rgba(0, 0, 0, .200);
|
915
|
-
--notification-focused-background-color: rgb(129, 212, 254);
|
916
|
-
--notification-focused-border-color: rgb(247, 247, 247);
|
917
|
-
--notification-disabled-background-color: rgb(129, 212, 254);
|
918
|
-
--notification-disabled-border-color: rgba(0, 0, 0, .00);
|
919
|
-
--on-notification-active-color: rgb(0, 0, 0);
|
920
|
-
--on-notification-neutral-color: rgba(0, 0, 0, .600);
|
921
|
-
--on-notification-disabled-color: rgba(0, 0, 0, .200);
|
922
943
|
--font-ui-title-size: 24px;
|
923
944
|
--font-ui-title-weight: bold;
|
924
945
|
--font-ui-title-line-height: 32px;
|
@@ -996,7 +1017,7 @@
|
|
996
1017
|
--icon-02-chevron-up: url('data:image/svg+xml,<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M6 14.0002L7.41 15.4102L12 10.8302L16.59 15.4102L18 14.0002L12 8.00016L6 14.0002Z" fill="rgba(255, 255, 255, .550)"/></svg>');
|
997
1018
|
--icon-02-chevron-down: url('data:image/svg+xml,<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M18 9.41L16.59 8L12 12.58L7.41 8L6 9.41L12 15.41L18 9.41Z" fill="rgba(255, 255, 255, .550)"/></svg>');
|
998
1019
|
}
|
999
|
-
|
1020
|
+
|
1000
1021
|
|
1001
1022
|
:root[data-obc-theme=night] {
|
1002
1023
|
--element-active-color: rgb(71, 71, 0);
|
@@ -1254,7 +1275,7 @@
|
|
1254
1275
|
--on-critical-alarm-neutral-color: rgba(0, 0, 0, .700);
|
1255
1276
|
--on-critical-alarm-disabled-color: rgba(0, 0, 0, .300);
|
1256
1277
|
--font-ui-title-size: 24px;
|
1257
|
-
--font-ui-title-weight:
|
1278
|
+
--font-ui-title-weight: bold;
|
1258
1279
|
--font-ui-title-line-height: 32px;
|
1259
1280
|
--font-ui-subtitle-size: 24px;
|
1260
1281
|
--font-ui-subtitle-weight: regular;
|
@@ -1266,13 +1287,13 @@
|
|
1266
1287
|
--font-ui-button-weight: semibold;
|
1267
1288
|
--font-ui-button-line-height: 24px;
|
1268
1289
|
--font-ui-body-active-size: 16px;
|
1269
|
-
--font-ui-body-active-weight:
|
1290
|
+
--font-ui-body-active-weight: bold;
|
1270
1291
|
--font-ui-body-active-line-height: 24px;
|
1271
1292
|
--font-ui-body-size: 16px;
|
1272
1293
|
--font-ui-body-weight: regular;
|
1273
1294
|
--font-ui-body-line-height: 24px;
|
1274
1295
|
--font-ui-label-active-size: 12px;
|
1275
|
-
--font-ui-label-active-weight:
|
1296
|
+
--font-ui-label-active-weight: bold;
|
1276
1297
|
--font-ui-label-active-line-height: 16px;
|
1277
1298
|
--font-ui-label-size: 12px;
|
1278
1299
|
--font-ui-label-weight: regular;
|
@@ -1329,5 +1350,5 @@
|
|
1329
1350
|
|
1330
1351
|
--icon-02-chevron-up: url('data:image/svg+xml,<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M6 14.0002L7.41 15.4102L12 10.8302L16.59 15.4102L18 14.0002L12 8.00016L6 14.0002Z" fill="rgb(51, 51, 0)"/></svg>');
|
1331
1352
|
--icon-02-chevron-down: url('data:image/svg+xml,<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M18 9.41L16.59 8L12 12.58L7.41 8L6 9.41L12 15.41L18 9.41Z" fill="rgb(51, 51, 0)"/></svg>');
|
1332
|
-
|
1333
|
-
}
|
1353
|
+
|
1354
|
+
}
|
@@ -1,246 +0,0 @@
|
|
1
|
-
import {FrameNode, StyleDict, StyledNode} from './figma-types';
|
2
|
-
import {DOMParser, XMLSerializer} from 'xmldom';
|
3
|
-
|
4
|
-
function childNodes2Elements(nodes: NodeListOf<ChildNode>): Element[] {
|
5
|
-
const data = [];
|
6
|
-
for (let i = 0; i < nodes.length; i++) {
|
7
|
-
const node = nodes[i];
|
8
|
-
if (node.nodeName === '#text') continue;
|
9
|
-
if (node.nodeName === 'defs') continue;
|
10
|
-
data.push(node as Element);
|
11
|
-
}
|
12
|
-
return data;
|
13
|
-
}
|
14
|
-
|
15
|
-
function getSvgId(svgNode: Element): string {
|
16
|
-
let svgId = (svgNode.getAttribute('id') as string).replace('°', '°');
|
17
|
-
const reDeg = /°/gi;
|
18
|
-
svgId = svgId.replace(reDeg, '°');
|
19
|
-
const re = new RegExp('_[0-9]+$');
|
20
|
-
if (svgId.match(re)) {
|
21
|
-
svgId = svgId.replace(re, '');
|
22
|
-
}
|
23
|
-
return svgId;
|
24
|
-
}
|
25
|
-
|
26
|
-
function replaceAll(string: string, search: string, replace: string): string {
|
27
|
-
return string.split(search).join(replace);
|
28
|
-
}
|
29
|
-
|
30
|
-
function makeid(): string {
|
31
|
-
let result = '';
|
32
|
-
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
33
|
-
const charactersLength = characters.length;
|
34
|
-
for (let i = 0; i < 10; i++) {
|
35
|
-
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
36
|
-
}
|
37
|
-
return result;
|
38
|
-
}
|
39
|
-
|
40
|
-
export function convertSvg(
|
41
|
-
figmaElement: FrameNode,
|
42
|
-
svgString: string,
|
43
|
-
styles: StyleDict,
|
44
|
-
removeAttrs: boolean
|
45
|
-
): string {
|
46
|
-
const svgDoc = new DOMParser().parseFromString(svgString, 'text/svg');
|
47
|
-
const root = svgDoc.firstChild;
|
48
|
-
if (root === null) return '';
|
49
|
-
|
50
|
-
for (const nd of childNodes2Elements(root.childNodes)) {
|
51
|
-
const svgId = getSvgId(nd);
|
52
|
-
const elementId = figmaElement.name;
|
53
|
-
if (svgId !== elementId) {
|
54
|
-
console.warn(
|
55
|
-
`Figma element id and svg id does not match (${elementId} !== ${svgId})`
|
56
|
-
);
|
57
|
-
}
|
58
|
-
parseNode(figmaElement as unknown as StyledNode, nd, styles, removeAttrs);
|
59
|
-
}
|
60
|
-
let out = new XMLSerializer().serializeToString(svgDoc);
|
61
|
-
const clipPrefix = makeid();
|
62
|
-
out = replaceAll(out, 'url(#clip', `url(#${clipPrefix}clip`);
|
63
|
-
out = replaceAll(out, 'clipPath id="clip', `clipPath id="${clipPrefix}clip`);
|
64
|
-
out = replaceAll(out, 'url(#path-', `url(#${clipPrefix}path-`);
|
65
|
-
out = replaceAll(out, 'mask id="path-', `mask id="${clipPrefix}path-`);
|
66
|
-
return out;
|
67
|
-
}
|
68
|
-
|
69
|
-
function findFigmaNode(
|
70
|
-
figmaElement: StyledNode,
|
71
|
-
svgNode: Element
|
72
|
-
): StyledNode | undefined {
|
73
|
-
const path = getSvgPath(svgNode);
|
74
|
-
path.shift();
|
75
|
-
return searchFigmaNode(figmaElement, path);
|
76
|
-
}
|
77
|
-
|
78
|
-
/** Searching for figma node matching the svg id path.
|
79
|
-
*
|
80
|
-
* Supports figma nodes having same name.
|
81
|
-
* @param figmaElement
|
82
|
-
* @param svgIds
|
83
|
-
*/
|
84
|
-
function searchFigmaNode(
|
85
|
-
figmaElement: StyledNode,
|
86
|
-
svgIds: string[]
|
87
|
-
): StyledNode | undefined {
|
88
|
-
if (svgIds.length === 0) return figmaElement;
|
89
|
-
if (figmaElement.children === undefined) return undefined;
|
90
|
-
|
91
|
-
const currentId = svgIds.shift();
|
92
|
-
const figmaNodes = figmaElement.children
|
93
|
-
.filter((f) => f.name === currentId && f.visible !== false)
|
94
|
-
.map((f) => {
|
95
|
-
const ids = [...svgIds];
|
96
|
-
return searchFigmaNode(f, ids);
|
97
|
-
})
|
98
|
-
.filter((value) => value !== undefined) as StyledNode[];
|
99
|
-
if (figmaNodes.length > 0) return figmaNodes[0];
|
100
|
-
else return undefined;
|
101
|
-
}
|
102
|
-
|
103
|
-
function getSvgPath(svgNode: Element): string[] {
|
104
|
-
if (svgNode.parentNode === null) return [];
|
105
|
-
const svgId = getSvgId(svgNode);
|
106
|
-
|
107
|
-
const ids = getSvgPath(svgNode.parentNode as Element);
|
108
|
-
if (svgId.length !== 0) {
|
109
|
-
ids.push(svgId);
|
110
|
-
}
|
111
|
-
return ids;
|
112
|
-
}
|
113
|
-
|
114
|
-
function parseNode(
|
115
|
-
figmaRoot: StyledNode,
|
116
|
-
svgNode: Element,
|
117
|
-
styles: StyleDict,
|
118
|
-
removeAttrs: boolean
|
119
|
-
) {
|
120
|
-
const figmaNode = findFigmaNode(figmaRoot, svgNode);
|
121
|
-
if (figmaNode === undefined) {
|
122
|
-
console.warn(
|
123
|
-
`Missing figma node: ${svgNode.getAttribute('id')}. Skipping subnodes.`
|
124
|
-
);
|
125
|
-
return;
|
126
|
-
}
|
127
|
-
|
128
|
-
const cssClasses = [];
|
129
|
-
if (svgNode.hasAttribute('id')) {
|
130
|
-
if (
|
131
|
-
svgNode.hasAttribute('id') &&
|
132
|
-
figmaNode.styles &&
|
133
|
-
figmaNode.styles.stroke &&
|
134
|
-
svgNode.hasAttribute('stroke')
|
135
|
-
) {
|
136
|
-
if (removeAttrs) {
|
137
|
-
svgNode.removeAttribute('stroke');
|
138
|
-
svgNode.removeAttribute('stroke-opacity');
|
139
|
-
}
|
140
|
-
const strokeStyleId = figmaNode.styles.stroke;
|
141
|
-
if (strokeStyleId !== undefined) {
|
142
|
-
const styleName = convertStyleName(
|
143
|
-
styles[strokeStyleId].name,
|
144
|
-
'-stroke'
|
145
|
-
);
|
146
|
-
cssClasses.push(styleName);
|
147
|
-
}
|
148
|
-
}
|
149
|
-
|
150
|
-
if (
|
151
|
-
svgNode.hasAttribute('id') &&
|
152
|
-
figmaNode.styles &&
|
153
|
-
figmaNode.styles.fill &&
|
154
|
-
svgNode.hasAttribute('fill')
|
155
|
-
) {
|
156
|
-
if (removeAttrs) {
|
157
|
-
svgNode.removeAttribute('fill');
|
158
|
-
}
|
159
|
-
const strokeStyleId = figmaNode.styles.fill;
|
160
|
-
if (strokeStyleId !== undefined) {
|
161
|
-
const styleName = convertStyleName(styles[strokeStyleId].name, '-fill');
|
162
|
-
cssClasses.push(styleName);
|
163
|
-
}
|
164
|
-
}
|
165
|
-
} else if (figmaNode.styles) {
|
166
|
-
const hasBackground =
|
167
|
-
figmaNode.background && figmaNode.background.length === 1;
|
168
|
-
const svgHasFill = svgNode.hasAttribute('fill');
|
169
|
-
const hasStrokeInsideOrOutside =
|
170
|
-
figmaNode.strokeAlign &&
|
171
|
-
(figmaNode.strokeAlign === 'INSIDE' ||
|
172
|
-
figmaNode.strokeAlign === 'OUTSIDE');
|
173
|
-
const mask = svgNode.getAttribute('mask');
|
174
|
-
const hasMaskInsideOrOutside =
|
175
|
-
mask && (mask.match(/inside/) || mask.match(/outside/));
|
176
|
-
if (
|
177
|
-
svgHasFill &&
|
178
|
-
!hasMaskInsideOrOutside &&
|
179
|
-
((hasBackground && figmaNode.styles.fills) || figmaNode.styles.fill)
|
180
|
-
) {
|
181
|
-
// Special case for background fill for frame
|
182
|
-
if (removeAttrs) {
|
183
|
-
svgNode.removeAttribute('fill');
|
184
|
-
}
|
185
|
-
|
186
|
-
const strokeStyleId = figmaNode.styles.fills || figmaNode.styles.fill;
|
187
|
-
if (strokeStyleId !== undefined) {
|
188
|
-
const styleName = convertStyleName(styles[strokeStyleId].name, '-fill');
|
189
|
-
cssClasses.push(styleName);
|
190
|
-
}
|
191
|
-
}
|
192
|
-
|
193
|
-
if (
|
194
|
-
hasStrokeInsideOrOutside &&
|
195
|
-
hasMaskInsideOrOutside &&
|
196
|
-
svgHasFill &&
|
197
|
-
figmaNode.styles &&
|
198
|
-
figmaNode.styles.stroke
|
199
|
-
) {
|
200
|
-
if (removeAttrs) {
|
201
|
-
svgNode.removeAttribute('fill');
|
202
|
-
}
|
203
|
-
const strokeStyleId = figmaNode.styles.stroke;
|
204
|
-
if (strokeStyleId !== undefined) {
|
205
|
-
const styleName = convertStyleName(styles[strokeStyleId].name, '-fill');
|
206
|
-
cssClasses.push(styleName);
|
207
|
-
}
|
208
|
-
}
|
209
|
-
|
210
|
-
const hasStroke = figmaNode.strokes && figmaNode.strokes.length === 1;
|
211
|
-
if (
|
212
|
-
hasStroke &&
|
213
|
-
svgNode.hasAttribute('stroke') &&
|
214
|
-
figmaNode.styles &&
|
215
|
-
figmaNode.styles.strokes
|
216
|
-
) {
|
217
|
-
// Special case for stroke on frame
|
218
|
-
if (removeAttrs) {
|
219
|
-
svgNode.removeAttribute('stroke');
|
220
|
-
}
|
221
|
-
const strokeStyleId = figmaNode.styles.strokes;
|
222
|
-
if (strokeStyleId !== undefined) {
|
223
|
-
const styleName = convertStyleName(
|
224
|
-
styles[strokeStyleId].name,
|
225
|
-
'-stroke'
|
226
|
-
);
|
227
|
-
cssClasses.push(styleName);
|
228
|
-
}
|
229
|
-
}
|
230
|
-
}
|
231
|
-
|
232
|
-
if (cssClasses.length > 0) {
|
233
|
-
svgNode.setAttribute('class', cssClasses.join(' '));
|
234
|
-
}
|
235
|
-
const childSvgs = childNodes2Elements(svgNode.childNodes);
|
236
|
-
if (childSvgs.length > 0) {
|
237
|
-
for (let i = 0; i < childSvgs.length; i++) {
|
238
|
-
const svgNode = childSvgs[i];
|
239
|
-
parseNode(figmaRoot, svgNode, styles, removeAttrs);
|
240
|
-
}
|
241
|
-
}
|
242
|
-
}
|
243
|
-
|
244
|
-
function convertStyleName(str: string, suffix: string): string {
|
245
|
-
return 'ob-' + str.replace(/\//g, '-').toLowerCase() + suffix;
|
246
|
-
}
|
@@ -1,82 +0,0 @@
|
|
1
|
-
export interface ExportDef {
|
2
|
-
name: string;
|
3
|
-
path: string[]; // Array of subpath for targeting the svg export in Figma
|
4
|
-
outputFolder: string; // sub folder of ./gen
|
5
|
-
nonScaling?: boolean;
|
6
|
-
}
|
7
|
-
|
8
|
-
const staticExportComponents: ExportDef[] = [];
|
9
|
-
|
10
|
-
function tickMarks(): ExportDef[] {
|
11
|
-
const circleDegrees = ['0', '1', '2', '5', '9', '10', '30', '45', '90'];
|
12
|
-
const tickType = ['Primary', 'Secondary', 'Tertiary'];
|
13
|
-
const circleTickMarks: ExportDef[] = [];
|
14
|
-
|
15
|
-
for (const degree of circleDegrees) {
|
16
|
-
for (const tick of tickType) {
|
17
|
-
const def: ExportDef = {
|
18
|
-
name: `${tick}Tickmark${degree}`,
|
19
|
-
path: [
|
20
|
-
'P2 Building blocks',
|
21
|
-
'Watchface elements',
|
22
|
-
'Tickmarks - Compass',
|
23
|
-
`Degree=${degree}°, Tick size=${tick}`,
|
24
|
-
],
|
25
|
-
outputFolder: 'Tickmarks',
|
26
|
-
nonScaling: true,
|
27
|
-
};
|
28
|
-
circleTickMarks.push(def);
|
29
|
-
}
|
30
|
-
}
|
31
|
-
|
32
|
-
const size = ['Medium', 'Large'];
|
33
|
-
const toplines: ExportDef[] = size.map((s) => ({
|
34
|
-
name: `Topline${s}`,
|
35
|
-
path: [
|
36
|
-
'P2 Building blocks',
|
37
|
-
'Watchface',
|
38
|
-
'Azimuth watchface',
|
39
|
-
`Size=${s}, Tickmarks=90°, Labels=False, Detailed=False, PORT / STBD=False`,
|
40
|
-
'watchface',
|
41
|
-
'top-line',
|
42
|
-
],
|
43
|
-
outputFolder: 'Tickmarks',
|
44
|
-
}));
|
45
|
-
return [...circleTickMarks, ...toplines];
|
46
|
-
}
|
47
|
-
|
48
|
-
function watchface(): ExportDef[] {
|
49
|
-
const watchface: ExportDef[] = [];
|
50
|
-
const types = [
|
51
|
-
{name: 'Regular', tag: 'Regular'},
|
52
|
-
{name: 'PORT STBD', tag: 'PORT_STBD'},
|
53
|
-
{name: 'Positive / Negative', tag: 'Positive_Negative'},
|
54
|
-
{name: 'Off', tag: 'Off'},
|
55
|
-
{name: 'Bar', tag: 'Bar'},
|
56
|
-
];
|
57
|
-
const size = ['Small', 'Medium', 'Large'];
|
58
|
-
|
59
|
-
for (const type of types) {
|
60
|
-
for (const s of size) {
|
61
|
-
const def: ExportDef = {
|
62
|
-
name: `${type.tag}Watchface${s}`,
|
63
|
-
path: [
|
64
|
-
'P2 Building blocks',
|
65
|
-
'Watchface elements',
|
66
|
-
'Watchface circle',
|
67
|
-
`Size=${s}, Type=${type.name}, Condensed=False, Arc=Off`,
|
68
|
-
],
|
69
|
-
outputFolder: 'Watchface',
|
70
|
-
};
|
71
|
-
watchface.push(def);
|
72
|
-
}
|
73
|
-
}
|
74
|
-
|
75
|
-
return watchface;
|
76
|
-
}
|
77
|
-
|
78
|
-
export const exportComponents = [
|
79
|
-
...staticExportComponents,
|
80
|
-
...tickMarks(),
|
81
|
-
...watchface(),
|
82
|
-
];
|