@phis/ui 0.4.4 → 0.4.6
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/README.md +9 -3
- package/cms/plugins.d.ts +1 -0
- package/cms/plugins.js +2 -0
- package/components/cms/phi-cms-root-layout.js +31 -2
- package/components/controls/phi-background-control.d.ts +6 -1
- package/components/controls/phi-background-control.js +12 -4
- package/components/controls/phi-button-control.d.ts +15 -1
- package/components/controls/phi-button-control.js +21 -3
- package/components/controls/phi-collapse-control.d.ts +6 -2
- package/components/controls/phi-collapse-control.js +2 -2
- package/components/controls/phi-dialog-control.d.ts +11 -5
- package/components/controls/phi-dialog-control.js +19 -13
- package/components/controls/phi-dropdown-control.js +2 -2
- package/components/controls/phi-media-asset-tile-control.js +10 -10
- package/components/controls/phi-menu-control-vocabulary.d.ts +7 -0
- package/components/controls/phi-menu-control-vocabulary.js +10 -0
- package/components/controls/phi-menu-control.d.ts +4 -1
- package/components/controls/phi-menu-control.js +6 -1
- package/components/controls/phi-progress-control.d.ts +10 -2
- package/components/controls/phi-progress-control.js +6 -2
- package/components/controls/phi-ribbon-control.d.ts +4 -1
- package/components/controls/phi-ribbon-control.js +5 -3
- package/components/controls/phi-ribbon-wrap-control.d.ts +7 -1
- package/components/controls/phi-ribbon-wrap-control.js +8 -2
- package/components/controls/phi-segmented-control.d.ts +4 -1
- package/components/controls/phi-segmented-control.js +13 -2
- package/components/controls/phi-surface-control.d.ts +2 -0
- package/components/controls/phi-surface-control.js +16 -1
- package/components/controls/phi-switch-control.d.ts +4 -1
- package/components/controls/phi-switch-control.js +8 -2
- package/components/controls/phi-tag-control.d.ts +4 -1
- package/components/controls/phi-tag-control.js +11 -3
- package/components/layouts/clients/phi-split-card-layout-client.js +13 -5
- package/components/layouts/clients/phi-three-column-layout-client.js +9 -3
- package/components/layouts/phi-layout-view-model.js +10 -1
- package/components/layouts/split-card-geometry.js +6 -2
- package/components/media/aspect-ratios.d.ts +2 -2
- package/components/menus/phi-account-menu.js +3 -1
- package/components/navigation/phi-link.js +7 -2
- package/components/navigation/use-phi-protected-mail.d.ts +11 -0
- package/components/navigation/use-phi-protected-mail.js +29 -0
- package/components/regions/clients/cms-region-container-client.js +16 -2
- package/components/regions/phi-cms-region-container.js +5 -1
- package/components/regions/phi-cms-region-shell.d.ts +11 -0
- package/components/regions/phi-cms-region-shell.js +64 -7
- package/components/regions/presets/phi-area-shell-preset-nodes.js +2 -1
- package/components/root/phi-config-provider.js +16 -0
- package/components/root/phi-root-layout.d.ts +1 -0
- package/components/root/phi-root-layout.js +1 -0
- package/components/root/phi-root-theme-resolver.js +12 -1
- package/components/root/phi-shell-chrome-overlay.d.ts +6 -0
- package/components/root/phi-shell-chrome-overlay.js +7 -1
- package/components/runtime/runtime-module-context.d.ts +12 -1
- package/components/runtime/runtime-module-context.js +6 -1
- package/components/shell/phi-cms-shell.d.ts +9 -1
- package/components/shell/phi-cms-shell.js +10 -4
- package/components/shell/phi-nav-link.js +7 -2
- package/components/shell/phi-shell-sider-drawer.d.ts +17 -0
- package/components/shell/phi-shell-sider-drawer.js +88 -0
- package/components/shell/use-phi-shell-header-bands.d.ts +5 -0
- package/components/shell/use-phi-shell-header-bands.js +64 -0
- package/components/shell/use-phi-shell-sticky-bottom.d.ts +18 -0
- package/components/shell/use-phi-shell-sticky-bottom.js +54 -0
- package/components/tables/client/phi-table-binding.d.ts +1 -0
- package/components/tables/client/phi-table-binding.js +22 -3
- package/components/trees/client/phi-tree-binding.d.ts +1 -0
- package/components/trees/client/phi-tree-binding.js +11 -2
- package/components/widgets/client/shared/phi-collection-provider.js +4 -3
- package/components/widgets/client/shared/phi-collection-view-binding.d.ts +1 -0
- package/components/widgets/client/shared/phi-collection-view-binding.js +16 -2
- package/components/widgets/client/shared/phi-command-buttons.js +6 -2
- package/components/widgets/config/background.d.ts +20 -0
- package/components/widgets/config/background.js +44 -2
- package/components/widgets/config/button-variant.d.ts +22 -4
- package/components/widgets/config/button-variant.js +24 -5
- package/components/widgets/config/common-action-field.d.ts +1 -1
- package/components/widgets/config/parser-primitives.js +4 -2
- package/components/widgets/config/theme-gradient.d.ts +11 -0
- package/components/widgets/config/theme-gradient.js +12 -0
- package/components/widgets/helpers/internal-reference-resolver.server.d.ts +1 -0
- package/components/widgets/helpers/internal-reference-resolver.server.js +4 -1
- package/components/widgets/label-sets/background.js +2 -0
- package/components/widgets/label-sets/geometry.js +2 -0
- package/components/widgets/label-sets/inspector.js +6 -0
- package/components/widgets/label-types/background.d.ts +1 -0
- package/components/widgets/label-types/background.js +1 -0
- package/components/widgets/label-types/common-controls.js +2 -2
- package/components/widgets/label-types/geometry.d.ts +1 -0
- package/components/widgets/label-types/geometry.js +1 -0
- package/components/widgets/label-types/inspector.d.ts +6 -0
- package/components/widgets/label-types/inspector.js +3 -0
- package/components/widgets/server/navigation-request.js +13 -1
- package/components/widgets/shared/card-body-client.d.ts +13 -0
- package/components/widgets/shared/card-body-client.js +40 -11
- package/components/widgets/shared/card-vocabulary.d.ts +36 -0
- package/components/widgets/shared/card-vocabulary.js +52 -0
- package/components/widgets/shared/collection-source-failure.d.ts +26 -0
- package/components/widgets/shared/collection-source-failure.js +42 -0
- package/components/widgets/shared/markdown-body-client.d.ts +29 -0
- package/components/widgets/shared/markdown-body-client.js +60 -5
- package/components/widgets/shared/markdown-image-vocabulary.d.ts +31 -0
- package/components/widgets/shared/markdown-image-vocabulary.js +68 -0
- package/components/widgets/shared/markdown-render.d.ts +5 -0
- package/components/widgets/shared/markdown-render.js +139 -11
- package/components/widgets/shared/markdown-sections.d.ts +40 -0
- package/components/widgets/shared/markdown-sections.js +111 -0
- package/components/widgets/shared/widget-failure-client.d.ts +10 -0
- package/components/widgets/shared/widget-failure-client.js +20 -0
- package/components/widgets/shared/widget-failure.d.ts +31 -0
- package/components/widgets/shared/widget-failure.js +20 -0
- package/components/widgets/shared/widget-failure.server.d.ts +9 -0
- package/components/widgets/shared/widget-failure.server.js +12 -0
- package/gateway/dashboard-card-memo.d.ts +3 -0
- package/gateway/dashboard-card-memo.js +25 -0
- package/helpers/cms-region-keys.d.ts +1 -1
- package/helpers/external-href.js +1 -1
- package/helpers/layout-style.d.ts +8 -4
- package/helpers/layout-style.js +3 -2
- package/helpers/mode-paint.d.ts +4 -0
- package/helpers/mode-paint.js +47 -0
- package/helpers/protected-mail.d.ts +16 -0
- package/helpers/protected-mail.js +81 -0
- package/helpers/surface-style.js +33 -11
- package/module-dashboard-cards.d.ts +1 -0
- package/module-dashboard-cards.js +1 -0
- package/module-records.d.ts +7 -0
- package/module-records.js +6 -0
- package/package.json +2 -2
- package/plugins/runtime-modules/builder/clients/inspector-config-field.js +1 -1
- package/plugins/runtime-modules/builder/clients/inspector-surface-labels.js +1 -0
- package/plugins/runtime-modules/builder/clients/region-inspector.js +67 -3
- package/plugins/runtime-modules/builder/clients/runtime-module-authoring-boundary.js +1 -1
- package/plugins/runtime-modules/builder/controller/draft-command-controller.js +7 -4
- package/plugins/runtime-modules/builder/controller/page-controller.js +7 -0
- package/plugins/runtime-modules/builder/persistence.d.ts +3 -0
- package/plugins/runtime-modules/builder/persistence.js +9 -1
- package/plugins/runtime-modules/core/content-entries/record-source.server.d.ts +3 -1
- package/plugins/runtime-modules/core/content-entries/record-source.server.js +7 -4
- package/plugins/runtime-modules/core/widgets/button/client.js +2 -2
- package/plugins/runtime-modules/core/widgets/button/config.d.ts +40 -4
- package/plugins/runtime-modules/core/widgets/button/config.js +12 -0
- package/plugins/runtime-modules/core/widgets/card/config.d.ts +102 -1
- package/plugins/runtime-modules/core/widgets/card/config.js +60 -1
- package/plugins/runtime-modules/core/widgets/card/editor.js +17 -2
- package/plugins/runtime-modules/core/widgets/card/server.js +13 -1
- package/plugins/runtime-modules/core/widgets/collection-view/asset-binding.d.ts +4 -1
- package/plugins/runtime-modules/core/widgets/collection-view/asset-binding.js +10 -3
- package/plugins/runtime-modules/core/widgets/collection-view/authoring.js +1 -1
- package/plugins/runtime-modules/core/widgets/collection-view/client.d.ts +3 -0
- package/plugins/runtime-modules/core/widgets/collection-view/client.js +47 -11
- package/plugins/runtime-modules/core/widgets/collection-view/image-preview-grid.d.ts +4 -1
- package/plugins/runtime-modules/core/widgets/collection-view/image-preview-grid.js +2 -2
- package/plugins/runtime-modules/core/widgets/collection-view/plugin.js +3 -2
- package/plugins/runtime-modules/core/widgets/collection-view/server.d.ts +6 -1
- package/plugins/runtime-modules/core/widgets/collection-view/server.js +21 -3
- package/plugins/runtime-modules/core/widgets/entry-detail/plugin.js +1 -1
- package/plugins/runtime-modules/core/widgets/entry-detail/server.d.ts +3 -1
- package/plugins/runtime-modules/core/widgets/entry-detail/server.js +5 -2
- package/plugins/runtime-modules/core/widgets/entry-header/plugin.js +1 -1
- package/plugins/runtime-modules/core/widgets/entry-header/server.d.ts +3 -1
- package/plugins/runtime-modules/core/widgets/entry-header/server.js +5 -2
- package/plugins/runtime-modules/core/widgets/entry-list/plugin.js +1 -1
- package/plugins/runtime-modules/core/widgets/entry-list/server.d.ts +6 -3
- package/plugins/runtime-modules/core/widgets/entry-list/server.js +13 -6
- package/plugins/runtime-modules/core/widgets/entry-list/view.server.js +2 -1
- package/plugins/runtime-modules/core/widgets/gallery/config.d.ts +3 -3
- package/plugins/runtime-modules/core/widgets/gallery/plugin.js +1 -1
- package/plugins/runtime-modules/core/widgets/gallery/server.d.ts +5 -3
- package/plugins/runtime-modules/core/widgets/gallery/server.js +8 -6
- package/plugins/runtime-modules/core/widgets/header-navigation/client.d.ts +6 -1
- package/plugins/runtime-modules/core/widgets/header-navigation/client.js +40 -13
- package/plugins/runtime-modules/core/widgets/header-navigation/config.d.ts +26 -1
- package/plugins/runtime-modules/core/widgets/header-navigation/config.js +27 -0
- package/plugins/runtime-modules/core/widgets/header-navigation/plugin.js +1 -1
- package/plugins/runtime-modules/core/widgets/header-navigation/server.d.ts +2 -2
- package/plugins/runtime-modules/core/widgets/header-navigation/server.js +3 -1
- package/plugins/runtime-modules/core/widgets/image/client.js +11 -7
- package/plugins/runtime-modules/core/widgets/markdown/config.d.ts +16 -0
- package/plugins/runtime-modules/core/widgets/markdown/config.js +46 -1
- package/plugins/runtime-modules/core/widgets/markdown/server.js +22 -8
- package/plugins/runtime-modules/core/widgets/record/client.d.ts +4 -1
- package/plugins/runtime-modules/core/widgets/record/client.js +8 -3
- package/plugins/runtime-modules/core/widgets/record/plugin.js +3 -2
- package/plugins/runtime-modules/core/widgets/record/server.d.ts +3 -1
- package/plugins/runtime-modules/core/widgets/record/server.js +2 -2
- package/plugins/runtime-modules/core/widgets/segmented/client.js +1 -1
- package/plugins/runtime-modules/core/widgets/segmented/config.d.ts +21 -1
- package/plugins/runtime-modules/core/widgets/segmented/config.js +11 -1
- package/plugins/runtime-modules/core/widgets/simple-text/server.js +11 -1
- package/plugins/runtime-modules/core/widgets/switch/client.js +1 -1
- package/plugins/runtime-modules/core/widgets/switch/config.d.ts +19 -0
- package/plugins/runtime-modules/core/widgets/switch/config.js +11 -0
- package/plugins/runtime-modules/core/widgets/table/authoring.js +1 -1
- package/plugins/runtime-modules/core/widgets/table/client.d.ts +4 -1
- package/plugins/runtime-modules/core/widgets/table/client.js +16 -3
- package/plugins/runtime-modules/core/widgets/table/plugin.js +3 -2
- package/plugins/runtime-modules/core/widgets/table/server.d.ts +3 -1
- package/plugins/runtime-modules/core/widgets/table/server.js +2 -2
- package/plugins/runtime-modules/core/widgets/table/static-resource-editor.js +2 -1
- package/plugins/runtime-modules/core/widgets/timeline/authoring.js +1 -1
- package/plugins/runtime-modules/core/widgets/timeline/client.d.ts +1 -3
- package/plugins/runtime-modules/core/widgets/timeline/client.js +14 -4
- package/plugins/runtime-modules/core/widgets/tree/authoring.js +1 -1
- package/plugins/runtime-modules/core/widgets/tree/client.d.ts +4 -1
- package/plugins/runtime-modules/core/widgets/tree/client.js +13 -2
- package/plugins/runtime-modules/core/widgets/tree/plugin.js +3 -2
- package/plugins/runtime-modules/core/widgets/tree/server.d.ts +3 -1
- package/plugins/runtime-modules/core/widgets/tree/server.js +2 -2
- package/plugins/runtime-modules/theme/presets.d.ts +9 -1
- package/plugins/runtime-modules/theme/tour.d.ts +9 -1
- package/plugins/runtime-modules/theme/tour.js +10 -1
- package/plugins/runtime-modules/theme/widgets/brand-controls/client.js +138 -7
- package/runtime-data-provider-client.d.ts +2 -0
- package/runtime-data-provider-client.js +7 -0
- package/styles/controls.css +118 -15
- package/styles/gradients.css +101 -0
- package/styles/layout.css +35 -0
- package/styles/root.css +18 -0
- package/styles/shell.css +206 -0
- package/theme/phi-button-shadow.d.ts +6 -0
- package/theme/phi-theme-gradients.d.ts +96 -0
- package/theme/phi-theme-gradients.js +245 -0
- package/theme/phi-theme-presets.d.ts +3 -0
- package/theme/phi-theme-presets.js +3 -0
- package/theme/phi-theme-tokens.d.ts +5 -1
- package/theme/phi-theme-tokens.js +14 -0
- package/theme/phi-tokens.d.ts +6 -0
- package/theme/phi-tokens.js +6 -0
- package/theme.d.ts +1 -0
- package/theme.js +6 -0
- package/types/cms-presets.d.ts +7 -0
- package/types/core-widget-placements.d.ts +8 -0
- package/types/layout-style.d.ts +9 -8
- package/types/layout-style.js +9 -8
- package/types/surface.d.ts +4 -0
- package/types/surface.js +4 -0
- package/types.d.ts +1 -1
- package/types.js +1 -1
package/styles/shell.css
CHANGED
|
@@ -556,3 +556,209 @@
|
|
|
556
556
|
transition: none;
|
|
557
557
|
}
|
|
558
558
|
}
|
|
559
|
+
|
|
560
|
+
/* -------------------------------------------------------------------------------------------------
|
|
561
|
+
Hero at the top.
|
|
562
|
+
|
|
563
|
+
A Page with a Hero starts it at the top of the window, behind the Header bands; a Page without one
|
|
564
|
+
keeps its content below them. No setting decides it: the Hero is the stage behind the Header, the
|
|
565
|
+
content the surface under it.
|
|
566
|
+
|
|
567
|
+
The Header rows hold no room here -- fixed at zero, so the Hero spanning them cannot grow them -- and
|
|
568
|
+
the grid depends on no measurement. Each band stands where the bands above it end, the glass pane
|
|
569
|
+
covers their sum, and the Hero's root Layout keeps its content below them by the same sum on top of
|
|
570
|
+
its own inset. Those values come from the Area's configs on the first paint and from the browser after
|
|
571
|
+
(`use-phi-shell-header-bands.ts`); a late one moves a band or the Hero's words, never the page.
|
|
572
|
+
|
|
573
|
+
Not where a Sider is embedded beside `header_bottom`: there the Sider would start behind the Header too.
|
|
574
|
+
The band offsets are important because a Region's root states `margin: 0` inline.
|
|
575
|
+
--------------------------------------------------------------------------------------------- */
|
|
576
|
+
[data-phi-shell-layout]:not([data-phi-shell-variant="embedded-sider"]):has(> [data-phi-region-key="hero"]) {
|
|
577
|
+
--phi-shell-header-height: calc(var(--phi-shell-band-top, 0px) + var(--phi-shell-band-main, 0px) + var(--phi-shell-band-bottom, 0px));
|
|
578
|
+
grid-template-rows: 0px 0px 0px auto minmax(0, 1fr) auto auto auto;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
/* Sized by their content, not their zero row: a band without a stated height whose content fills it by
|
|
582
|
+
percentage (`height: 100%`) would otherwise resolve against the row and fold to nothing. A stated height
|
|
583
|
+
is inline and wins. */
|
|
584
|
+
[data-phi-shell-layout]:not([data-phi-shell-variant="embedded-sider"]):has(> [data-phi-region-key="hero"]) > [data-phi-region-key^="header_"] {
|
|
585
|
+
align-self: start;
|
|
586
|
+
height: max-content;
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
[data-phi-shell-layout]:not([data-phi-shell-variant="embedded-sider"]):has(> [data-phi-region-key="hero"]) > [data-phi-region-key="header_main"] {
|
|
590
|
+
margin-block-start: var(--phi-shell-band-top, 0px) !important;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
[data-phi-shell-layout]:not([data-phi-shell-variant="embedded-sider"]):has(> [data-phi-region-key="hero"]) > [data-phi-region-key="header_bottom"] {
|
|
594
|
+
margin-block-start: calc(var(--phi-shell-band-top, 0px) + var(--phi-shell-band-main, 0px)) !important;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
[data-phi-shell-layout]:not([data-phi-shell-variant="embedded-sider"]):has(> [data-phi-region-key="hero"]) > [data-phi-region-key="hero"] {
|
|
598
|
+
grid-row-start: header_top-start;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
/* One pane over all three bands, its height their sum; the second Header pane has nothing left to cover. */
|
|
602
|
+
[data-phi-shell-layout]:not([data-phi-shell-variant="embedded-sider"]):has(> [data-phi-region-key="hero"]) > .phi-shell-chrome-pane--header {
|
|
603
|
+
grid-row: header_top-start / header_top-end;
|
|
604
|
+
align-self: start;
|
|
605
|
+
height: var(--phi-shell-header-height);
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
[data-phi-shell-layout]:not([data-phi-shell-variant="embedded-sider"]):has(> [data-phi-region-key="hero"]) > .phi-shell-chrome-pane--header-bottom {
|
|
609
|
+
display: none;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
/* Important because the Layout's padding is inline; the rule only adds to it, read back from `--phi-layout-padding-top`. */
|
|
613
|
+
[data-phi-shell-layout]:not([data-phi-shell-variant="embedded-sider"]) > [data-phi-region-key="hero"] > .phi-cms-region-shell__content > .phi-slot-child > [data-layout-kind] {
|
|
614
|
+
padding-block-start: calc(var(--phi-shell-header-height, 0px) + var(--phi-layout-padding-top, 0px)) !important;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
/* Content reaching into the Hero (SHELL.md): the Page's `content` set up by its `heroOverlap`, so its first
|
|
618
|
+
boxes stand on the Hero's picture. It follows the Hero in the DOM at the same z-index, so it paints over
|
|
619
|
+
it. Important because a Region's root states `margin: 0` inline. Nothing happens without a Hero. */
|
|
620
|
+
[data-phi-shell-layout]:has(> [data-phi-region-key="hero"]) > main [data-phi-region-key="content"] {
|
|
621
|
+
margin-block-start: calc(-1 * var(--phi-region-hero-overlap, 0px)) !important;
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
/* -------------------------------------------------------------------------------------------------
|
|
625
|
+
* The Sider on a phone (SHELL.md). A `sider_left` with `MobileDrawer` leaves its column below 768px
|
|
626
|
+
* and stands at the inline start, off screen, until `PhiShellSiderDrawer` marks the Shell open. The
|
|
627
|
+
* `!important`s win over the Region's inline geometry, which is the column's. Fixed inside the Shell
|
|
628
|
+
* means fixed to the Shell, a container: `--phi-shell-sider-drawer-top` moves it to the viewport's top.
|
|
629
|
+
* ---------------------------------------------------------------------------------------------- */
|
|
630
|
+
.phi-shell-sider-drawer-button,
|
|
631
|
+
.phi-shell-sider-drawer-mask {
|
|
632
|
+
display: none;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
@container phi-render-viewport (width < 768px) {
|
|
636
|
+
[data-phi-shell-sider-drawer] > .phi-shell-chrome-pane--sider {
|
|
637
|
+
display: none;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
[data-phi-sider-mobile="drawer"] {
|
|
641
|
+
position: fixed !important;
|
|
642
|
+
top: var(--phi-shell-sider-drawer-top, 0px) !important;
|
|
643
|
+
bottom: auto !important;
|
|
644
|
+
inset-inline-start: 0 !important;
|
|
645
|
+
width: min(max(var(--phi-shell-sider-width, 200px), 16rem), 85vw) !important;
|
|
646
|
+
min-width: min(max(var(--phi-shell-sider-width, 200px), 16rem), 85vw) !important;
|
|
647
|
+
max-width: 85vw !important;
|
|
648
|
+
height: 100dvh !important;
|
|
649
|
+
min-height: 0 !important;
|
|
650
|
+
max-height: 100dvh !important;
|
|
651
|
+
overflow-y: auto !important;
|
|
652
|
+
z-index: 1001 !important;
|
|
653
|
+
background-color: var(--ant-color-bg-elevated);
|
|
654
|
+
box-shadow: var(--ant-box-shadow-secondary);
|
|
655
|
+
transform: translateX(-100%);
|
|
656
|
+
visibility: hidden;
|
|
657
|
+
transition: transform 200ms ease, visibility 0s linear 200ms;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
/*
|
|
661
|
+
* A Sider without a ground of its own shows the Shell's pane behind it, and on a phone there is no pane
|
|
662
|
+
* behind it: it stands over the page. It takes the Theme's elevated ground; an authored ground stays.
|
|
663
|
+
*/
|
|
664
|
+
[data-phi-sider-mobile="drawer"][data-phi-shell-chrome="true"] {
|
|
665
|
+
background: var(--ant-color-bg-elevated) !important;
|
|
666
|
+
backdrop-filter: none !important;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
[data-phi-sider-mobile="drawer"] .phi-sider-collapse-bar {
|
|
670
|
+
display: none !important;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
[dir="rtl"] [data-phi-sider-mobile="drawer"] {
|
|
674
|
+
transform: translateX(100%);
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
[data-phi-sider-drawer-open="true"] [data-phi-sider-mobile="drawer"] {
|
|
678
|
+
transform: none;
|
|
679
|
+
visibility: visible;
|
|
680
|
+
transition: transform 200ms ease;
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
[data-phi-sider-drawer-open="true"] > .phi-shell-sider-drawer-mask {
|
|
684
|
+
display: block;
|
|
685
|
+
position: fixed;
|
|
686
|
+
top: var(--phi-shell-sider-drawer-top, 0px);
|
|
687
|
+
inset-inline: 0;
|
|
688
|
+
height: 100dvh;
|
|
689
|
+
z-index: 1000;
|
|
690
|
+
background: var(--ant-color-bg-mask);
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
.phi-shell-sider-drawer-button {
|
|
694
|
+
display: inline-flex;
|
|
695
|
+
position: absolute;
|
|
696
|
+
inset-inline-start: var(--ant-padding-xs);
|
|
697
|
+
top: 50%;
|
|
698
|
+
transform: translateY(-50%);
|
|
699
|
+
z-index: 1;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
/* No `header_main` to sit in: the button stands at the Shell's top. */
|
|
703
|
+
.phi-shell-sider-drawer-button--shell {
|
|
704
|
+
top: var(--ant-padding-xs);
|
|
705
|
+
transform: none;
|
|
706
|
+
z-index: 999;
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
/* The Header's content makes room for the button at its start. */
|
|
710
|
+
[data-phi-region-key="header_main"]:has(> .phi-shell-sider-drawer-button) > .phi-cms-region-shell__content {
|
|
711
|
+
padding-inline-start: calc(var(--ant-control-height) + var(--ant-padding-xs)) !important;
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
/*
|
|
716
|
+
* A Header Navigation on a phone (`phoneMenu: "button"`): the row gives way to a menu button at the
|
|
717
|
+
* Widget's inline end, which opens the entries in a Drawer. The phone is the Shell's width, as above.
|
|
718
|
+
*/
|
|
719
|
+
.phi-header-nav__button {
|
|
720
|
+
display: none;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
@container phi-render-viewport (width < 768px) {
|
|
724
|
+
.phi-header-nav--phone-button {
|
|
725
|
+
justify-content: flex-end !important;
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
.phi-header-nav--phone-button > .phi-header-nav__row {
|
|
729
|
+
display: none !important;
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
.phi-header-nav--phone-button > .phi-header-nav__button {
|
|
733
|
+
display: inline-flex;
|
|
734
|
+
align-items: center;
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
/*
|
|
738
|
+
* The button keeps its width. Its row hidden, the Widget has no width of its own, and the slot frames
|
|
739
|
+
* around it -- `min-width: 0` all -- gave it up to the Widgets beside it, down to a pixel.
|
|
740
|
+
*/
|
|
741
|
+
.phi-header-nav--phone-button,
|
|
742
|
+
.phi-slot-child:has(.phi-header-nav--phone-button) {
|
|
743
|
+
min-width: var(--ant-control-height) !important;
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
/*
|
|
747
|
+
* The account menu on a phone is its avatar: the pill with the name and the chevron is kept for a
|
|
748
|
+
* screen reader, which reads it as the button's name, and taken out of the row.
|
|
749
|
+
*/
|
|
750
|
+
.phi-account-menu .phi-dropdown-control__pill {
|
|
751
|
+
position: absolute !important;
|
|
752
|
+
width: 1px !important;
|
|
753
|
+
height: 1px !important;
|
|
754
|
+
overflow: hidden !important;
|
|
755
|
+
clip-path: inset(50%) !important;
|
|
756
|
+
white-space: nowrap !important;
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
@media (prefers-reduced-motion: reduce) {
|
|
761
|
+
[data-phi-sider-mobile="drawer"] {
|
|
762
|
+
transition: none !important;
|
|
763
|
+
}
|
|
764
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { PhiThemeMode } from "./phi-theme-presets";
|
|
2
|
+
import type { PhiThemeGradientKey } from "./phi-theme-gradients";
|
|
2
3
|
/**
|
|
3
4
|
* The shadow under each kind of Button, as a step rather than as CSS.
|
|
4
5
|
*
|
|
@@ -21,6 +22,11 @@ export declare const PHI_BUTTON_SHADOW_STEPS: readonly ["none", "soft", "strong"
|
|
|
21
22
|
export type PhiButtonShadowStep = (typeof PHI_BUTTON_SHADOW_STEPS)[number];
|
|
22
23
|
export type PhiThemeButtons = {
|
|
23
24
|
shadow?: Partial<Record<PhiButtonShadowKind, PhiButtonShadowStep>> | null;
|
|
25
|
+
/**
|
|
26
|
+
* The Theme gradient every primary Button is filled with (theme/phi-theme-gradients.ts); absent, they
|
|
27
|
+
* keep their one colour. A Button can still choose a gradient of its own with the `gradient` variant.
|
|
28
|
+
*/
|
|
29
|
+
primaryGradient?: PhiThemeGradientKey | null;
|
|
24
30
|
};
|
|
25
31
|
export declare function isPhiButtonShadowStep(value: unknown): value is PhiButtonShadowStep;
|
|
26
32
|
/**
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Theme's gradients: three named slots, like the ten custom colours, that a control can take its
|
|
3
|
+
* ground from instead of from one colour.
|
|
4
|
+
*
|
|
5
|
+
* A gradient belongs to a mode for the reason a mode seed does: the ground that reads as a brand on a
|
|
6
|
+
* light page -- a deep burgundy run -- is a hole in a dark one, where the same brand reads as gold. So a
|
|
7
|
+
* palette states each slot per mode (`modes[mode].gradients`), and a slot it leaves out is derived from
|
|
8
|
+
* the mode's own colours, which is what lets every Theme offer all three without anybody drawing them.
|
|
9
|
+
*
|
|
10
|
+
* They reach the page as Ant Design tokens -- `phiGradient1` and its `phiGradient1Text` -- and Ant Design
|
|
11
|
+
* writes every token as a custom property under the Theme's class (`--ant-phi-gradient-1`). That is the
|
|
12
|
+
* whole transport: the root writes both modes, a Surface tone writes its own mode on its box, and the
|
|
13
|
+
* Theme workspace's preview writes the draft's, so a control that reads the property is in the right mode
|
|
14
|
+
* wherever it stands without asking which one that is.
|
|
15
|
+
*/
|
|
16
|
+
export declare const PHI_THEME_GRADIENT_KEYS: readonly ["gradient1", "gradient2", "gradient3"];
|
|
17
|
+
export type PhiThemeGradientKey = (typeof PHI_THEME_GRADIENT_KEYS)[number];
|
|
18
|
+
export type PhiThemeGradientDirection = "to right" | "to left" | "to bottom" | "to top" | `${number}deg`;
|
|
19
|
+
/** The same shape a Background's gradient Base has, so the one editor draws and reads both. */
|
|
20
|
+
export type PhiThemeGradientStop = {
|
|
21
|
+
color: string;
|
|
22
|
+
percent: number;
|
|
23
|
+
};
|
|
24
|
+
export type PhiThemeGradient = {
|
|
25
|
+
direction: PhiThemeGradientDirection;
|
|
26
|
+
stops: PhiThemeGradientStop[];
|
|
27
|
+
/**
|
|
28
|
+
* Which of the Theme's two text colours stands on it (`PhiThemeGradientInks`); absent, whichever reads
|
|
29
|
+
* better where it reads worst. No colour of its own: words on a run read like the Theme's other words,
|
|
30
|
+
* and follow when the Theme's text colours change.
|
|
31
|
+
*/
|
|
32
|
+
text?: PhiThemeGradientTextTone;
|
|
33
|
+
};
|
|
34
|
+
export declare const PHI_THEME_GRADIENT_TEXT_TONES: readonly ["light", "dark"];
|
|
35
|
+
export type PhiThemeGradientTextTone = (typeof PHI_THEME_GRADIENT_TEXT_TONES)[number];
|
|
36
|
+
/**
|
|
37
|
+
* The Theme's two text colours for words on a run, in one mode: `light` is the text it sets on a solid
|
|
38
|
+
* coloured ground (`colorTextLightSolid`), `dark` the darker of its text and its ground -- its text in
|
|
39
|
+
* light mode, its ground in dark mode, where the text is the light one.
|
|
40
|
+
*/
|
|
41
|
+
export type PhiThemeGradientInks = Record<PhiThemeGradientTextTone, string>;
|
|
42
|
+
/**
|
|
43
|
+
* A slot as a palette states it: a whole run, or only which text colour stands on the run the slot
|
|
44
|
+
* derives -- so choosing the words does not freeze the palette's colours into the slot.
|
|
45
|
+
*/
|
|
46
|
+
export type PhiThemeGradientSlot = PhiThemeGradient | {
|
|
47
|
+
text: PhiThemeGradientTextTone;
|
|
48
|
+
};
|
|
49
|
+
export type PhiThemeGradientPalette = Partial<Record<PhiThemeGradientKey, PhiThemeGradientSlot>>;
|
|
50
|
+
/** A slot as a value a control or a widget config may store; anything else reads as no gradient. */
|
|
51
|
+
export declare function readPhiThemeGradientKey(value: unknown): PhiThemeGradientKey | undefined;
|
|
52
|
+
/** The text tone a stored slot states, with or without a run of its own. */
|
|
53
|
+
export declare function readPhiThemeGradientTextTone(value: unknown): PhiThemeGradientTextTone | undefined;
|
|
54
|
+
/** A stored gradient, read strictly: two stops at least, each a colour and a place on the run. */
|
|
55
|
+
export declare function readPhiThemeGradient(value: unknown): PhiThemeGradient | null;
|
|
56
|
+
export declare const PHI_THEME_GRADIENT_CSS_VARS: Record<PhiThemeGradientKey, {
|
|
57
|
+
paint: string;
|
|
58
|
+
text: string;
|
|
59
|
+
}>;
|
|
60
|
+
/** A run a little lighter under the pointer, a little darker while it is pressed. */
|
|
61
|
+
export declare const PHI_GRADIENT_HOVER_FILTER = "brightness(1.18) saturate(1.15)";
|
|
62
|
+
/** The two text colours of one mode's resolved tokens (`PhiThemeGradientInks`). */
|
|
63
|
+
export declare function resolvePhiThemeGradientInks(token: Record<string, unknown>): PhiThemeGradientInks;
|
|
64
|
+
/** Where a text colour reads worst on a gradient: the ratio, the stop, and whether under the pointer. */
|
|
65
|
+
export type PhiThemeGradientContrast = {
|
|
66
|
+
ratio: number;
|
|
67
|
+
stopIndex: number;
|
|
68
|
+
color: string;
|
|
69
|
+
hover: boolean;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Where a text colour reads worst on the run. Text crosses the whole run, so the stop it reads worst on
|
|
73
|
+
* decides -- at rest and under the pointer, where the hover filter lightens run and words alike. A
|
|
74
|
+
* translucent text colour is laid on each stop first. `null` where a colour is not one this can read
|
|
75
|
+
* (`hsl()`, a variable): the Theme workspace then says nothing rather than something wrong.
|
|
76
|
+
*/
|
|
77
|
+
export declare function resolvePhiThemeGradientContrast(gradient: PhiThemeGradient, text: string): PhiThemeGradientContrast | null;
|
|
78
|
+
/** The weakest contrast a text colour has anywhere on the run, at rest or under the pointer. */
|
|
79
|
+
export declare function resolvePhiThemeGradientWorstContrast(gradient: PhiThemeGradient, text: string): number | null;
|
|
80
|
+
/** Which of the two text colours reads better where the run reads worst for it. */
|
|
81
|
+
export declare function resolvePhiThemeGradientAutoTextTone(gradient: PhiThemeGradient, inks: PhiThemeGradientInks): PhiThemeGradientTextTone;
|
|
82
|
+
/** Every slot of one mode: what the palette states, the derived run where it states nothing. */
|
|
83
|
+
export declare function resolvePhiThemeGradients(stated: PhiThemeGradientPalette | null | undefined, token: Record<string, unknown>): Record<PhiThemeGradientKey, PhiThemeGradient>;
|
|
84
|
+
/** The text colour on a run: the tone it states, else the one that reads better. */
|
|
85
|
+
export declare function resolvePhiThemeGradientText(gradient: PhiThemeGradient, inks: PhiThemeGradientInks): string;
|
|
86
|
+
/**
|
|
87
|
+
* The tokens one mode's gradients become, and the primary Buttons' run when the Theme asks for one.
|
|
88
|
+
*
|
|
89
|
+
* Laid over the resolved alias tokens rather than fed to the algorithm: they are not seeds, nothing
|
|
90
|
+
* derives from them, and they are read back only as the custom properties Ant Design writes for them.
|
|
91
|
+
*/
|
|
92
|
+
export declare function buildPhiThemeGradientTokens({ gradients, token, primaryButtonGradient, }: {
|
|
93
|
+
gradients: PhiThemeGradientPalette | null | undefined;
|
|
94
|
+
token: Record<string, unknown>;
|
|
95
|
+
primaryButtonGradient?: PhiThemeGradientKey | null;
|
|
96
|
+
}): Record<string, string>;
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Theme's gradients: three named slots, like the ten custom colours, that a control can take its
|
|
3
|
+
* ground from instead of from one colour.
|
|
4
|
+
*
|
|
5
|
+
* A gradient belongs to a mode for the reason a mode seed does: the ground that reads as a brand on a
|
|
6
|
+
* light page -- a deep burgundy run -- is a hole in a dark one, where the same brand reads as gold. So a
|
|
7
|
+
* palette states each slot per mode (`modes[mode].gradients`), and a slot it leaves out is derived from
|
|
8
|
+
* the mode's own colours, which is what lets every Theme offer all three without anybody drawing them.
|
|
9
|
+
*
|
|
10
|
+
* They reach the page as Ant Design tokens -- `phiGradient1` and its `phiGradient1Text` -- and Ant Design
|
|
11
|
+
* writes every token as a custom property under the Theme's class (`--ant-phi-gradient-1`). That is the
|
|
12
|
+
* whole transport: the root writes both modes, a Surface tone writes its own mode on its box, and the
|
|
13
|
+
* Theme workspace's preview writes the draft's, so a control that reads the property is in the right mode
|
|
14
|
+
* wherever it stands without asking which one that is.
|
|
15
|
+
*/
|
|
16
|
+
export const PHI_THEME_GRADIENT_KEYS = ["gradient1", "gradient2", "gradient3"];
|
|
17
|
+
export const PHI_THEME_GRADIENT_TEXT_TONES = ["light", "dark"];
|
|
18
|
+
function isPhiThemeGradientKey(value) {
|
|
19
|
+
return typeof value === "string" && PHI_THEME_GRADIENT_KEYS.includes(value);
|
|
20
|
+
}
|
|
21
|
+
/** A slot as a value a control or a widget config may store; anything else reads as no gradient. */
|
|
22
|
+
export function readPhiThemeGradientKey(value) {
|
|
23
|
+
return isPhiThemeGradientKey(value) ? value : undefined;
|
|
24
|
+
}
|
|
25
|
+
function isGradientDirection(value) {
|
|
26
|
+
return typeof value === "string"
|
|
27
|
+
&& (["to right", "to left", "to bottom", "to top"].includes(value) || /^-?\d+(\.\d+)?deg$/.test(value));
|
|
28
|
+
}
|
|
29
|
+
/** The text tone a stored slot states, with or without a run of its own. */
|
|
30
|
+
export function readPhiThemeGradientTextTone(value) {
|
|
31
|
+
const text = value && typeof value === "object" ? value.text : undefined;
|
|
32
|
+
return PHI_THEME_GRADIENT_TEXT_TONES.find((tone) => tone === text);
|
|
33
|
+
}
|
|
34
|
+
/** A stored gradient, read strictly: two stops at least, each a colour and a place on the run. */
|
|
35
|
+
export function readPhiThemeGradient(value) {
|
|
36
|
+
if (!value || typeof value !== "object")
|
|
37
|
+
return null;
|
|
38
|
+
const raw = value;
|
|
39
|
+
if (!isGradientDirection(raw.direction) || !Array.isArray(raw.stops))
|
|
40
|
+
return null;
|
|
41
|
+
const stops = raw.stops.flatMap((stop) => {
|
|
42
|
+
if (!stop || typeof stop !== "object")
|
|
43
|
+
return [];
|
|
44
|
+
const { color, percent } = stop;
|
|
45
|
+
return typeof color === "string" && color.trim() && typeof percent === "number" && Number.isFinite(percent)
|
|
46
|
+
? [{ color: color.trim(), percent: Math.min(100, Math.max(0, percent)) }]
|
|
47
|
+
: [];
|
|
48
|
+
});
|
|
49
|
+
if (stops.length < 2)
|
|
50
|
+
return null;
|
|
51
|
+
const text = PHI_THEME_GRADIENT_TEXT_TONES.find((tone) => tone === raw.text);
|
|
52
|
+
return { direction: raw.direction, stops, ...(text ? { text } : {}) };
|
|
53
|
+
}
|
|
54
|
+
function serializePhiThemeGradientCss(gradient) {
|
|
55
|
+
return `linear-gradient(${gradient.direction}, ${gradient.stops.map((stop) => `${stop.color} ${stop.percent}%`).join(", ")})`;
|
|
56
|
+
}
|
|
57
|
+
/*
|
|
58
|
+
* The custom properties, named the way Ant Design names a token's (`token2CSSVar`): `phiGradient1Text`
|
|
59
|
+
* becomes `--ant-phi-gradient-1-text`. Stated once so CSS and controls never spell them differently.
|
|
60
|
+
*/
|
|
61
|
+
const PHI_THEME_GRADIENT_TOKEN_NAMES = {
|
|
62
|
+
gradient1: { paint: "phiGradient1", text: "phiGradient1Text" },
|
|
63
|
+
gradient2: { paint: "phiGradient2", text: "phiGradient2Text" },
|
|
64
|
+
gradient3: { paint: "phiGradient3", text: "phiGradient3Text" },
|
|
65
|
+
};
|
|
66
|
+
export const PHI_THEME_GRADIENT_CSS_VARS = {
|
|
67
|
+
gradient1: { paint: "--ant-phi-gradient-1", text: "--ant-phi-gradient-1-text" },
|
|
68
|
+
gradient2: { paint: "--ant-phi-gradient-2", text: "--ant-phi-gradient-2-text" },
|
|
69
|
+
gradient3: { paint: "--ant-phi-gradient-3", text: "--ant-phi-gradient-3-text" },
|
|
70
|
+
};
|
|
71
|
+
/*
|
|
72
|
+
* The primary Buttons' run when the Theme gives them one, with the filter each pressed state lays over
|
|
73
|
+
* it; `none` in all three otherwise, so the rules in `styles/gradients.css` change nothing on a Theme
|
|
74
|
+
* that never asked for a gradient. The states are filters rather than a second picture: Ant Design
|
|
75
|
+
* transitions every property of a Button, and a picture swapped on hover crossfades badly -- it
|
|
76
|
+
* flickered as the pointer left -- where a filter eases.
|
|
77
|
+
*/
|
|
78
|
+
const PHI_PRIMARY_BUTTON_GRADIENT_TOKENS = {
|
|
79
|
+
paint: "phiPrimaryButtonGradient",
|
|
80
|
+
hover: "phiPrimaryButtonGradientHover",
|
|
81
|
+
active: "phiPrimaryButtonGradientActive",
|
|
82
|
+
text: "phiPrimaryButtonGradientText",
|
|
83
|
+
};
|
|
84
|
+
/** A run a little lighter under the pointer, a little darker while it is pressed. */
|
|
85
|
+
export const PHI_GRADIENT_HOVER_FILTER = "brightness(1.18) saturate(1.15)";
|
|
86
|
+
const PHI_GRADIENT_ACTIVE_FILTER = "brightness(0.88)";
|
|
87
|
+
/* Enough of CSS colour for what a palette states: hex in its four lengths and `rgb()`/`rgba()`. */
|
|
88
|
+
function parseColor(value) {
|
|
89
|
+
const text = value.trim().toLowerCase();
|
|
90
|
+
const hex = /^#([0-9a-f]{3,8})$/.exec(text)?.[1];
|
|
91
|
+
if (hex) {
|
|
92
|
+
const full = hex.length <= 4 ? [...hex].map((digit) => digit + digit).join("") : hex;
|
|
93
|
+
return {
|
|
94
|
+
r: Number.parseInt(full.slice(0, 2), 16),
|
|
95
|
+
g: Number.parseInt(full.slice(2, 4), 16),
|
|
96
|
+
b: Number.parseInt(full.slice(4, 6), 16),
|
|
97
|
+
a: full.length >= 8 ? Number.parseInt(full.slice(6, 8), 16) / 255 : 1,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
const rgb = /^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)(?:[\s,/]+([\d.]+)(%?))?/.exec(text);
|
|
101
|
+
if (!rgb)
|
|
102
|
+
return null;
|
|
103
|
+
const alpha = rgb[4] == null ? 1 : Number(rgb[4]) / (rgb[5] ? 100 : 1);
|
|
104
|
+
return { r: Number(rgb[1]), g: Number(rgb[2]), b: Number(rgb[3]), a: Math.min(1, Math.max(0, alpha)) };
|
|
105
|
+
}
|
|
106
|
+
/** A translucent text colour as it lands on its ground: the near-black `0.88` text is not black. */
|
|
107
|
+
function composite(top, ground) {
|
|
108
|
+
const mix = (front, back) => front * top.a + back * (1 - top.a);
|
|
109
|
+
return { r: mix(top.r, ground.r), g: mix(top.g, ground.g), b: mix(top.b, ground.b) };
|
|
110
|
+
}
|
|
111
|
+
/* What `filter: brightness(n)` does to a colour: each channel scaled and clipped. */
|
|
112
|
+
function brighten(colour, factor) {
|
|
113
|
+
const scale = (channel) => Math.min(255, channel * factor);
|
|
114
|
+
return { r: scale(colour.r), g: scale(colour.g), b: scale(colour.b) };
|
|
115
|
+
}
|
|
116
|
+
function relativeLuminance({ r, g, b }) {
|
|
117
|
+
const channel = (value) => {
|
|
118
|
+
const c = value / 255;
|
|
119
|
+
return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
|
|
120
|
+
};
|
|
121
|
+
return 0.2126 * channel(r) + 0.7152 * channel(g) + 0.0722 * channel(b);
|
|
122
|
+
}
|
|
123
|
+
function contrastOf(first, second) {
|
|
124
|
+
const [light, dark] = [relativeLuminance(first), relativeLuminance(second)].sort((x, y) => y - x);
|
|
125
|
+
return (light + 0.05) / (dark + 0.05);
|
|
126
|
+
}
|
|
127
|
+
/** How much lighter a gradient Control is under the pointer (`styles/gradients.css`). */
|
|
128
|
+
const PHI_GRADIENT_HOVER_BRIGHTNESS = 1.18;
|
|
129
|
+
const PHI_GRADIENT_LIGHT_TEXT = "#ffffff";
|
|
130
|
+
const PHI_GRADIENT_DARK_TEXT = "rgba(0, 0, 0, 0.88)";
|
|
131
|
+
/** The two text colours of one mode's resolved tokens (`PhiThemeGradientInks`). */
|
|
132
|
+
export function resolvePhiThemeGradientInks(token) {
|
|
133
|
+
const light = tokenColor(token, "colorTextLightSolid", PHI_GRADIENT_LIGHT_TEXT);
|
|
134
|
+
const candidates = [tokenColor(token, "colorText", PHI_GRADIENT_DARK_TEXT), tokenColor(token, "colorBgBase", PHI_GRADIENT_DARK_TEXT)];
|
|
135
|
+
const darkness = (colour) => {
|
|
136
|
+
const parsed = parseColor(colour);
|
|
137
|
+
return parsed ? relativeLuminance(composite(parsed, { r: 255, g: 255, b: 255 })) : Number.POSITIVE_INFINITY;
|
|
138
|
+
};
|
|
139
|
+
const dark = candidates.reduce((darkest, next) => (darkness(next) < darkness(darkest) ? next : darkest));
|
|
140
|
+
return { light, dark: Number.isFinite(darkness(dark)) ? dark : PHI_GRADIENT_DARK_TEXT };
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Where a text colour reads worst on the run. Text crosses the whole run, so the stop it reads worst on
|
|
144
|
+
* decides -- at rest and under the pointer, where the hover filter lightens run and words alike. A
|
|
145
|
+
* translucent text colour is laid on each stop first. `null` where a colour is not one this can read
|
|
146
|
+
* (`hsl()`, a variable): the Theme workspace then says nothing rather than something wrong.
|
|
147
|
+
*/
|
|
148
|
+
export function resolvePhiThemeGradientContrast(gradient, text) {
|
|
149
|
+
const words = parseColor(text);
|
|
150
|
+
if (!words)
|
|
151
|
+
return null;
|
|
152
|
+
let worst = null;
|
|
153
|
+
for (const [stopIndex, stop] of gradient.stops.entries()) {
|
|
154
|
+
const ground = parseColor(stop.color);
|
|
155
|
+
if (!ground)
|
|
156
|
+
return null;
|
|
157
|
+
for (const hover of [false, true]) {
|
|
158
|
+
const factor = hover ? PHI_GRADIENT_HOVER_BRIGHTNESS : 1;
|
|
159
|
+
const lit = brighten(ground, factor);
|
|
160
|
+
const ratio = contrastOf(lit, brighten(composite(words, ground), factor));
|
|
161
|
+
if (worst == null || ratio < worst.ratio - 1e-9) {
|
|
162
|
+
worst = { ratio, stopIndex, color: stop.color, hover };
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return worst;
|
|
167
|
+
}
|
|
168
|
+
/** The weakest contrast a text colour has anywhere on the run, at rest or under the pointer. */
|
|
169
|
+
export function resolvePhiThemeGradientWorstContrast(gradient, text) {
|
|
170
|
+
return resolvePhiThemeGradientContrast(gradient, text)?.ratio ?? null;
|
|
171
|
+
}
|
|
172
|
+
/** Which of the two text colours reads better where the run reads worst for it. */
|
|
173
|
+
export function resolvePhiThemeGradientAutoTextTone(gradient, inks) {
|
|
174
|
+
const light = resolvePhiThemeGradientWorstContrast(gradient, inks.light) ?? 0;
|
|
175
|
+
const dark = resolvePhiThemeGradientWorstContrast(gradient, inks.dark) ?? 0;
|
|
176
|
+
return light >= dark ? "light" : "dark";
|
|
177
|
+
}
|
|
178
|
+
function tokenColor(token, key, fallback) {
|
|
179
|
+
const value = token[key];
|
|
180
|
+
return typeof value === "string" && value.trim() ? value : fallback;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* The three slots a mode offers when its palette states none: runs within the mode's own colours, so they
|
|
184
|
+
* belong to whichever brand the Theme carries. The primary's hover into its pressed shade first -- the
|
|
185
|
+
* brand --, the warning colour second because a palette's accent sits there, then the info colour into
|
|
186
|
+
* the primary, a run for the chrome. Three cover what a site asks of a run; a fourth was the third
|
|
187
|
+
* turned round.
|
|
188
|
+
*/
|
|
189
|
+
function buildPhiThemeDefaultGradients(token) {
|
|
190
|
+
const primary = tokenColor(token, "colorPrimary", "#1677ff");
|
|
191
|
+
const primaryHover = tokenColor(token, "colorPrimaryHover", primary);
|
|
192
|
+
const primaryActive = tokenColor(token, "colorPrimaryActive", primary);
|
|
193
|
+
const warning = tokenColor(token, "colorWarning", "#faad14");
|
|
194
|
+
const warningHover = tokenColor(token, "colorWarningHover", warning);
|
|
195
|
+
const warningActive = tokenColor(token, "colorWarningActive", warning);
|
|
196
|
+
const info = tokenColor(token, "colorInfo", primary);
|
|
197
|
+
return {
|
|
198
|
+
gradient1: { direction: "135deg", stops: [{ color: primaryHover, percent: 0 }, { color: primaryActive, percent: 100 }] },
|
|
199
|
+
gradient2: { direction: "135deg", stops: [{ color: warningHover, percent: 0 }, { color: warningActive, percent: 100 }] },
|
|
200
|
+
gradient3: { direction: "135deg", stops: [{ color: info, percent: 0 }, { color: primary, percent: 100 }] },
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
/** Every slot of one mode: what the palette states, the derived run where it states nothing. */
|
|
204
|
+
export function resolvePhiThemeGradients(stated, token) {
|
|
205
|
+
const defaults = buildPhiThemeDefaultGradients(token);
|
|
206
|
+
return Object.fromEntries(PHI_THEME_GRADIENT_KEYS.map((key) => {
|
|
207
|
+
const own = readPhiThemeGradient(stated?.[key]);
|
|
208
|
+
const text = readPhiThemeGradientTextTone(stated?.[key]);
|
|
209
|
+
return [key, own ?? (text ? { ...defaults[key], text } : defaults[key])];
|
|
210
|
+
}));
|
|
211
|
+
}
|
|
212
|
+
/** The text colour on a run: the tone it states, else the one that reads better. */
|
|
213
|
+
export function resolvePhiThemeGradientText(gradient, inks) {
|
|
214
|
+
return inks[gradient.text ?? resolvePhiThemeGradientAutoTextTone(gradient, inks)];
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* The tokens one mode's gradients become, and the primary Buttons' run when the Theme asks for one.
|
|
218
|
+
*
|
|
219
|
+
* Laid over the resolved alias tokens rather than fed to the algorithm: they are not seeds, nothing
|
|
220
|
+
* derives from them, and they are read back only as the custom properties Ant Design writes for them.
|
|
221
|
+
*/
|
|
222
|
+
export function buildPhiThemeGradientTokens({ gradients, token, primaryButtonGradient, }) {
|
|
223
|
+
const resolved = resolvePhiThemeGradients(gradients, token);
|
|
224
|
+
const inks = resolvePhiThemeGradientInks(token);
|
|
225
|
+
const tokens = {};
|
|
226
|
+
for (const key of PHI_THEME_GRADIENT_KEYS) {
|
|
227
|
+
const names = PHI_THEME_GRADIENT_TOKEN_NAMES[key];
|
|
228
|
+
tokens[names.paint] = serializePhiThemeGradientCss(resolved[key]);
|
|
229
|
+
tokens[names.text] = resolvePhiThemeGradientText(resolved[key], inks);
|
|
230
|
+
}
|
|
231
|
+
if (primaryButtonGradient && isPhiThemeGradientKey(primaryButtonGradient)) {
|
|
232
|
+
const paint = tokens[PHI_THEME_GRADIENT_TOKEN_NAMES[primaryButtonGradient].paint];
|
|
233
|
+
tokens[PHI_PRIMARY_BUTTON_GRADIENT_TOKENS.paint] = paint;
|
|
234
|
+
tokens[PHI_PRIMARY_BUTTON_GRADIENT_TOKENS.hover] = PHI_GRADIENT_HOVER_FILTER;
|
|
235
|
+
tokens[PHI_PRIMARY_BUTTON_GRADIENT_TOKENS.active] = PHI_GRADIENT_ACTIVE_FILTER;
|
|
236
|
+
// Only stated with a run under it: absent, the rule falls back to Ant Design's own primary text.
|
|
237
|
+
tokens[PHI_PRIMARY_BUTTON_GRADIENT_TOKENS.text] = tokens[PHI_THEME_GRADIENT_TOKEN_NAMES[primaryButtonGradient].text];
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
tokens[PHI_PRIMARY_BUTTON_GRADIENT_TOKENS.paint] = "none";
|
|
241
|
+
tokens[PHI_PRIMARY_BUTTON_GRADIENT_TOKENS.hover] = "none";
|
|
242
|
+
tokens[PHI_PRIMARY_BUTTON_GRADIENT_TOKENS.active] = "none";
|
|
243
|
+
}
|
|
244
|
+
return tokens;
|
|
245
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { PhiThemeGradientPalette } from "./phi-theme-gradients";
|
|
1
2
|
export type PhiThemeMode = "light" | "dark";
|
|
2
3
|
export type PhiThemeCustomColorKey = "custom1" | "custom2" | "custom3" | "custom4" | "custom5" | "custom6" | "custom7" | "custom8" | "custom9" | "custom10";
|
|
3
4
|
export type PhiThemeCustomColorPalette = Record<PhiThemeCustomColorKey, string>;
|
|
@@ -14,6 +15,8 @@ export type PhiThemePaletteMode = {
|
|
|
14
15
|
seed?: Record<string, string>;
|
|
15
16
|
overrides?: Record<string, string>;
|
|
16
17
|
customColors?: Partial<PhiThemeCustomColorPalette>;
|
|
18
|
+
/** The mode's gradient slots (theme/phi-theme-gradients.ts); a slot left out is derived. */
|
|
19
|
+
gradients?: PhiThemeGradientPalette;
|
|
17
20
|
};
|
|
18
21
|
/**
|
|
19
22
|
* A palette: the colour of a Theme, in the one shape a Module ships it in and a Site owns it in.
|
|
@@ -107,6 +107,9 @@ function mergePhiThemePaletteModes(base, own) {
|
|
|
107
107
|
...(base?.customColors || own?.customColors
|
|
108
108
|
? { customColors: { ...(base?.customColors ?? {}), ...(own?.customColors ?? {}) } }
|
|
109
109
|
: {}),
|
|
110
|
+
...(base?.gradients || own?.gradients
|
|
111
|
+
? { gradients: { ...(base?.gradients ?? {}), ...(own?.gradients ?? {}) } }
|
|
112
|
+
: {}),
|
|
110
113
|
};
|
|
111
114
|
}
|
|
112
115
|
/**
|
|
@@ -34,8 +34,12 @@ export declare const PHI_THEME_TOKEN_KEYS: readonly ["colorBgContainer", "colorB
|
|
|
34
34
|
* It is a separate list and not one more entry above, because `PhiThemeTokens` is cut from Ant
|
|
35
35
|
* Design's type and a name Ant Design does not know cannot be cut from it. A Client Component that
|
|
36
36
|
* needs one of these reads it as a CSS variable, the way a Server Component does.
|
|
37
|
+
*
|
|
38
|
+
* The `phiGradient*` names are the Theme's gradient slots and the primary Buttons' run
|
|
39
|
+
* (theme/phi-theme-gradients.ts): tokens of this package's own, laid over the resolved ones so Ant
|
|
40
|
+
* Design writes them per mode and per Surface tone like every other.
|
|
37
41
|
*/
|
|
38
|
-
export declare const PHI_THEME_OWN_TOKEN_KEYS: readonly ["paddingXXL"];
|
|
42
|
+
export declare const PHI_THEME_OWN_TOKEN_KEYS: readonly ["paddingXXL", "phiGradient1", "phiGradient1Text", "phiGradient2", "phiGradient2Text", "phiGradient3", "phiGradient3Text", "phiPrimaryButtonGradient", "phiPrimaryButtonGradientHover", "phiPrimaryButtonGradientActive", "phiPrimaryButtonGradientText"];
|
|
39
43
|
export type PhiThemeTokenKey = (typeof PHI_THEME_TOKEN_KEYS)[number];
|
|
40
44
|
/**
|
|
41
45
|
* The resolved Theme, in the names above and their Ant Design value types.
|
|
@@ -162,9 +162,23 @@ export const PHI_THEME_TOKEN_KEYS = [
|
|
|
162
162
|
* It is a separate list and not one more entry above, because `PhiThemeTokens` is cut from Ant
|
|
163
163
|
* Design's type and a name Ant Design does not know cannot be cut from it. A Client Component that
|
|
164
164
|
* needs one of these reads it as a CSS variable, the way a Server Component does.
|
|
165
|
+
*
|
|
166
|
+
* The `phiGradient*` names are the Theme's gradient slots and the primary Buttons' run
|
|
167
|
+
* (theme/phi-theme-gradients.ts): tokens of this package's own, laid over the resolved ones so Ant
|
|
168
|
+
* Design writes them per mode and per Surface tone like every other.
|
|
165
169
|
*/
|
|
166
170
|
export const PHI_THEME_OWN_TOKEN_KEYS = [
|
|
167
171
|
"paddingXXL",
|
|
172
|
+
"phiGradient1",
|
|
173
|
+
"phiGradient1Text",
|
|
174
|
+
"phiGradient2",
|
|
175
|
+
"phiGradient2Text",
|
|
176
|
+
"phiGradient3",
|
|
177
|
+
"phiGradient3Text",
|
|
178
|
+
"phiPrimaryButtonGradient",
|
|
179
|
+
"phiPrimaryButtonGradientHover",
|
|
180
|
+
"phiPrimaryButtonGradientActive",
|
|
181
|
+
"phiPrimaryButtonGradientText",
|
|
168
182
|
];
|
|
169
183
|
/**
|
|
170
184
|
* The colours a palette seeds, shared by both modes.
|
package/theme/phi-tokens.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The golden ratio, φ = (1 + √5) / 2 ≈ 1.618: the step of the spacing scale below (each step the sum of
|
|
3
|
+
* the two before it), the golden rectangle a picture may be cropped to, and how a picture shares a line
|
|
4
|
+
* with text -- the text φ times as wide as the picture.
|
|
5
|
+
*/
|
|
6
|
+
export declare const PHI_GOLDEN_RATIO: number;
|
|
1
7
|
/**
|
|
2
8
|
* The one spacing scale: the distance inside a frame and the distance between two things alike.
|
|
3
9
|
*
|
package/theme/phi-tokens.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The golden ratio, φ = (1 + √5) / 2 ≈ 1.618: the step of the spacing scale below (each step the sum of
|
|
3
|
+
* the two before it), the golden rectangle a picture may be cropped to, and how a picture shares a line
|
|
4
|
+
* with text -- the text φ times as wide as the picture.
|
|
5
|
+
*/
|
|
6
|
+
export const PHI_GOLDEN_RATIO = (1 + Math.sqrt(5)) / 2;
|
|
1
7
|
/**
|
|
2
8
|
* The one spacing scale: the distance inside a frame and the distance between two things alike.
|
|
3
9
|
*
|
package/theme.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { isPhiThemePaletteModeSeedKey, mergePhiThemePalettes, PHI_THEME_CUSTOM_COLOR_KEYS, PHI_THEME_PALETTE_MODE_SEED_KEYS, type PhiThemeCustomColorKey, type PhiThemeCustomColorPalette, type PhiThemeMode, type PhiThemePalette, type PhiThemePaletteMode, type PhiThemePresetPlugin, } from "./theme/phi-theme-presets";
|
|
2
2
|
export * from "./theme/phi-tokens";
|
|
3
|
+
export { PHI_COLOR, PHI_RADIUS, PHI_SPACE } from "./theme/antd-css-var-contract";
|
|
3
4
|
export { type PhiThemeBlockIdentity, type PhiThemeFontsBlock, type PhiThemeGroundBlock, type PhiThemePaletteBlock, type PhiThemeSetBlock, type PhiThemeStyleBlock, } from "./theme/phi-theme-blocks";
|