@plexui/styles 0.1.33 → 0.1.35
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/dist/es/components/Accordion/Accordion.module.css +26 -1
- package/dist/es/components/Alert/Alert.module.css +213 -1
- package/dist/es/components/Badge/Badge.module.css +37 -0
- package/dist/es/components/Breadcrumb/Breadcrumb.module.css +63 -0
- package/dist/es/components/Button/Button.module.css +123 -22
- package/dist/es/components/Button/NavigationButton.module.css +17 -0
- package/dist/es/components/ButtonGroup/ButtonGroup.module.css +227 -20
- package/dist/es/components/Card/Card.module.css +31 -6
- package/dist/es/components/Checkbox/Checkbox.module.css +26 -72
- package/dist/es/components/CodeBlock/CodeBlock.module.css +34 -1
- package/dist/es/components/ColorPicker/ColorPicker.module.css +414 -0
- package/dist/es/components/ContextMenu/ContextMenu.module.css +55 -0
- package/dist/es/components/DataTable/DataTable.module.css +4 -0
- package/dist/es/components/DatePicker/Calendar.module.css +279 -6
- package/dist/es/components/DatePicker/CalendarNavigationIcon.module.css +10 -0
- package/dist/es/components/DateRangePicker/Calendar.module.css +226 -4
- package/dist/es/components/DateRangePicker/Trigger.module.css +45 -2
- package/dist/es/components/Dialog/Dialog.module.css +871 -89
- package/dist/es/components/EmptyMessage/EmptyMessage.module.css +52 -0
- package/dist/es/components/Field/Field.module.css +574 -24
- package/dist/es/components/FieldGroup/FieldGroup.module.css +188 -3
- package/dist/es/components/FileUpload/FileUpload.module.css +74 -1
- package/dist/es/components/FloatingLabelInput/FloatingLabelInput.module.css +40 -1
- package/dist/es/components/FloatingLabelSelect/FloatingLabelSelect.module.css +28 -1
- package/dist/es/components/IndexBar/IndexBar.module.css +146 -0
- package/dist/es/components/Indicator/LoadingIndicator.module.css +14 -7
- package/dist/es/components/Input/Input.module.css +198 -1
- package/dist/es/components/InputGroup/InputGroup.module.css +4 -0
- package/dist/es/components/MarkdownEditor/MarkdownEditor.module.css +18 -0
- package/dist/es/components/Menu/Menu.module.css +544 -34
- package/dist/es/components/OTPInput/OTPInput.module.css +6 -1
- package/dist/es/components/Page/Page.module.css +391 -31
- package/dist/es/components/PageControl/PageControl.module.css +81 -0
- package/dist/es/components/PhoneLayout/PhoneLayout.module.css +10 -0
- package/dist/es/components/Popover/Popover.module.css +17 -1
- package/dist/es/components/Select/Select.module.css +201 -9
- package/dist/es/components/SelectControl/SelectControl.module.css +151 -4
- package/dist/es/components/Sidebar/Sidebar.module.css +624 -71
- package/dist/es/components/Slider/Slider.module.css +132 -45
- package/dist/es/components/Sortable/Sortable.module.css +7 -3
- package/dist/es/components/Stepper/Stepper.module.css +98 -0
- package/dist/es/components/SwipeActions/SwipeActions.module.css +166 -0
- package/dist/es/components/Switch/Switch.module.css +59 -4
- package/dist/es/components/TabBar/TabBar.module.css +478 -0
- package/dist/es/components/Tabs/Tabs.module.css +315 -3
- package/dist/es/components/TagInput/TagInput.module.css +50 -9
- package/dist/es/components/Textarea/Textarea.module.css +6 -0
- package/dist/es/components/Tip/Tip.module.css +456 -0
- package/dist/es/components/Toast/Toast.module.css +197 -9
- package/dist/es/components/Toolbar/Toolbar.module.css +850 -21
- package/dist/es/styles/katex-fonts/KaTeX_AMS-Regular.woff2 +0 -0
- package/dist/es/styles/katex-fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
- package/dist/es/styles/katex-fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
- package/dist/es/styles/katex-fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
- package/dist/es/styles/katex-fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
- package/dist/es/styles/katex-fonts/KaTeX_Main-Bold.woff2 +0 -0
- package/dist/es/styles/katex-fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
- package/dist/es/styles/katex-fonts/KaTeX_Main-Italic.woff2 +0 -0
- package/dist/es/styles/katex-fonts/KaTeX_Main-Regular.woff2 +0 -0
- package/dist/es/styles/katex-fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
- package/dist/es/styles/katex-fonts/KaTeX_Math-Italic.woff2 +0 -0
- package/dist/es/styles/katex-fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
- package/dist/es/styles/katex-fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
- package/dist/es/styles/katex-fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
- package/dist/es/styles/katex-fonts/KaTeX_Script-Regular.woff2 +0 -0
- package/dist/es/styles/katex-fonts/KaTeX_Size1-Regular.woff2 +0 -0
- package/dist/es/styles/katex-fonts/KaTeX_Size2-Regular.woff2 +0 -0
- package/dist/es/styles/katex-fonts/KaTeX_Size3-Regular.woff2 +0 -0
- package/dist/es/styles/katex-fonts/KaTeX_Size4-Regular.woff2 +0 -0
- package/dist/es/styles/katex-fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
- package/dist/es/styles/katex-fonts/LICENSE +21 -0
- package/dist/es/styles/katex.min.css +666 -730
- package/dist/es/styles/mobile-materials.css +145 -14
- package/dist/es/styles/mobile-surfaces.css +82 -32
- package/dist/es/styles/touch.css +940 -92
- package/dist/es/styles/variables-components.css +356 -17
- package/package.json +1 -1
- package/postcss/parseLightDark.mjs +20 -2
- package/postcss/phoneLayoutScope.mjs +134 -0
- package/postcss.config.mjs +3 -0
|
@@ -100,8 +100,10 @@
|
|
|
100
100
|
--navigation-button-size: var(--control-size-2xl);
|
|
101
101
|
--navigation-button-back-icon-size: 32px;
|
|
102
102
|
--navigation-button-close-icon-size: 34px;
|
|
103
|
-
/*
|
|
104
|
-
|
|
103
|
+
/* The checkmark of a bar's confirm, sized by native ink over the kit (plan 162): Files View Options draws
|
|
104
|
+
17.7 × 17.3pt with a 2.1pt line (IMG_5686), Photos New Album 18.3pt square with 2.3pt (IMG_5453); the
|
|
105
|
+
iOS 26 kit's 15 × 14.5 is smaller. The Check box of 30px draws about 17.8 × 16.5 with a 2.5px line (owner 08.11). */
|
|
106
|
+
--navigation-button-confirm-icon-size: 30px;
|
|
105
107
|
|
|
106
108
|
/* =============================================
|
|
107
109
|
Card
|
|
@@ -154,6 +156,20 @@
|
|
|
154
156
|
--button-group-text-border-color: var(--color-border-secondary-outline, var(--color-border));
|
|
155
157
|
--button-group-text-font-size: var(--font-text-sm-size);
|
|
156
158
|
--button-group-text-font-weight: var(--font-weight-medium);
|
|
159
|
+
/* A glass group on a phone (`mobileMaterial="glass"`, or any group in a Toolbar): the Button Group of the iOS 27
|
|
160
|
+
kit (Toolbars 507:25993, _Buttons - 44pt and 48pt, Type=Button Group). A row is the 44pt top bar's capsule,
|
|
161
|
+
160 wide with three symbols: 2 + 44 + 12 + 44 + 12 + 44 + 2, the centers of the kit's 36pt symbols 56 apart
|
|
162
|
+
(padding 6, gap 20). A column is the kit's only vertical one, the 48pt capsule, 48 x 164 with three symbols:
|
|
163
|
+
4 + 48 + 6 + 48 + 6 + 48 + 4 (the kit's padding 10, gap 18 around 36pt symbols). Groups side by side keep the
|
|
164
|
+
10px of the top bar's items. In a Toolbar a group takes the bar's own sizes instead. */
|
|
165
|
+
--button-group-glass-item-size: var(--toolbar-top-item-size);
|
|
166
|
+
--button-group-glass-gap: var(--toolbar-group-gap);
|
|
167
|
+
--button-group-glass-padding: var(--toolbar-group-padding);
|
|
168
|
+
--button-group-glass-vertical-item-size: var(--toolbar-bottom-item-size);
|
|
169
|
+
--button-group-glass-vertical-gap: var(--toolbar-bottom-group-gap);
|
|
170
|
+
--button-group-glass-vertical-padding: var(--toolbar-bottom-group-padding);
|
|
171
|
+
--button-group-glass-nested-gap: var(--toolbar-top-item-gap);
|
|
172
|
+
--button-group-glass-label-gutter: var(--toolbar-label-gutter);
|
|
157
173
|
|
|
158
174
|
/* =============================================
|
|
159
175
|
Accordion
|
|
@@ -294,6 +310,39 @@
|
|
|
294
310
|
--field-group-description-font-size: var(--font-text-sm-size);
|
|
295
311
|
--field-group-description-line-height: var(--font-text-sm-line-height);
|
|
296
312
|
|
|
313
|
+
/* =============================================
|
|
314
|
+
Swipe actions
|
|
315
|
+
============================================= */
|
|
316
|
+
/* Actions behind a row of a list, after the iOS 27 kit Row with Swipe Actions (Lists 550:49969; there is no native
|
|
317
|
+
frame of a swipe): Symbol Only capsules of 60x44 with the symbol in 8px ends; Symbol and Label 84x44 with a 16pt
|
|
318
|
+
symbol 8px before a 13/15 label; Symbol and Label Tall a 60x38 capsule 6px from the top of a row of 68 with a
|
|
319
|
+
13/15 medium label 5px under it. The actions stand 10px apart, 16px from the edge and 10px from the content. A
|
|
320
|
+
17pt symbol draws as a 20px PlexUI icon, a 16pt one as 18px. A longer label widens its capsule past 84 with the
|
|
321
|
+
kit's 4px ends (text 4px in clears the round end of a 44px capsule). The content of a revealed row is a capsule
|
|
322
|
+
of the row's color on the background of the list (SwipeActions.module.css: on a phone the canvas of the Page and
|
|
323
|
+
the fill of a FieldGroup, on a desktop the secondary surface under the surface). */
|
|
324
|
+
--swipe-actions-gap: 10px;
|
|
325
|
+
--swipe-actions-edge-inset: 16px;
|
|
326
|
+
--swipe-actions-content-gap: 10px;
|
|
327
|
+
--swipe-actions-content-radius: 9999px;
|
|
328
|
+
--swipe-actions-action-height: 44px;
|
|
329
|
+
--swipe-actions-action-min-width: 60px;
|
|
330
|
+
--swipe-actions-action-padding-inline: 8px;
|
|
331
|
+
--swipe-actions-icon-size: 20px;
|
|
332
|
+
--swipe-actions-labeled-min-width: 84px;
|
|
333
|
+
--swipe-actions-labeled-padding-inline: 4px;
|
|
334
|
+
--swipe-actions-labeled-icon-size: 18px;
|
|
335
|
+
--swipe-actions-label-gap: 8px;
|
|
336
|
+
--swipe-actions-label-font-size: 13px;
|
|
337
|
+
--swipe-actions-label-line-height: 15px;
|
|
338
|
+
--swipe-actions-label-font-weight: var(--font-weight-normal);
|
|
339
|
+
--swipe-actions-tall-action-height: 38px;
|
|
340
|
+
--swipe-actions-tall-padding-top: 6px;
|
|
341
|
+
--swipe-actions-tall-padding-bottom: 4px;
|
|
342
|
+
--swipe-actions-caption-gap: 5px;
|
|
343
|
+
--swipe-actions-caption-font-weight: var(--font-weight-medium);
|
|
344
|
+
--swipe-actions-duration: 250ms;
|
|
345
|
+
|
|
297
346
|
/* =============================================
|
|
298
347
|
FloatingLabelInput
|
|
299
348
|
============================================= */
|
|
@@ -374,8 +423,13 @@
|
|
|
374
423
|
--dialog-alert-radius: 34px;
|
|
375
424
|
--dialog-alert-padding: 14px;
|
|
376
425
|
--dialog-alert-action-height: 48px;
|
|
377
|
-
|
|
426
|
+
/* The capsule of a sheet's footer action: native setup sheets draw it 53pt tall (IMG_5432 Wallet, 159px at
|
|
427
|
+
3x; IMG_5509, 160px), owner 08.11. */
|
|
428
|
+
--dialog-sheet-action-height: 53px;
|
|
378
429
|
--dialog-sheet-radius: 38px;
|
|
430
|
+
/* Native iOS 26 dims the page under a phone Sheet or Alert to 80% in light (Sheets IMG_5437/5444/5453/5470/
|
|
431
|
+
5471/5491, Alert iOS2 IMG_5533: white 255 to 204, grouped 242/242/247 to 193/193/197) and to 50% in dark
|
|
432
|
+
(Alert iOS2 IMG_5532: 28 to 14, red 255 to 128). A dark Sheet keeps the same 50%: no native frame shows it. */
|
|
379
433
|
--dialog-sheet-close-size: var(--control-size-2xl);
|
|
380
434
|
--dialog-sheet-close-icon-size: 34px;
|
|
381
435
|
--dialog-mobile-type-size: 17px;
|
|
@@ -432,15 +486,33 @@
|
|
|
432
486
|
--toolbar-sheet-padding-top: 16px;
|
|
433
487
|
--toolbar-bottom-padding-top: 4px;
|
|
434
488
|
--toolbar-bottom-fill-padding-top: 12px;
|
|
435
|
-
|
|
489
|
+
/* Native iOS 26 bottom bars (Mail, Contacts, Notes at 430 x 932, IMG_5551, 5737, 5736) stand their 48pt items
|
|
490
|
+
28 above the screen's edge, the 34 home indicator inset less 6. Without an inset (a browser page without
|
|
491
|
+
viewport-fit=cover) they keep 16 to the window's edge. */
|
|
492
|
+
--toolbar-bottom-padding-bottom: max(16px, calc(var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)) - 6px));
|
|
436
493
|
--toolbar-search-padding-bottom: 14px;
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
494
|
+
/* The search field of those bars: the magnifier draws 16.33 of ink with a stroke of 2, 14.0 from the field's
|
|
495
|
+
edge, and "Search" starts at 41.67, set in Regular in the secondary label color (rgb 148 to 150 on the
|
|
496
|
+
glass). SearchSm in a 23.75px box draws that ink: 3.46 of the box lies before it, so the gutter is 10.54. The
|
|
497
|
+
S of "Search" inks 0.95 after its origin in SF Pro 17, so the gap to the text is 6.43 (overlaid on IMG_5737:
|
|
498
|
+
the ink starts at 41.67 and sits on the native baseline within 0.33). */
|
|
499
|
+
--toolbar-search-gutter: 10.54px;
|
|
500
|
+
--toolbar-search-icon-gap: 6.43px;
|
|
501
|
+
--toolbar-search-icon-size: 23.75px;
|
|
502
|
+
--toolbar-search-font-weight: 400;
|
|
440
503
|
--toolbar-flat-opacity: 80%;
|
|
441
504
|
--toolbar-flat-blur: 60px;
|
|
442
|
-
|
|
443
|
-
|
|
505
|
+
/* The large title starts 21pt under the row of controls in iOS 26 Mail and Freeform (iOS2 IMG_5530, 5531,
|
|
506
|
+
5534: controls 59 to 103, title baseline 157 at 430pt); the kit's 10 sets it 11pt too high. */
|
|
507
|
+
--toolbar-large-title-gap: 21px;
|
|
508
|
+
/* A bar symbol, sized by its drawn glyph (plan 162): the kit's 44pt bar button holds a 29pt symbol box
|
|
509
|
+
that draws about 22pt (Apps 2.4, Toolbar button top 39972:316665: a check of 21.75 × 15.7, a heart of
|
|
510
|
+
22 × 20), and native Freeform draws its ellipsis 19.7pt wide with 4pt dots (IMG_5684). A PlexUI icon
|
|
511
|
+
of 26px draws the same: DotsHorizontal 19.5 wide with 4.3px dots (owner 08.11; 24px was small). */
|
|
512
|
+
--toolbar-icon-size: 26px;
|
|
513
|
+
/* A symbol with less ink, as the plus of a Contacts bar: 17.67 of ink with a stroke of 2 (IMG_5737), which
|
|
514
|
+
PlusLg draws in a 23.56px box. A bar button with iconSize="sm" takes it. */
|
|
515
|
+
--toolbar-icon-size-sm: 23.56px;
|
|
444
516
|
--toolbar-label-font-size: 17px;
|
|
445
517
|
--toolbar-label-line-height: 22px;
|
|
446
518
|
--toolbar-label-font-weight: 510;
|
|
@@ -464,6 +536,22 @@
|
|
|
464
536
|
--toolbar-edge-blur-large: 10px;
|
|
465
537
|
--toolbar-group-item-hover: color-mix(in srgb, var(--color-text) 4%, transparent);
|
|
466
538
|
--toolbar-group-item-active: color-mix(in srgb, var(--color-text) 8%, transparent);
|
|
539
|
+
/* A disabled prominent bar button gives up its tint for a gray capsule, in PlexUI alpha colors. Native iOS 26,
|
|
540
|
+
light (IMG_5441/5471/5472/5473): 210-213 on the grouped 242/242/246 bar, about 13% black, under a white
|
|
541
|
+
label: alpha-12 and gray-0. Dark (iOS2 IMG_5523/5526): 79/79/81 on the 28/28/29 sheet, about 22% white,
|
|
542
|
+
under a 131/131/133 glyph, 30% white: alpha-20 and alpha-30. */
|
|
543
|
+
/* A prominent bar button (NavigationButton confirm, a solid primary or info Button) is tinted with the accent: the
|
|
544
|
+
kit's Symbol and Text - Prominent (iOS 27 Buttons - 44pt, 5720:29596) lay accents/blue #08f under a
|
|
545
|
+
#f5f5f5 symbol or label, and native glass shows 0/133/251 (Photos checkmark, IMG_5453): the info solid
|
|
546
|
+
of PlexUI, blue-400, under white (owner, 08.11). Its edge is the glass's: the sides darkened (kit, 25
|
|
547
|
+
levels; native, 0/113/217) and light along the top and the bottom (kit Glass Effect, a +40 dodge 10px
|
|
548
|
+
deep at both; native 187 at the top and 205 at the bottom on 133, 152 on the diagonals, none at the sides).
|
|
549
|
+
Set the background to --color-background-primary-solid to keep the PlexUI primary. */
|
|
550
|
+
--toolbar-prominent-background: var(--color-background-info-solid);
|
|
551
|
+
--toolbar-prominent-background-hover: var(--color-background-info-solid-hover);
|
|
552
|
+
--toolbar-prominent-background-active: var(--color-background-info-solid-active);
|
|
553
|
+
--toolbar-prominent-color: var(--color-text-info-solid);
|
|
554
|
+
--toolbar-prominent-sheen: linear-gradient(rgb(255 255 255 / 16%), transparent 6px, transparent calc(100% - 8px), rgb(255 255 255 / 16%));
|
|
467
555
|
|
|
468
556
|
/* =============================================
|
|
469
557
|
Page
|
|
@@ -478,6 +566,17 @@
|
|
|
478
566
|
--page-bar-height: 36px;
|
|
479
567
|
--page-bar-height-phone: 44px;
|
|
480
568
|
--page-bar-gap: 24px;
|
|
569
|
+
/* A glass bar: thin enough that what scrolls under it reads through the blur (owner 08.11: 72% was too
|
|
570
|
+
opaque); the Thin material of the iOS kit (Materials 224:56302) is white 40% under a 50px blur. */
|
|
571
|
+
/* The soft scroll edge covers content fully down to the bottom of the bar, as native iOS 26 bars do
|
|
572
|
+
(IMG_5503: the cover holds at 249 to 252 over white to 10pt under the row of controls, the bar's bottom),
|
|
573
|
+
then fades out over this tail past the bar (owner 08.11: 16px read too short). */
|
|
574
|
+
--page-bar-soft-tail: 32px;
|
|
575
|
+
/* The blur of a glass bar: light enough that the lines scrolled under it still read as smudged text
|
|
576
|
+
(owner 08.11: at 20px the 17px text of a sheet vanished and the bar read as opaque white; 10px still
|
|
577
|
+
nearly hides it, 6px shows it). The saturation is Apple's bar material (180%). */
|
|
578
|
+
--page-bar-glass-filter: blur(6px) saturate(180%);
|
|
579
|
+
/* The line of a hard scroll edge: iOS 26 kit Materials, Scroll Edge Effect - Hard (5661:26978), 1pt black 12%. */
|
|
481
580
|
--page-title-font-size: 20px;
|
|
482
581
|
--page-title-line-height: 26px;
|
|
483
582
|
--page-content-padding-top: 16px;
|
|
@@ -488,6 +587,43 @@
|
|
|
488
587
|
============================================= */
|
|
489
588
|
--popover-radius: var(--radius-xl);
|
|
490
589
|
|
|
590
|
+
/* =============================================
|
|
591
|
+
Tip
|
|
592
|
+
============================================= */
|
|
593
|
+
/* A tip as the TipKit kit draws it (TipKit Community, macOS Mini Tip 118:5175 and iOS Mini Tip 41:1351, the
|
|
594
|
+
same layout on both): 300 wide as a popover, 22 above, 16 at the sides and below (22 below when no action
|
|
595
|
+
shows), the title 17/22 semibold over the description 15/20 4 below it, 22 to the actions, the actions
|
|
596
|
+
side by side 12 apart. Close is a 30 circle 19 from the top and the trailing edge, its glyph about 11pt
|
|
597
|
+
drawn (a 20px X draws 11). A symbol is 34pt in a 44 by 54 frame 6 in from the padding and 12 from the
|
|
598
|
+
text, in the description's color (a 40px icon draws about 34). The arrow of a popover and an annotation is the kit's 47 by 13 curve.
|
|
599
|
+
macOS rounds the tip 20 (iOS: 26, see the phone rules in Tip.module.css). An inline tip on macOS is
|
|
600
|
+
black at 5% (alpha-05); a popover tip takes the PlexUI popover surface, and the kit's iOS popover shadow
|
|
601
|
+
(0 10 30, black at 20%) drawn around the arrow too. */
|
|
602
|
+
--tip-popover-width: 300px;
|
|
603
|
+
--tip-radius: 20px;
|
|
604
|
+
--tip-padding-top: 22px;
|
|
605
|
+
--tip-padding-inline: 16px;
|
|
606
|
+
--tip-padding-bottom: 16px;
|
|
607
|
+
--tip-gap: 22px;
|
|
608
|
+
--tip-title-font-size: 17px;
|
|
609
|
+
--tip-title-line-height: 22px;
|
|
610
|
+
--tip-description-font-size: 15px;
|
|
611
|
+
--tip-description-line-height: 20px;
|
|
612
|
+
--tip-description-gap: 4px;
|
|
613
|
+
--tip-description-color: var(--color-text-secondary);
|
|
614
|
+
--tip-action-gap: 12px;
|
|
615
|
+
--tip-icon-size: 40px;
|
|
616
|
+
--tip-icon-frame-width: 44px;
|
|
617
|
+
--tip-icon-frame-height: 54px;
|
|
618
|
+
--tip-close-size: 30px;
|
|
619
|
+
--tip-close-offset: 19px;
|
|
620
|
+
--tip-close-icon-size: 20px;
|
|
621
|
+
--tip-arrow-width: 47px;
|
|
622
|
+
--tip-arrow-height: 13px;
|
|
623
|
+
--tip-background: var(--alpha-05);
|
|
624
|
+
--tip-popover-background: var(--color-surface-elevated);
|
|
625
|
+
--tip-popover-shadow: 0 10px 30px rgb(0 0 0 / 20%);
|
|
626
|
+
|
|
491
627
|
/* =============================================
|
|
492
628
|
RadioGroup
|
|
493
629
|
============================================= */
|
|
@@ -510,8 +646,182 @@
|
|
|
510
646
|
--segmented-control-gutter: 2px;
|
|
511
647
|
--segmented-control-font-weight: var(--font-weight-semibold);
|
|
512
648
|
--segmented-control-thumb-shadow: 0 1px 4px -1px rgb(0 0 0 / 20%);
|
|
649
|
+
/* Phone (touch.css): the thumb on the glass track, as native frames show it: about 8% black in light (228 on a
|
|
650
|
+
247 track, Calendar IMG_5433/5434) and darker than the track in dark (32-34 on 54-58, IMG_5522/5523). */
|
|
513
651
|
--segmented-control-option-highlight-gutter: 1px;
|
|
514
652
|
|
|
653
|
+
/* =============================================
|
|
654
|
+
Color picker
|
|
655
|
+
============================================= */
|
|
656
|
+
/* A desktop scale of the iOS 26 kit Color Picker (0:5275) in PlexUI sizes: a 264px column, 22px grid cells,
|
|
657
|
+
28px tracks and fields. The phone takes the kit's own sizes (touch.css). */
|
|
658
|
+
--color-picker-width: 264px;
|
|
659
|
+
--color-picker-modes-gap: 16px;
|
|
660
|
+
--color-picker-body-aspect-ratio: 358 / 300;
|
|
661
|
+
--color-picker-body-radius: var(--radius-xl);
|
|
662
|
+
--color-picker-section-gap: 16px;
|
|
663
|
+
--color-picker-row-gap: 4px;
|
|
664
|
+
--color-picker-opacity-padding-bottom: 16px;
|
|
665
|
+
--color-picker-label-font-size: var(--font-text-sm-size);
|
|
666
|
+
--color-picker-label-line-height: var(--font-text-sm-line-height);
|
|
667
|
+
--color-picker-selection-color: #fff;
|
|
668
|
+
--color-picker-selection-width: 2px;
|
|
669
|
+
--color-picker-track-height: 28px;
|
|
670
|
+
--color-picker-track-inset: 2px;
|
|
671
|
+
--color-picker-checker-size: 6px;
|
|
672
|
+
--color-picker-knob-size: 24px;
|
|
673
|
+
--color-picker-knob-border: 2px;
|
|
674
|
+
--color-picker-knob-shadow: 0 0 3px rgb(0 0 0 / 10%);
|
|
675
|
+
--color-picker-loupe-size: 22px;
|
|
676
|
+
--color-picker-field-gap: 8px;
|
|
677
|
+
--color-picker-field-width: 56px;
|
|
678
|
+
--color-picker-field-wide-width: 88px;
|
|
679
|
+
--color-picker-field-height: 28px;
|
|
680
|
+
--color-picker-field-radius: var(--radius-md);
|
|
681
|
+
--color-picker-field-font-size: var(--font-text-sm-size);
|
|
682
|
+
--color-picker-field-line-height: var(--font-text-sm-line-height);
|
|
683
|
+
--color-picker-field-background: var(--color-background-secondary-soft-alpha);
|
|
684
|
+
--color-picker-separator-color: var(--color-border);
|
|
685
|
+
--color-picker-current-size: 56px;
|
|
686
|
+
--color-picker-current-radius: var(--radius-xl);
|
|
687
|
+
--color-picker-current-gap: 24px;
|
|
688
|
+
--color-picker-swatch-size: 24px;
|
|
689
|
+
--color-picker-swatch-row-gap: 16px;
|
|
690
|
+
--color-picker-swatch-ring-inset: 2px;
|
|
691
|
+
--color-picker-swatch-ring-width: 2px;
|
|
692
|
+
--color-picker-add-icon-size: 16px;
|
|
693
|
+
--color-picker-page-control-row-height: 8px;
|
|
694
|
+
--color-picker-page-control-empty-display: none;
|
|
695
|
+
--color-picker-popover-padding: 12px 16px 16px;
|
|
696
|
+
--color-picker-popover-header-gap: 12px;
|
|
697
|
+
--color-picker-sheet-radius: 34px 34px 58px 58px;
|
|
698
|
+
/* Phone (touch.css): the kit's Percentage field and Add button (120/120/120 at 20%: 228 on white) are alpha-12,
|
|
699
|
+
and its separator (198 on white) alpha-25. */
|
|
700
|
+
--color-picker-mobile-field-background: var(--alpha-12);
|
|
701
|
+
/* The picker's Mode control is the plain kit segmented control: Fills/Tertiary (118/118/128 at 12% and 24%: 240
|
|
702
|
+
on white, 28 on black) is alpha-06 and alpha-12; the Selected Fill thumb (white, white at 27%) gray-0 and alpha-25. */
|
|
703
|
+
--color-picker-mobile-separator-color: var(--alpha-25);
|
|
704
|
+
|
|
705
|
+
/* =============================================
|
|
706
|
+
Color well
|
|
707
|
+
============================================= */
|
|
708
|
+
/* The kit's Picker Button (5739:34128): an angular rainbow from yellow at the top, a 3px ring 2px from the color;
|
|
709
|
+
28px and 36px. */
|
|
710
|
+
--color-well-size-sm: 28px;
|
|
711
|
+
--color-well-size-lg: 36px;
|
|
712
|
+
--color-well-ring-width: 3px;
|
|
713
|
+
--color-well-ring-gap: 2px;
|
|
714
|
+
--color-well-rainbow: conic-gradient(
|
|
715
|
+
rgb(231 224 64) 0%,
|
|
716
|
+
rgb(238 170 60) 12.4%,
|
|
717
|
+
rgb(232 64 59) 24.9%,
|
|
718
|
+
rgb(179 62 213) 36.6%,
|
|
719
|
+
rgb(105 74 232) 50.6%,
|
|
720
|
+
rgb(60 202 231) 64.3%,
|
|
721
|
+
rgb(60 232 133) 74.9%,
|
|
722
|
+
rgb(137 231 67) 87%,
|
|
723
|
+
rgb(231 224 64) 100%
|
|
724
|
+
);
|
|
725
|
+
|
|
726
|
+
/* =============================================
|
|
727
|
+
Context menu
|
|
728
|
+
============================================= */
|
|
729
|
+
/* The iOS 26 kit Context Menu - Dimming Overlay (507:25994): black at 23% over a 30px background blur; the
|
|
730
|
+
kit shows light only, so dark takes the Dialog's dark scrim. The preview keeps the element's own corner, or
|
|
731
|
+
the kit's Content Area radius 30, and its drop shadow 32 at 20%. */
|
|
732
|
+
--context-menu-dimming-backdrop-filter: blur(30px);
|
|
733
|
+
--context-menu-preview-radius: 30px;
|
|
734
|
+
--context-menu-preview-shadow: 0 0 32px rgb(0 0 0 / 20%);
|
|
735
|
+
|
|
736
|
+
/* =============================================
|
|
737
|
+
Index bar (phone)
|
|
738
|
+
============================================= */
|
|
739
|
+
/* The section index of a phone list, after native iOS Contacts (IMG_5737; 09.11) and the iOS 27 kit (Lists,
|
|
740
|
+
Index Bar 48:56457), which agree: letters of about 11pt (a cap height of 7.7-8pt) 14pt apart (13.8 native),
|
|
741
|
+
in a 16pt column at the trailing edge, centred 8pt from it (7.7 native), in the medium weight of the kit.
|
|
742
|
+
The country list of a sheet (IMG_5491: 15pt apart, 10pt from the edge) is the exception. The kit tints them
|
|
743
|
+
systemBlue; PlexUI draws that tint as info, as it does the prominent toolbar button. The target reaches 30px
|
|
744
|
+
in from the edge (agent: the kit and native frames show no target). A list keeps its margins beside the
|
|
745
|
+
index, whose letters sit in the trailing one (Contacts rows end 16pt from the edge). */
|
|
746
|
+
--index-bar-width: 16px;
|
|
747
|
+
--index-bar-inset-inline-end: 0px;
|
|
748
|
+
--index-bar-font-size: 11px;
|
|
749
|
+
--index-bar-line-height: 14px;
|
|
750
|
+
--index-bar-font-weight: var(--font-weight-medium);
|
|
751
|
+
--index-bar-color: var(--color-text-info);
|
|
752
|
+
--index-bar-target-width: 30px;
|
|
753
|
+
|
|
754
|
+
/* =============================================
|
|
755
|
+
Page control
|
|
756
|
+
============================================= */
|
|
757
|
+
/* The iOS 26 kit Page control (507:24679) on every screen: dots of 8px, 8px apart, in a 24px capsule with
|
|
758
|
+
12px ends; past the window of full dots 6px and 4px. The current dot is the primary label and the others
|
|
759
|
+
labels/primary at 30% (alpha-30). The capsule fill has no kit or native measurement: alpha-08 (agent). */
|
|
760
|
+
--page-control-height: 24px;
|
|
761
|
+
--page-control-padding-inline: 12px;
|
|
762
|
+
--page-control-gap: 8px;
|
|
763
|
+
--page-control-dot-size: 8px;
|
|
764
|
+
--page-control-dot-size-small: 6px;
|
|
765
|
+
--page-control-dot-size-smaller: 4px;
|
|
766
|
+
--page-control-dot-color: var(--alpha-30);
|
|
767
|
+
--page-control-dot-color-current: var(--color-text);
|
|
768
|
+
--page-control-background: var(--alpha-08);
|
|
769
|
+
|
|
770
|
+
/* =============================================
|
|
771
|
+
Stepper
|
|
772
|
+
============================================= */
|
|
773
|
+
--stepper-height: var(--control-size-md);
|
|
774
|
+
--stepper-segment-width: 40px;
|
|
775
|
+
--stepper-radius: var(--control-radius-md);
|
|
776
|
+
--stepper-segment-background-hover: var(--alpha-05);
|
|
777
|
+
--stepper-segment-background-active: var(--alpha-10);
|
|
778
|
+
--stepper-separator-color: var(--color-border);
|
|
779
|
+
--stepper-separator-inset: 4px;
|
|
780
|
+
--stepper-icon-size: var(--control-icon-size-md);
|
|
781
|
+
--stepper-icon-color: var(--color-text);
|
|
782
|
+
--stepper-icon-disabled-color: var(--color-text-disabled);
|
|
783
|
+
/* Phone (touch.css), the iOS 27 kit Stepper (Steppers: _Decrement, _Increment) in PlexUI alpha colors: each
|
|
784
|
+
segment has its own fill, Fills/Tertiary (118/118/128 at 12% and 24%: 239 on white, 28 on black), alpha-06
|
|
785
|
+
and alpha-12; a pressed segment and one at the end of the range turn to Fills/Quaternary (116/116/128 at 8%,
|
|
786
|
+
118/118/128 at 18%: 244 and 21), alpha-05 and alpha-08; the separator under them (60/60/67 and 235/235/245
|
|
787
|
+
at 30%) is alpha-25. */
|
|
788
|
+
--stepper-mobile-separator-color: var(--alpha-25);
|
|
789
|
+
|
|
790
|
+
/* =============================================
|
|
791
|
+
Tab bar (phone)
|
|
792
|
+
============================================= */
|
|
793
|
+
/* The iOS 26 kit Tab Bar - iPhone (507:24689), 402 x 95: a 62px glass capsule 21px from the sides and the
|
|
794
|
+
bottom; tabs of a symbol (18pt in a 28pt line) over a 10/12 semibold label, 6px above and 7px below,
|
|
795
|
+
94px apart at most, the selected one on a 54px pill 6px wider than the tab; a separate 62px search
|
|
796
|
+
circle 8px away; minimized, two 48px circles. The selection pill (237 burnt into the light glass, 18
|
|
797
|
+
dodged into the dark one: about 8% either way) is alpha-08. The kit tints the selected tab systemBlue;
|
|
798
|
+
PlexUI colors navigation as its Sidebar does: the selected tab in the primary text, the others
|
|
799
|
+
--gray-750 (dark --gray-850). Minimized, the symbol is the primary label, as in the kit. */
|
|
800
|
+
--tab-bar-gutter: 21px;
|
|
801
|
+
--tab-bar-gap: 8px;
|
|
802
|
+
--tab-bar-padding-top: 12px;
|
|
803
|
+
--tab-bar-padding-bottom: max(21px, calc(var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)) - 13px));
|
|
804
|
+
/* Minimized, the circles keep 28px from the sides and the bottom (kit iOS 27, Tab Bar - iPhone 3:70967,
|
|
805
|
+
Minimized=True; 21 in the iOS 26 kit), and the bar keeps its 95px so the Page under it does not move. */
|
|
806
|
+
--tab-bar-minimized-padding-top: 19px;
|
|
807
|
+
--tab-bar-minimized-gutter: 28px;
|
|
808
|
+
--tab-bar-minimized-padding-bottom: max(28px, calc(var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)) - 6px));
|
|
809
|
+
--tab-bar-capsule-padding-block: 4px;
|
|
810
|
+
--tab-bar-capsule-padding-inline: 10px;
|
|
811
|
+
--tab-bar-item-width: 94px;
|
|
812
|
+
--tab-bar-item-height: 54px;
|
|
813
|
+
--tab-bar-pill-outset: 6px;
|
|
814
|
+
--tab-bar-icon-box: 28px;
|
|
815
|
+
--tab-bar-icon-size: 24px;
|
|
816
|
+
--tab-bar-label-font-size: 10px;
|
|
817
|
+
--tab-bar-label-line-height: 12px;
|
|
818
|
+
--tab-bar-label-font-weight: var(--font-weight-semibold);
|
|
819
|
+
--tab-bar-search-size: 62px;
|
|
820
|
+
--tab-bar-minimized-size: 48px;
|
|
821
|
+
--tab-bar-item-color-selected: var(--color-text);
|
|
822
|
+
--tab-bar-item-color-minimized: var(--color-text);
|
|
823
|
+
--tab-bar-item-background-selected: var(--alpha-08);
|
|
824
|
+
|
|
515
825
|
/* =============================================
|
|
516
826
|
Tabs — Underline variant
|
|
517
827
|
============================================= */
|
|
@@ -646,10 +956,9 @@
|
|
|
646
956
|
/* Mobile menu button (hamburger icon) */
|
|
647
957
|
--sidebar-mobile-button-size: 32px;
|
|
648
958
|
--sidebar-mobile-button-radius: 8px;
|
|
649
|
-
--sidebar-mobile-icon-size:
|
|
650
|
-
--sidebar-mobile-
|
|
651
|
-
--sidebar-mobile-
|
|
652
|
-
--sidebar-mobile-line-transition-duration: 0.2s;
|
|
959
|
+
--sidebar-mobile-icon-size: 24px;
|
|
960
|
+
--sidebar-mobile-icon-color: var(--gray-900);
|
|
961
|
+
--sidebar-mobile-icon-transition-duration: 0.2s;
|
|
653
962
|
|
|
654
963
|
/* Mobile drawer */
|
|
655
964
|
--sidebar-mobile-gutter: 12px;
|
|
@@ -757,14 +1066,29 @@
|
|
|
757
1066
|
--codeblock-syntax-3: var(--green-600);
|
|
758
1067
|
--codeblock-syntax-5: var(--purple-500);
|
|
759
1068
|
--dialog-backdrop-dim-background: rgb(0 0 0 / 30%);
|
|
1069
|
+
--dialog-mobile-scrim: rgb(0 0 0 / 20%);
|
|
760
1070
|
--menu-item-background-color: var(--alpha-08);
|
|
761
1071
|
--modal-backdrop-background: rgb(0 0 0 / 30%);
|
|
762
|
-
--
|
|
763
|
-
--
|
|
1072
|
+
--toolbar-search-placeholder-color: var(--alpha-40);
|
|
1073
|
+
--toolbar-prominent-disabled-background: var(--alpha-12);
|
|
1074
|
+
--toolbar-prominent-disabled-color: var(--gray-0);
|
|
1075
|
+
--toolbar-prominent-shadow: 0 8px 15px rgb(0 0 0 / 2%), 1.25px 0 0 -0.75px rgb(0 0 0 / 12%), -1.25px 0 0 -0.75px rgb(0 0 0 / 12%), inset 0 0.67px 0 rgb(255 255 255 / 35%), inset 0 -0.67px 0 rgb(255 255 255 / 35%);
|
|
1076
|
+
--page-bar-veil-opacity: 55%;
|
|
1077
|
+
--page-bar-veil: rgb(255 255 255 / 55%);
|
|
764
1078
|
--page-bar-line: rgb(0 0 0 / 10%);
|
|
1079
|
+
--page-bar-hard-line: rgb(0 0 0 / 12%);
|
|
765
1080
|
--segmented-control-background: var(--gray-100);
|
|
766
1081
|
--segmented-control-thumb-background: var(--gray-0);
|
|
1082
|
+
--segmented-control-mobile-thumb-background: var(--alpha-08);
|
|
767
1083
|
--segmented-control-option-highlight-background-color: var(--gray-200);
|
|
1084
|
+
--color-picker-mobile-mode-background: var(--alpha-06);
|
|
1085
|
+
--color-picker-mobile-mode-thumb-background: var(--gray-0);
|
|
1086
|
+
--context-menu-dimming-background: rgb(0 0 0 / 23%);
|
|
1087
|
+
--stepper-background: var(--gray-100);
|
|
1088
|
+
--stepper-mobile-segment-background: var(--alpha-06);
|
|
1089
|
+
--stepper-mobile-segment-background-active: var(--alpha-05);
|
|
1090
|
+
--stepper-mobile-segment-background-disabled: var(--alpha-05);
|
|
1091
|
+
--tab-bar-item-color: var(--gray-750);
|
|
768
1092
|
--slider-track-color: var(--gray-150);
|
|
769
1093
|
--slider-range-color: var(--gray-450);
|
|
770
1094
|
--switch-track-color: var(--gray-150);
|
|
@@ -798,14 +1122,29 @@
|
|
|
798
1122
|
--codeblock-syntax-3: var(--green-300);
|
|
799
1123
|
--codeblock-syntax-5: var(--purple-300);
|
|
800
1124
|
--dialog-backdrop-dim-background: rgb(0 0 0 / 50%);
|
|
1125
|
+
--dialog-mobile-scrim: rgb(0 0 0 / 50%);
|
|
801
1126
|
--menu-item-background-color: var(--alpha-10);
|
|
802
1127
|
--modal-backdrop-background: rgb(0 0 0 / 50%);
|
|
803
|
-
--
|
|
804
|
-
--
|
|
1128
|
+
--toolbar-search-placeholder-color: var(--alpha-60);
|
|
1129
|
+
--toolbar-prominent-disabled-background: var(--alpha-20);
|
|
1130
|
+
--toolbar-prominent-disabled-color: var(--alpha-30);
|
|
1131
|
+
--toolbar-prominent-shadow: 0 8px 15px transparent, 1.25px 0 0 -0.75px rgb(0 0 0 / 12%), -1.25px 0 0 -0.75px rgb(0 0 0 / 12%), inset 0 0.67px 0 rgb(255 255 255 / 35%), inset 0 -0.67px 0 rgb(255 255 255 / 35%);
|
|
1132
|
+
--page-bar-veil-opacity: 50%;
|
|
1133
|
+
--page-bar-veil: rgb(0 0 0 / 50%);
|
|
805
1134
|
--page-bar-line: var(--color-border);
|
|
1135
|
+
--page-bar-hard-line: var(--color-border);
|
|
806
1136
|
--segmented-control-background: var(--alpha-08);
|
|
807
1137
|
--segmented-control-thumb-background: var(--alpha-12);
|
|
1138
|
+
--segmented-control-mobile-thumb-background: var(--gray-200);
|
|
808
1139
|
--segmented-control-option-highlight-background-color: var(--alpha-08);
|
|
1140
|
+
--color-picker-mobile-mode-background: var(--alpha-12);
|
|
1141
|
+
--color-picker-mobile-mode-thumb-background: var(--alpha-25);
|
|
1142
|
+
--context-menu-dimming-background: rgb(0 0 0 / 50%);
|
|
1143
|
+
--stepper-background: var(--alpha-08);
|
|
1144
|
+
--stepper-mobile-segment-background: var(--alpha-12);
|
|
1145
|
+
--stepper-mobile-segment-background-active: var(--alpha-08);
|
|
1146
|
+
--stepper-mobile-segment-background-disabled: var(--alpha-08);
|
|
1147
|
+
--tab-bar-item-color: var(--gray-850);
|
|
809
1148
|
--slider-track-color: var(--gray-400);
|
|
810
1149
|
--slider-range-color: var(--gray-600);
|
|
811
1150
|
--switch-track-color: var(--gray-400);
|
package/package.json
CHANGED
|
@@ -2,6 +2,24 @@ import postcss from "postcss"
|
|
|
2
2
|
import selectorParser from "postcss-selector-parser"
|
|
3
3
|
import valueParser from "postcss-value-parser"
|
|
4
4
|
|
|
5
|
+
// A selector that starts on the root element itself (`html:root`, or `:root` before the phone layout scope)
|
|
6
|
+
const ROOT_COMPOUND = /^(?::root|html)(?:\[[^\]]*\]|:[\w-]+(?:\([^)]*\))?|\.[\w-]+)*(?=$|[\s>+~])/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The selectors for one theme of a rule that is not a bare theme scope. The theme attribute sits on an ancestor, or,
|
|
10
|
+
* for a selector that starts on the root element, on the root itself (no element is above it) or inside it; the root
|
|
11
|
+
* keeps its specificity so the dark rule, emitted after the light one, wins.
|
|
12
|
+
* @param {string} selector
|
|
13
|
+
* @param {"light" | "dark"} theme
|
|
14
|
+
*/
|
|
15
|
+
export const themedSelectors = (selector, theme) => {
|
|
16
|
+
const scope = `:where([data-theme="${theme}"])`
|
|
17
|
+
const root = ROOT_COMPOUND.exec(selector)
|
|
18
|
+
if (!root) return [`${scope} ${selector}`]
|
|
19
|
+
const rest = selector.slice(root[0].length).trim()
|
|
20
|
+
return rest ? [`${root[0]}${scope} ${rest}`, `${root[0]} ${scope} ${rest}`] : [`${root[0]}${scope}`]
|
|
21
|
+
}
|
|
22
|
+
|
|
5
23
|
/** @type {import('postcss').PluginCreator} */
|
|
6
24
|
export default function platformUILightDark() {
|
|
7
25
|
return {
|
|
@@ -152,8 +170,8 @@ export default function platformUILightDark() {
|
|
|
152
170
|
}
|
|
153
171
|
|
|
154
172
|
// Themed nested only for non-simple selectors
|
|
155
|
-
lightParts.push(...otherSelectors.
|
|
156
|
-
darkParts.push(...otherSelectors.
|
|
173
|
+
lightParts.push(...otherSelectors.flatMap((s) => themedSelectors(s, "light")))
|
|
174
|
+
darkParts.push(...otherSelectors.flatMap((s) => themedSelectors(s, "dark")))
|
|
157
175
|
|
|
158
176
|
// Dedupe while preserving order
|
|
159
177
|
const uniq = (arr) => Array.from(new Set(arr))
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A phone layout without a narrow window (plan 176). The rules of the phone media queries (767px and below) also
|
|
5
|
+
* apply inside an element marked `data-plex-layout="phone"` (PhoneLayout, or a dialog laid out as on a phone), and
|
|
6
|
+
* the rules of the desktop queries (768px and up) do not apply there.
|
|
7
|
+
*
|
|
8
|
+
* Runs after postcss-nested, on flat rules. A copy keeps the specificity of its rule (the scope sits in `:where()`),
|
|
9
|
+
* and follows its media rule, so the cascade inside the scope is the one a narrow window has.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export const PHONE_SCOPE = '[data-plex-layout="phone"]'
|
|
13
|
+
|
|
14
|
+
const PHONE_FEATURE = /^\(\s*(?:max-width\s*:\s*767(?:\.98)?px|width\s*<=?\s*767(?:\.98)?px)\s*\)$/i
|
|
15
|
+
const DESKTOP_FEATURE = /^\(\s*(?:min-width\s*:\s*768px|width\s*>=\s*768px)\s*\)$/i
|
|
16
|
+
const MEDIA_TYPE = /^(?:only\s+)?(?:screen|all)$/i
|
|
17
|
+
const ROOT_COMPOUND = /^(?::root|html|body)(?=$|[\s>+~.[:#])((?:\[[^\]]*\]|:[\w-]+(?:\([^)]*\))?|\.[\w-]+)*)/
|
|
18
|
+
|
|
19
|
+
/** Splits on commas outside parentheses and brackets. */
|
|
20
|
+
const splitList = (value) => {
|
|
21
|
+
const parts = []
|
|
22
|
+
let depth = 0
|
|
23
|
+
let start = 0
|
|
24
|
+
for (let index = 0; index < value.length; index++) {
|
|
25
|
+
const char = value[index]
|
|
26
|
+
if (char === "(" || char === "[") depth++
|
|
27
|
+
else if (char === ")" || char === "]") depth--
|
|
28
|
+
else if (char === "," && depth === 0) {
|
|
29
|
+
parts.push(value.slice(start, index).trim())
|
|
30
|
+
start = index + 1
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
parts.push(value.slice(start).trim())
|
|
34
|
+
return parts.filter(Boolean)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* What the copy of a media rule keeps of its queries once the phone condition is taken out: `true` for none (the
|
|
39
|
+
* copy applies whenever the scope does), the remaining conditions, or `null` when no query is a phone one.
|
|
40
|
+
* @param {string} params
|
|
41
|
+
* @returns {true | string | null}
|
|
42
|
+
*/
|
|
43
|
+
export const phoneCondition = (params) => {
|
|
44
|
+
const kept = []
|
|
45
|
+
for (const query of splitList(params)) {
|
|
46
|
+
const features = query.split(/\s+and\s+/i).map((part) => part.trim())
|
|
47
|
+
if (!features.some((feature) => PHONE_FEATURE.test(feature))) continue
|
|
48
|
+
const rest = features.filter((feature) => !PHONE_FEATURE.test(feature) && !MEDIA_TYPE.test(feature))
|
|
49
|
+
if (rest.some((feature) => /width/i.test(feature))) continue // another width range: not known inside a frame
|
|
50
|
+
if (!rest.length) return true
|
|
51
|
+
kept.push(rest.join(" and "))
|
|
52
|
+
}
|
|
53
|
+
return kept.length ? kept.join(", ") : null
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** @param {string} params */
|
|
57
|
+
export const isDesktopMedia = (params) =>
|
|
58
|
+
splitList(params).every((query) => query.split(/\s+and\s+/i).some((feature) => DESKTOP_FEATURE.test(feature.trim())))
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The selector for elements inside the scope: after a leading `:root`, `html` or `body` (and what it carries), so
|
|
62
|
+
* tokens set on the root are set on the scope instead, or before the selector.
|
|
63
|
+
* @param {string} selector
|
|
64
|
+
*/
|
|
65
|
+
export const scopeSelector = (selector) => {
|
|
66
|
+
const root = ROOT_COMPOUND.exec(selector)
|
|
67
|
+
if (root) {
|
|
68
|
+
const rest = selector.slice(root[0].length).trim()
|
|
69
|
+
return `${root[0]} :where(${PHONE_SCOPE})${rest ? ` ${rest}` : ""}`
|
|
70
|
+
}
|
|
71
|
+
return `:where(${PHONE_SCOPE}) ${selector}`
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* The selector for elements outside the scope: its subject (before any pseudo-element) is not the scope or in it.
|
|
76
|
+
* @param {string} selector
|
|
77
|
+
*/
|
|
78
|
+
export const unscopeSelector = (selector) => {
|
|
79
|
+
const exclusion = `:not(:where(${PHONE_SCOPE}, ${PHONE_SCOPE} *))`
|
|
80
|
+
const pseudo = selector.search(/::[\w-]+(?:\([^)]*\))?$/)
|
|
81
|
+
return pseudo === -1 ? `${selector}${exclusion}` : `${selector.slice(0, pseudo)}${exclusion}${selector.slice(pseudo)}`
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const inKeyframes = (rule) => {
|
|
85
|
+
for (let node = rule.parent; node; node = node.parent) {
|
|
86
|
+
if (node.type === "atrule" && /keyframes$/i.test(node.name)) return true
|
|
87
|
+
}
|
|
88
|
+
return false
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** @type {import('postcss').PluginCreator<void>} */
|
|
92
|
+
export default function phoneLayoutScope() {
|
|
93
|
+
return {
|
|
94
|
+
postcssPlugin: "plexui/components/postcss-phone-layout-scope",
|
|
95
|
+
OnceExit(root, { AtRule }) {
|
|
96
|
+
/** @type {import('postcss').AtRule[]} */
|
|
97
|
+
const media = []
|
|
98
|
+
root.walkAtRules("media", (rule) => {
|
|
99
|
+
media.push(rule)
|
|
100
|
+
})
|
|
101
|
+
for (const rule of media) {
|
|
102
|
+
// A phone rule inside another phone rule is copied with its outer one
|
|
103
|
+
let outer = rule.parent
|
|
104
|
+
let nested = false
|
|
105
|
+
for (; outer; outer = outer.parent) {
|
|
106
|
+
if (outer.type === "atrule" && outer.name === "media" && phoneCondition(outer.params) !== null) nested = true
|
|
107
|
+
}
|
|
108
|
+
const condition = phoneCondition(rule.params)
|
|
109
|
+
if (condition !== null && !nested) {
|
|
110
|
+
const copy = rule.clone()
|
|
111
|
+
copy.walkRules((inner) => {
|
|
112
|
+
if (inKeyframes(inner)) return
|
|
113
|
+
inner.selectors = inner.selectors.map(scopeSelector)
|
|
114
|
+
})
|
|
115
|
+
// A media rule nested in the phone one is copied whole; its own phone condition, if any, is the scope's
|
|
116
|
+
copy.walkAtRules("media", (inner) => {
|
|
117
|
+
const innerCondition = phoneCondition(inner.params)
|
|
118
|
+
if (innerCondition === true) inner.replaceWith(inner.nodes ?? [])
|
|
119
|
+
else if (innerCondition !== null) inner.params = innerCondition
|
|
120
|
+
})
|
|
121
|
+
if (condition === true) rule.after(copy.nodes ?? [])
|
|
122
|
+
else rule.after(new AtRule({ name: "media", params: condition, nodes: copy.nodes ?? [] }))
|
|
123
|
+
} else if (isDesktopMedia(rule.params)) {
|
|
124
|
+
rule.walkRules((inner) => {
|
|
125
|
+
if (inKeyframes(inner)) return
|
|
126
|
+
inner.selectors = inner.selectors.map(unscopeSelector)
|
|
127
|
+
})
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
phoneLayoutScope.postcss = true
|