@phis/ui 0.4.4 → 0.4.5

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.
Files changed (183) hide show
  1. package/README.md +9 -3
  2. package/cms/plugins.d.ts +1 -0
  3. package/cms/plugins.js +2 -0
  4. package/components/cms/phi-cms-root-layout.js +30 -1
  5. package/components/controls/phi-background-control.d.ts +6 -1
  6. package/components/controls/phi-background-control.js +12 -4
  7. package/components/controls/phi-button-control.d.ts +13 -1
  8. package/components/controls/phi-button-control.js +21 -3
  9. package/components/controls/phi-dropdown-control.js +2 -2
  10. package/components/controls/phi-media-asset-tile-control.js +10 -10
  11. package/components/controls/phi-progress-control.d.ts +10 -2
  12. package/components/controls/phi-progress-control.js +6 -2
  13. package/components/controls/phi-ribbon-control.d.ts +4 -1
  14. package/components/controls/phi-ribbon-control.js +5 -3
  15. package/components/controls/phi-ribbon-wrap-control.d.ts +7 -1
  16. package/components/controls/phi-ribbon-wrap-control.js +8 -2
  17. package/components/controls/phi-segmented-control.d.ts +4 -1
  18. package/components/controls/phi-segmented-control.js +13 -2
  19. package/components/controls/phi-surface-control.d.ts +2 -0
  20. package/components/controls/phi-surface-control.js +16 -1
  21. package/components/controls/phi-switch-control.d.ts +4 -1
  22. package/components/controls/phi-switch-control.js +8 -2
  23. package/components/controls/phi-tag-control.d.ts +4 -1
  24. package/components/controls/phi-tag-control.js +11 -3
  25. package/components/layouts/phi-layout-view-model.js +10 -1
  26. package/components/regions/clients/cms-region-container-client.js +11 -1
  27. package/components/regions/phi-cms-region-container.js +5 -1
  28. package/components/regions/phi-cms-region-shell.d.ts +10 -0
  29. package/components/regions/phi-cms-region-shell.js +53 -7
  30. package/components/root/phi-root-layout.d.ts +1 -0
  31. package/components/root/phi-root-layout.js +1 -0
  32. package/components/root/phi-root-theme-resolver.js +12 -1
  33. package/components/root/phi-shell-chrome-overlay.d.ts +6 -0
  34. package/components/root/phi-shell-chrome-overlay.js +7 -1
  35. package/components/runtime/runtime-module-context.d.ts +12 -1
  36. package/components/runtime/runtime-module-context.js +6 -1
  37. package/components/shell/phi-cms-shell.d.ts +7 -1
  38. package/components/shell/phi-cms-shell.js +4 -2
  39. package/components/shell/use-phi-shell-header-bands.d.ts +5 -0
  40. package/components/shell/use-phi-shell-header-bands.js +64 -0
  41. package/components/shell/use-phi-shell-sticky-bottom.d.ts +18 -0
  42. package/components/shell/use-phi-shell-sticky-bottom.js +54 -0
  43. package/components/tables/client/phi-table-binding.d.ts +1 -0
  44. package/components/tables/client/phi-table-binding.js +22 -3
  45. package/components/trees/client/phi-tree-binding.d.ts +1 -0
  46. package/components/trees/client/phi-tree-binding.js +11 -2
  47. package/components/widgets/client/shared/phi-collection-provider.js +4 -3
  48. package/components/widgets/client/shared/phi-collection-view-binding.d.ts +1 -0
  49. package/components/widgets/client/shared/phi-collection-view-binding.js +16 -2
  50. package/components/widgets/client/shared/phi-command-buttons.js +6 -2
  51. package/components/widgets/config/background.d.ts +20 -0
  52. package/components/widgets/config/background.js +44 -2
  53. package/components/widgets/config/button-variant.d.ts +22 -4
  54. package/components/widgets/config/button-variant.js +24 -5
  55. package/components/widgets/config/common-action-field.d.ts +1 -1
  56. package/components/widgets/config/parser-primitives.js +4 -2
  57. package/components/widgets/config/theme-gradient.d.ts +11 -0
  58. package/components/widgets/config/theme-gradient.js +12 -0
  59. package/components/widgets/label-sets/background.js +2 -0
  60. package/components/widgets/label-sets/geometry.js +2 -0
  61. package/components/widgets/label-sets/inspector.js +4 -0
  62. package/components/widgets/label-types/background.d.ts +1 -0
  63. package/components/widgets/label-types/background.js +1 -0
  64. package/components/widgets/label-types/common-controls.js +2 -2
  65. package/components/widgets/label-types/geometry.d.ts +1 -0
  66. package/components/widgets/label-types/geometry.js +1 -0
  67. package/components/widgets/label-types/inspector.d.ts +4 -0
  68. package/components/widgets/label-types/inspector.js +2 -0
  69. package/components/widgets/shared/card-body-client.d.ts +11 -0
  70. package/components/widgets/shared/card-body-client.js +32 -4
  71. package/components/widgets/shared/collection-source-failure.d.ts +26 -0
  72. package/components/widgets/shared/collection-source-failure.js +42 -0
  73. package/components/widgets/shared/markdown-render.js +16 -3
  74. package/components/widgets/shared/widget-failure-client.d.ts +10 -0
  75. package/components/widgets/shared/widget-failure-client.js +20 -0
  76. package/components/widgets/shared/widget-failure.d.ts +31 -0
  77. package/components/widgets/shared/widget-failure.js +20 -0
  78. package/components/widgets/shared/widget-failure.server.d.ts +9 -0
  79. package/components/widgets/shared/widget-failure.server.js +12 -0
  80. package/gateway/dashboard-card-memo.d.ts +3 -0
  81. package/gateway/dashboard-card-memo.js +25 -0
  82. package/helpers/cms-region-keys.d.ts +1 -1
  83. package/helpers/layout-style.d.ts +8 -4
  84. package/helpers/layout-style.js +3 -2
  85. package/helpers/mode-paint.d.ts +4 -0
  86. package/helpers/mode-paint.js +47 -0
  87. package/helpers/surface-style.js +33 -11
  88. package/module-dashboard-cards.d.ts +1 -0
  89. package/module-dashboard-cards.js +1 -0
  90. package/module-records.d.ts +7 -0
  91. package/module-records.js +6 -0
  92. package/package.json +1 -1
  93. package/plugins/runtime-modules/builder/clients/inspector-config-field.js +1 -1
  94. package/plugins/runtime-modules/builder/clients/inspector-surface-labels.js +1 -0
  95. package/plugins/runtime-modules/builder/clients/region-inspector.js +47 -2
  96. package/plugins/runtime-modules/builder/clients/runtime-module-authoring-boundary.js +1 -1
  97. package/plugins/runtime-modules/builder/controller/draft-command-controller.js +7 -4
  98. package/plugins/runtime-modules/builder/controller/page-controller.js +7 -0
  99. package/plugins/runtime-modules/builder/persistence.d.ts +3 -0
  100. package/plugins/runtime-modules/builder/persistence.js +9 -1
  101. package/plugins/runtime-modules/core/content-entries/record-source.server.d.ts +3 -1
  102. package/plugins/runtime-modules/core/content-entries/record-source.server.js +7 -4
  103. package/plugins/runtime-modules/core/widgets/button/client.js +2 -2
  104. package/plugins/runtime-modules/core/widgets/button/config.d.ts +40 -4
  105. package/plugins/runtime-modules/core/widgets/button/config.js +12 -0
  106. package/plugins/runtime-modules/core/widgets/card/config.d.ts +94 -0
  107. package/plugins/runtime-modules/core/widgets/card/config.js +38 -0
  108. package/plugins/runtime-modules/core/widgets/card/editor.js +8 -1
  109. package/plugins/runtime-modules/core/widgets/card/server.js +4 -0
  110. package/plugins/runtime-modules/core/widgets/collection-view/asset-binding.d.ts +4 -1
  111. package/plugins/runtime-modules/core/widgets/collection-view/asset-binding.js +10 -3
  112. package/plugins/runtime-modules/core/widgets/collection-view/authoring.js +1 -1
  113. package/plugins/runtime-modules/core/widgets/collection-view/client.d.ts +3 -0
  114. package/plugins/runtime-modules/core/widgets/collection-view/client.js +47 -11
  115. package/plugins/runtime-modules/core/widgets/collection-view/image-preview-grid.d.ts +4 -1
  116. package/plugins/runtime-modules/core/widgets/collection-view/image-preview-grid.js +2 -2
  117. package/plugins/runtime-modules/core/widgets/collection-view/plugin.js +3 -2
  118. package/plugins/runtime-modules/core/widgets/collection-view/server.d.ts +6 -1
  119. package/plugins/runtime-modules/core/widgets/collection-view/server.js +21 -3
  120. package/plugins/runtime-modules/core/widgets/entry-detail/plugin.js +1 -1
  121. package/plugins/runtime-modules/core/widgets/entry-detail/server.d.ts +3 -1
  122. package/plugins/runtime-modules/core/widgets/entry-detail/server.js +5 -2
  123. package/plugins/runtime-modules/core/widgets/entry-header/plugin.js +1 -1
  124. package/plugins/runtime-modules/core/widgets/entry-header/server.d.ts +3 -1
  125. package/plugins/runtime-modules/core/widgets/entry-header/server.js +5 -2
  126. package/plugins/runtime-modules/core/widgets/entry-list/plugin.js +1 -1
  127. package/plugins/runtime-modules/core/widgets/entry-list/server.d.ts +6 -3
  128. package/plugins/runtime-modules/core/widgets/entry-list/server.js +13 -6
  129. package/plugins/runtime-modules/core/widgets/gallery/plugin.js +1 -1
  130. package/plugins/runtime-modules/core/widgets/gallery/server.d.ts +5 -3
  131. package/plugins/runtime-modules/core/widgets/gallery/server.js +8 -6
  132. package/plugins/runtime-modules/core/widgets/record/client.d.ts +4 -1
  133. package/plugins/runtime-modules/core/widgets/record/client.js +8 -3
  134. package/plugins/runtime-modules/core/widgets/record/plugin.js +3 -2
  135. package/plugins/runtime-modules/core/widgets/record/server.d.ts +3 -1
  136. package/plugins/runtime-modules/core/widgets/record/server.js +2 -2
  137. package/plugins/runtime-modules/core/widgets/segmented/client.js +1 -1
  138. package/plugins/runtime-modules/core/widgets/segmented/config.d.ts +21 -1
  139. package/plugins/runtime-modules/core/widgets/segmented/config.js +11 -1
  140. package/plugins/runtime-modules/core/widgets/switch/client.js +1 -1
  141. package/plugins/runtime-modules/core/widgets/switch/config.d.ts +19 -0
  142. package/plugins/runtime-modules/core/widgets/switch/config.js +11 -0
  143. package/plugins/runtime-modules/core/widgets/table/authoring.js +1 -1
  144. package/plugins/runtime-modules/core/widgets/table/client.d.ts +4 -1
  145. package/plugins/runtime-modules/core/widgets/table/client.js +16 -3
  146. package/plugins/runtime-modules/core/widgets/table/plugin.js +3 -2
  147. package/plugins/runtime-modules/core/widgets/table/server.d.ts +3 -1
  148. package/plugins/runtime-modules/core/widgets/table/server.js +2 -2
  149. package/plugins/runtime-modules/core/widgets/table/static-resource-editor.js +2 -1
  150. package/plugins/runtime-modules/core/widgets/timeline/authoring.js +1 -1
  151. package/plugins/runtime-modules/core/widgets/timeline/client.d.ts +1 -3
  152. package/plugins/runtime-modules/core/widgets/timeline/client.js +14 -4
  153. package/plugins/runtime-modules/core/widgets/tree/authoring.js +1 -1
  154. package/plugins/runtime-modules/core/widgets/tree/client.d.ts +4 -1
  155. package/plugins/runtime-modules/core/widgets/tree/client.js +13 -2
  156. package/plugins/runtime-modules/core/widgets/tree/plugin.js +3 -2
  157. package/plugins/runtime-modules/core/widgets/tree/server.d.ts +3 -1
  158. package/plugins/runtime-modules/core/widgets/tree/server.js +2 -2
  159. package/plugins/runtime-modules/theme/presets.d.ts +9 -1
  160. package/plugins/runtime-modules/theme/tour.d.ts +9 -1
  161. package/plugins/runtime-modules/theme/tour.js +10 -1
  162. package/plugins/runtime-modules/theme/widgets/brand-controls/client.js +138 -7
  163. package/runtime-data-provider-client.d.ts +2 -0
  164. package/runtime-data-provider-client.js +7 -0
  165. package/styles/controls.css +10 -5
  166. package/styles/gradients.css +101 -0
  167. package/styles/root.css +18 -0
  168. package/styles/shell.css +64 -0
  169. package/theme/phi-button-shadow.d.ts +6 -0
  170. package/theme/phi-theme-gradients.d.ts +96 -0
  171. package/theme/phi-theme-gradients.js +245 -0
  172. package/theme/phi-theme-presets.d.ts +3 -0
  173. package/theme/phi-theme-presets.js +3 -0
  174. package/theme/phi-theme-tokens.d.ts +5 -1
  175. package/theme/phi-theme-tokens.js +14 -0
  176. package/types/cms-presets.d.ts +7 -0
  177. package/types/core-widget-placements.d.ts +3 -0
  178. package/types/layout-style.d.ts +9 -8
  179. package/types/layout-style.js +9 -8
  180. package/types/surface.d.ts +4 -0
  181. package/types/surface.js +4 -0
  182. package/types.d.ts +1 -1
  183. package/types.js +1 -1
@@ -36,7 +36,7 @@ function panelStep(key, slot, controls, title, description) {
36
36
  */
37
37
  export const PHI_THEME_WORKSPACE_TOUR = {
38
38
  id: `${PHI_THEME_RUNTIME_MODULE_ID}/workspace`,
39
- version: 1,
39
+ version: 2,
40
40
  steps: [
41
41
  {
42
42
  key: "theme-choice",
@@ -53,6 +53,15 @@ export const PHI_THEME_WORKSPACE_TOUR = {
53
53
  placement: "bottom",
54
54
  },
55
55
  panelStep("color", 0, PHI_THEME_PAGE_WIDGET_IDS.widgetBrandThemeControls, "Colour from a few seeds", "A palette is picked whole, or each colour is set on its own. Every colour is a seed: Primary, Info, Success, Warning, Error, Link, the text and the background each grow into the shades for hover, borders and backgrounds, and Custom grows into ten steps of its own."),
56
+ {
57
+ key: "gradients",
58
+ target: `cms:${PHI_THEME_PAGE_WIDGET_IDS.widgetBrandThemeControls}:gradients`,
59
+ title: "Three gradients",
60
+ description: "Below the colours, three runs that Buttons, badges, ribbons, tags and switches can be filled with: the brand, an accent and one for the chrome. Each starts from the palette's colours and follows them until you set its stops and direction yourself, separately for light and dark. Its labels take the theme's light or dark text, whichever reads better unless you choose; the preview shows a Button, its hover and a badge, and a note says where a label would read poorly.",
61
+ placement: "right",
62
+ prepare: [showPanel(0)],
63
+ release: [showPanel(0)],
64
+ },
56
65
  panelStep("style", 1, PHI_THEME_PAGE_WIDGET_IDS.widgetBrandStyleControls, "Buttons and corners", "A shape sets the corners at once -- square, subtle, rounded or pill -- for buttons and fields alike. Below it the details: the buttons' shadows, the corner radius in three sizes, how tall controls are, and the fonts and their size."),
57
66
  panelStep("background", 2, PHI_THEME_PAGE_WIDGET_IDS.widgetBrandBackgroundControls, "Behind everything", "The root background is one layer behind the whole Site: a colour, a gradient or an image, still or in parallax, with an overlay of colour, pattern or noise on top. The chrome overlay is a second ground the header, the sider and the footer share, and the chrome shadow sets how they cast onto the Page. Each is set for light and dark."),
58
67
  panelStep("brand", 3, PHI_THEME_PAGE_WIDGET_IDS.widgetBrandIdentityControls, "The Site's own marks", "The logo, one per mode, and where a click on it leads; the wordmark, the Site's name in type; and the two short lines the Brand shows beside them."),
@@ -3,12 +3,15 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
3
3
  import { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore, } from "react";
4
4
  import { usePhiSignalDispatcher, usePhiSignalListener } from "../../../../../components/runtime/runtime-signal-bus";
5
5
  import { usePhiSignalIdentity } from "../../../../../components/runtime/runtime-signal-identity";
6
+ import { usePhiVisualAnchorParts } from "../../../../../components/runtime/runtime-visual-anchors";
7
+ import { PHI_VISUAL_ANCHOR_PART_ATTRIBUTE } from "../../../../../types/visual-anchors";
6
8
  import { usePhiControlSignalController } from "../../../../../components/widgets/client/shared/phi-control-signals";
7
9
  import { PHI_SIGNAL_VALUE_SCHEMAS } from "../../../../../types/signals";
8
10
  import { createPhiThemeControllerAddress } from "../../../../../plugins/runtime-modules/theme/controller/address";
9
11
  import { PHI_THEME_SIGNAL_CHANNELS } from "../../../../../plugins/runtime-modules/theme/controller/signals";
10
12
  import { PHI_THEME_CUSTOM_COLOR_KEYS, isPhiThemePaletteModeSeedKey, mergePhiThemePalettes, resolvePhiThemeColorTokens, } from "../../../../../theme/phi-theme-presets";
11
13
  import { buildPhiThemeCustomColorPalette, resolvePhiThemePaletteCustomColors } from "../../../../../theme/phi-theme-palette";
14
+ import { buildPhiThemeGradientTokens, PHI_THEME_GRADIENT_KEYS, readPhiThemeGradient, readPhiThemeGradientTextTone, readPhiThemeGradientKey, resolvePhiThemeGradients, resolvePhiThemeGradientText, resolvePhiThemeGradientContrast, resolvePhiThemeGradientAutoTextTone, resolvePhiThemeGradientInks, PHI_GRADIENT_HOVER_FILTER, } from "../../../../../theme/phi-theme-gradients";
12
15
  import { usePhiConfig } from "../../../../../components/root/phi-config-provider";
13
16
  import { usePhiThemeBlockCatalog } from "../../../../../components/root/phi-theme-block-catalog-provider";
14
17
  import { resolvePhiThemeComposition, resolvePhiThemeEffectiveLogo, resolvePhiThemeEffectiveFonts, resolvePhiThemeEffectiveRoot, } from "../../../../../theme/phi-theme-composition";
@@ -267,6 +270,7 @@ const THEME_COLOR_SEED_SECTIONS = [
267
270
  /** The Collapse order of the colour panel, which decides which section an author finds open. */
268
271
  const BRAND_THEME_COLOR_SECTION_KEYS = [
269
272
  "custom",
273
+ "gradients",
270
274
  ...THEME_COLOR_SEED_SECTIONS.map((section) => section.key),
271
275
  ];
272
276
  /**
@@ -289,7 +293,7 @@ function withThemePalette(theme, palette) {
289
293
  function mergeThemePaletteMode(theme, mode, rewrite) {
290
294
  const palette = theme.palette ?? {};
291
295
  const written = rewrite(palette.modes?.[mode] ?? {});
292
- const nextMode = Object.fromEntries(["seed", "overrides", "customColors"]
296
+ const nextMode = Object.fromEntries(["seed", "overrides", "customColors", "gradients"]
293
297
  .filter((part) => Object.keys(written[part] ?? {}).length > 0)
294
298
  .map((part) => [part, written[part]]));
295
299
  return withThemePalette(theme, {
@@ -347,10 +351,28 @@ function mergeThemeButtonShadow(theme, kind, choice) {
347
351
  if (choice !== "theme") {
348
352
  shadow[kind] = choice;
349
353
  }
354
+ const { shadow: _previousShadow, ...otherButtons } = theme.buttons ?? {};
355
+ return withThemeButtons(theme, Object.keys(shadow).length > 0 ? { ...otherButtons, shadow } : otherButtons);
356
+ }
357
+ /** The Button settings written back, the `buttons` entry gone when nothing is left in it. */
358
+ function withThemeButtons(theme, buttons) {
350
359
  const withoutButtons = omitThemeFields(theme, "buttons");
351
- return Object.keys(shadow).length > 0
352
- ? { ...withoutButtons, buttons: { ...(theme.buttons ?? {}), shadow } }
353
- : withoutButtons;
360
+ return Object.keys(buttons).length > 0 ? { ...withoutButtons, buttons } : withoutButtons;
361
+ }
362
+ /** Every primary Button filled with a Theme gradient, or handed back to its one colour. */
363
+ function mergeThemePrimaryButtonGradient(theme, gradient) {
364
+ const { primaryGradient: _previous, ...otherButtons } = theme.buttons ?? {};
365
+ return withThemeButtons(theme, gradient ? { ...otherButtons, primaryGradient: gradient } : otherButtons);
366
+ }
367
+ /** One gradient slot stated for the mode being edited, or handed back to the derived run with `null`. */
368
+ function mergeThemeGradient(theme, key, gradient, mode) {
369
+ return mergeThemePaletteMode(theme, mode, (current) => {
370
+ const gradients = { ...(current.gradients ?? {}) };
371
+ delete gradients[key];
372
+ if (gradient)
373
+ gradients[key] = gradient;
374
+ return { ...current, gradients };
375
+ });
354
376
  }
355
377
  /** A structural token the author set, laid over the style block under `style.token`. */
356
378
  function mergeThemeToken(theme, tokenPatch) {
@@ -505,13 +527,22 @@ function readAliasTokenNumber(token, key) {
505
527
  }
506
528
  /** A draft's alias tokens for one mode, its blocks folded in, as the live render resolves a Theme. */
507
529
  function resolveBrandDraftAliasTokens(resolvedTheme, preset, mode, fonts = {}) {
508
- return resolvePhiAntdAliasTokens(mode, {
530
+ const aliasTokens = resolvePhiAntdAliasTokens(mode, {
509
531
  ...buildPhiEffectiveNonColorThemeTokens(resolvedTheme),
510
532
  ...resolvePhiThemeColorTokens(preset, resolvedTheme.palette, mode),
511
533
  ...(resolvedTheme.style?.token ?? {}),
512
534
  ...(fonts.body ? { fontFamily: fonts.body } : {}),
513
535
  ...(fonts.mono ? { fontFamilyCode: fonts.mono } : {}),
514
536
  });
537
+ // The gradient slots and the primary Buttons' run, as the root lays them over its tokens.
538
+ return {
539
+ ...aliasTokens,
540
+ ...buildPhiThemeGradientTokens({
541
+ gradients: mergePhiThemePalettes(preset.palette, resolvedTheme.palette).modes?.[mode]?.gradients,
542
+ token: aliasTokens,
543
+ primaryButtonGradient: readPhiThemeGradientKey(resolvedTheme.buttons?.primaryGradient),
544
+ }),
545
+ };
515
546
  }
516
547
  function readEffectiveTokenNumber(token, key, fallback) {
517
548
  const value = token[key];
@@ -1013,10 +1044,15 @@ function resolveThemeFontSlots(theme, fonts, block) {
1013
1044
  ?? "",
1014
1045
  }));
1015
1046
  }
1047
+ /** The parts of the colour panel a Tour may point at. */
1048
+ const PHI_BRAND_THEME_CONTROLS_ANCHOR_PARTS = ["gradients"];
1016
1049
  export function PhiBuilderBrandThemeControlsWidgetClient({ runtime, config, colorPickerLabels, }) {
1017
1050
  const { presets: themePresets, token: clientToken } = usePhiConfig();
1018
1051
  const themeBlocks = usePhiThemeBlockCatalog();
1019
1052
  const sectionLabelWidth = clientToken.controlHeight * 3;
1053
+ // The Gradients section is a part a Tour can point at (`cms:<id>:gradients`, theme/tour.ts).
1054
+ const anchorAddress = usePhiSignalIdentity().receiver ?? null;
1055
+ usePhiVisualAnchorParts(anchorAddress?.startsWith("cms:") ? anchorAddress : null, PHI_BRAND_THEME_CONTROLS_ANCHOR_PARTS);
1020
1056
  const colorControlWidth = clientToken.controlHeight * 5.5;
1021
1057
  const themeKey = resolveThemeKey(config);
1022
1058
  const { state, draftRef, publishDraft, pickerTransaction } = usePhiBrandThemeDraft(runtime, themeKey);
@@ -1031,7 +1067,7 @@ export function PhiBuilderBrandThemeControlsWidgetClient({ runtime, config, colo
1031
1067
  * then redrew. Kept until the draft, the mode, the blocks or the presets change.
1032
1068
  */
1033
1069
  const customLabel = colorPickerLabels?.custom ?? "Custom";
1034
- const { themeComposition, selectedPreset, colorToken, ownPalette, ownOverrides, customPalette, customColorOptions, computedToken, } = useMemo(() => {
1070
+ const { themeComposition, selectedPreset, colorToken, ownPalette, ownOverrides, customPalette, customColorOptions, computedToken, gradients, gradientInks, ownGradients, } = useMemo(() => {
1035
1071
  const themeComposition = resolvePhiThemeComposition(state.draft, themeBlocks);
1036
1072
  const selectedPreset = resolveThemePayloadPreset(state.draft, themePresets);
1037
1073
  /*
@@ -1060,6 +1096,15 @@ export function PhiBuilderBrandThemeControlsWidgetClient({ runtime, config, colo
1060
1096
  ...buildPhiEffectiveNonColorThemeTokens(state.draft),
1061
1097
  ...baseColorToken,
1062
1098
  });
1099
+ /*
1100
+ * The gradient slots as the Site draws them: stated by the palette block or the draft, else derived
1101
+ * from the mode's colours as they resolve WITH the author's overrides -- what the root derives from.
1102
+ */
1103
+ const gradientToken = resolvePhiAntdAliasTokens(previewMode, { ...buildPhiEffectiveNonColorThemeTokens(state.draft), ...colorToken });
1104
+ const gradients = resolvePhiThemeGradients(mergePhiThemePalettes(selectedPreset.palette, state.draft.palette).modes?.[previewMode]?.gradients, gradientToken);
1105
+ // The Theme's two text colours in this mode, which the words on a run are chosen from.
1106
+ const gradientInks = resolvePhiThemeGradientInks(gradientToken);
1107
+ const ownGradients = ownPalette.modes?.[previewMode]?.gradients ?? {};
1063
1108
  return {
1064
1109
  themeComposition,
1065
1110
  selectedPreset,
@@ -1069,6 +1114,9 @@ export function PhiBuilderBrandThemeControlsWidgetClient({ runtime, config, colo
1069
1114
  customPalette,
1070
1115
  customColorOptions,
1071
1116
  computedToken,
1117
+ gradients,
1118
+ gradientInks,
1119
+ ownGradients,
1072
1120
  };
1073
1121
  }, [customLabel, previewMode, state.draft, themeBlocks, themePresets]);
1074
1122
  return (_jsx(PhiFlexControl, { vertical: true, gap: clientToken.padding, style: { width: "100%", minWidth: 0, opacity: loading ? 0.65 : 1 }, children: _jsx(PhiCardControl, { size: "small", children: _jsxs(PhiFlexControl, { vertical: true, gap: clientToken.paddingSM, children: [_jsx(PhiBrandBlockPicker, { label: "Palette", value: themeComposition.palette.key, unavailable: themeComposition.unavailable.palette, options: themeBlocks.palettes, onChange: (key) => {
@@ -1099,6 +1147,86 @@ export function PhiBuilderBrandThemeControlsWidgetClient({ runtime, config, colo
1099
1147
  publishDraft(mergeThemeCustomColors(state.draft, { [tokenKey]: value }, previewMode));
1100
1148
  } }) }, item.key))) })),
1101
1149
  },
1150
+ {
1151
+ key: "gradients",
1152
+ label: (_jsxs(PhiFlexControl, { align: "center", gap: clientToken.paddingSM, wrap: "wrap", style: { minWidth: 0 }, [PHI_VISUAL_ANCHOR_PART_ATTRIBUTE]: "gradients", children: [_jsx(PhiTypographyControl, { strong: true, style: { width: sectionLabelWidth }, children: "Gradients" }), _jsx(PhiFlexControl, { gap: clientToken.paddingXXS, "aria-hidden": true, children: PHI_THEME_GRADIENT_KEYS.map((key) => (_jsx("span", { style: {
1153
+ width: clientToken.controlHeightSM * 1.5,
1154
+ height: clientToken.controlHeightSM,
1155
+ borderRadius: clientToken.borderRadiusSM,
1156
+ background: `linear-gradient(${gradients[key].direction}, ${gradients[key].stops
1157
+ .map((stop) => `${stop.color} ${stop.percent}%`).join(", ")})`,
1158
+ } }, key))) })] })),
1159
+ children: (_jsxs(PhiFlexControl, { vertical: true, gap: clientToken.padding, children: [_jsxs(PhiTypographyControl, { type: "secondary", children: ["Three runs Buttons, badges, tags and switches can be filled with. ", previewMode === "dark" ? "Dark" : "Light", " mode; a slot left alone follows the palette's colours."] }), PHI_THEME_GRADIENT_KEYS.map((key, index) => {
1160
+ const gradient = gradients[key];
1161
+ // The run the author stated, and the text tone they chose -- either may stand alone.
1162
+ const own = readPhiThemeGradient(ownGradients[key]);
1163
+ const ownTone = readPhiThemeGradientTextTone(ownGradients[key]);
1164
+ const text = resolvePhiThemeGradientText(gradient, gradientInks);
1165
+ const contrast = resolvePhiThemeGradientContrast(gradient, text);
1166
+ const tone = gradient.text ?? resolvePhiThemeGradientAutoTextTone(gradient, gradientInks);
1167
+ const otherTone = tone === "light" ? "dark" : "light";
1168
+ // Neither of the Theme's text colours reads: then the run itself is what has to change.
1169
+ const otherContrast = resolvePhiThemeGradientContrast(gradient, gradientInks[otherTone]);
1170
+ const neitherReads = otherContrast != null && otherContrast.ratio < 4.5;
1171
+ /*
1172
+ * An error where the author's choice is what reads poorly: a run they stated, or a text
1173
+ * colour they chose while the other one would read. Otherwise the palette's colours are
1174
+ * what falls short, and it is a hint.
1175
+ */
1176
+ const contrastLevel = own || (ownTone && !neitherReads) ? "error" : "info";
1177
+ const paint = `linear-gradient(${gradient.direction}, ${gradient.stops
1178
+ .map((stop) => `${stop.color} ${stop.percent}%`).join(", ")})`;
1179
+ return (_jsxs(PhiFlexControl, { vertical: true, gap: clientToken.paddingXS, children: [_jsxs(PhiFlexControl, { align: "center", justify: "space-between", gap: clientToken.paddingXS, children: [_jsx(PhiTypographyControl, { strong: true, children: `Gradient ${index + 1}` }), own || ownTone ? (_jsx(PhiButtonControl, { size: "small", type: "link", disabled: saving, style: { paddingInline: 0, height: clientToken.controlHeightSM }, onClick: () => publishDraft(mergeThemeGradient(draftRef.current, key, null, previewMode)), label: "Reset to palette" })) : null] }), _jsxs(PhiFlexControl, { align: "center", gap: clientToken.paddingSM, wrap: "wrap", "aria-hidden": true, children: [[false, true].map((hover) => (_jsx("span", { style: {
1180
+ display: "inline-flex",
1181
+ alignItems: "center",
1182
+ height: clientToken.controlHeight,
1183
+ paddingInline: clientToken.padding,
1184
+ borderRadius: 999,
1185
+ background: paint,
1186
+ color: text,
1187
+ fontSize: clientToken.fontSize,
1188
+ fontWeight: 600,
1189
+ whiteSpace: "nowrap",
1190
+ ...(hover ? { filter: PHI_GRADIENT_HOVER_FILTER } : {}),
1191
+ }, children: hover ? "Hover" : `Gradient ${index + 1}` }, hover ? "hover" : "rest"))), _jsx("span", { style: {
1192
+ display: "inline-flex",
1193
+ alignItems: "center",
1194
+ paddingInline: clientToken.paddingXS,
1195
+ borderRadius: clientToken.borderRadiusSM,
1196
+ background: paint,
1197
+ color: text,
1198
+ fontSize: clientToken.fontSizeSM,
1199
+ fontWeight: 600,
1200
+ lineHeight: 2,
1201
+ }, children: "Badge" })] }), _jsx(PhiBackgroundControl, { value: normalizePhiBackgroundWidgetConfig({
1202
+ base: { kind: "gradient", direction: gradient.direction, stops: gradient.stops },
1203
+ }), baseKinds: ["gradient"], overlay: false, filters: [], motionModes: [], imageSourceKinds: [], disabled: saving, onChange: (value) => {
1204
+ const base = normalizePhiBackgroundWidgetConfig(value).base;
1205
+ if (base.kind !== "gradient")
1206
+ return;
1207
+ publishDraft(mergeThemeGradient(draftRef.current, key, { direction: base.direction, stops: base.stops, ...(ownTone ? { text: ownTone } : {}) }, previewMode));
1208
+ } }, `${key}-${previewMode}`), _jsxs(PhiFlexControl, { vertical: true, gap: clientToken.paddingXXS, children: [_jsx(PhiTypographyControl, { type: "secondary", children: "Label colour" }), _jsx(PhiSegmentedControl, { block: true, disabled: saving, value: ownTone ?? "auto", options: [
1209
+ { value: "auto", label: "Automatic" },
1210
+ { value: "light", label: "Light text" },
1211
+ { value: "dark", label: "Dark text" },
1212
+ ], onChange: (next) => {
1213
+ // Only the words change: a run the author stated stays theirs, a derived one stays derived.
1214
+ const run = own ? { direction: own.direction, stops: own.stops } : null;
1215
+ const slot = next === "auto"
1216
+ ? run
1217
+ : run ? { ...run, text: next } : { text: next };
1218
+ publishDraft(mergeThemeGradient(draftRef.current, key, slot, previewMode));
1219
+ } })] }), contrast != null && contrast.ratio < 4.5 ? (_jsx(PhiAlertControl, { showIcon: true, level: contrastLevel,
1220
+ // Small: a note beside a setting in a narrow panel, not a page's message.
1221
+ title: (_jsx("span", { style: { display: "block", fontSize: clientToken.fontSize, fontWeight: 600, lineHeight: 1.4 }, children: `Label contrast ${contrast.ratio.toFixed(1)}:1 at stop ${contrast.stopIndex + 1} (${contrast.color})${contrast.hover ? " under the pointer" : ""}.` })), description: (_jsx("span", { style: { display: "block", fontSize: clientToken.fontSizeSM, lineHeight: 1.45 }, children: [
1222
+ own ? null : "This run is derived from the palette's colours.",
1223
+ "Labels on Buttons, badges and tags need 4.5:1 to read reliably.",
1224
+ neitherReads
1225
+ ? "Neither of the Theme's text colours reaches it here: make the run's stops lighter or darker."
1226
+ : `The ${otherTone} text reads better: choose it, or move the stops away from the ${tone} text.`,
1227
+ ].filter(Boolean).join(" ") })) })) : null] }, key));
1228
+ })] })),
1229
+ },
1102
1230
  ...THEME_COLOR_SEED_SECTIONS.map((section) => {
1103
1231
  const seedAuthored = Object.prototype.hasOwnProperty.call(ownPalette.seed ?? {}, section.key) ||
1104
1232
  Object.prototype.hasOwnProperty.call(ownPalette.modes?.[previewMode]?.seed ?? {}, section.key);
@@ -1229,7 +1357,10 @@ export function PhiBuilderBrandStyleControlsWidgetClient({ runtime, config, }) {
1229
1357
  {
1230
1358
  key: "buttonShadow",
1231
1359
  label: _jsx(PhiTypographyControl, { strong: true, children: "Button Shadow" }),
1232
- children: (_jsxs(PhiFlexControl, { vertical: true, gap: clientToken.paddingSM, children: [_jsx(PhiTypographyControl, { type: "secondary", children: "Under each kind of Button. Theme keeps the tinted line; applies to both modes." }), PHI_THEME_BUTTON_SHADOW_KINDS.map((item) => (_jsx(PhiSegmentedControl, { label: item.label, value: readThemeButtonShadowChoice(state.draft, item.key), options: PHI_THEME_BUTTON_SHADOW_OPTIONS, block: true, disabled: saving, onChange: (choice) => publishDraft(mergeThemeButtonShadow(state.draft, item.key, choice)) }, item.key)))] })),
1360
+ children: (_jsxs(PhiFlexControl, { vertical: true, gap: clientToken.paddingSM, children: [_jsx(PhiTypographyControl, { type: "secondary", children: "Under each kind of Button. Theme keeps the tinted line; applies to both modes." }), PHI_THEME_BUTTON_SHADOW_KINDS.map((item) => (_jsx(PhiSegmentedControl, { label: item.label, value: readThemeButtonShadowChoice(state.draft, item.key), options: PHI_THEME_BUTTON_SHADOW_OPTIONS, block: true, disabled: saving, onChange: (choice) => publishDraft(mergeThemeButtonShadow(state.draft, item.key, choice)) }, item.key))), _jsx(PhiDividerControl, { style: { marginBlock: 0 } }), _jsx(PhiTypographyControl, { type: "secondary", children: "Fills every primary Button with one of the Theme's gradients (Color tab). A Button can still choose its own with the Gradient variant." }), _jsx(PhiSelectControl, { label: "Primary fill", value: readPhiThemeGradientKey(state.draft.buttons?.primaryGradient) ?? "none", options: [
1361
+ { value: "none", label: "Colour" },
1362
+ ...PHI_THEME_GRADIENT_KEYS.map((key, index) => ({ value: key, label: `Gradient ${index + 1}` })),
1363
+ ], disabled: saving, onChange: (choice) => publishDraft(mergeThemePrimaryButtonGradient(state.draft, choice === "none" ? null : choice)) })] })),
1233
1364
  },
1234
1365
  {
1235
1366
  key: "radius",
@@ -20,3 +20,5 @@ export { PhiCardCollectionViewBinding, } from "./plugins/runtime-modules/core/wi
20
20
  export { createPhiRuntimeModuleDataProviderClientManifest, extendPhiRuntimeModuleDataProviderClientManifest, PhiRuntimeModuleDataProviderClientManifestProvider, } from "./components/runtime/runtime-module-data-provider-client-manifest";
21
21
  export type { PhiRuntimeModuleDataProviderClientManifest, } from "./components/runtime/runtime-module-data-provider-client-manifest";
22
22
  export type { PhiRuntimeModuleDataProviderClientProps, PhiRuntimeModuleDataProviderClientDefinition, PhiRuntimeModuleDataProviderDescriptor, } from "./types/cms-plugins";
23
+ export { PhiWidgetFailure } from "./components/widgets/shared/widget-failure-client";
24
+ export type { PhiWidgetFailureProps } from "./components/widgets/shared/widget-failure";
@@ -18,3 +18,10 @@ export { createPhiCollectionProviderClient, PhiCollectionProviderClient, usePhiC
18
18
  */
19
19
  export { PhiCardCollectionViewBinding, } from "./plugins/runtime-modules/core/widgets/card/collection-view-binding";
20
20
  export { createPhiRuntimeModuleDataProviderClientManifest, extendPhiRuntimeModuleDataProviderClientManifest, PhiRuntimeModuleDataProviderClientManifestProvider, } from "./components/runtime/runtime-module-data-provider-client-manifest";
21
+ /*
22
+ * What a Widget bound to one of these Providers renders when the binding cannot be served in the browser
23
+ * -- the Area does not offer the Provider, a read failed after hydration: the error card in the Builder,
24
+ * nothing on a live page, one `cms.widget.unavailable` warning per distinct failure. The Server twin,
25
+ * `PhiWidgetFailureServer`, is Server-only and lives in `@phis/ui/module/records`.
26
+ */
27
+ export { PhiWidgetFailure } from "./components/widgets/shared/widget-failure-client";
@@ -400,17 +400,22 @@ h5.phi-typography, .phi-typography h5 {
400
400
  /* --- Dropdown ------------------------------------------------------------------------------------ */
401
401
 
402
402
  /*
403
- * The shared pill trigger: a bordered, fully rounded label that reacts to hover. Hover is a CSS
404
- * state, not React state, so a trigger never re-renders to change its own border colour.
403
+ * The shared pill trigger: a bordered label that reacts to hover. Hover is a CSS state, not React
404
+ * state, so a trigger never re-renders to change its own border colour.
405
+ *
406
+ * Its corner, its line and its air are the Theme's: the small Control's radius from the Style's control
407
+ * shape (a capsule under `pill`, a sharp box under `square`, the small step of the scale otherwise), the
408
+ * Theme's line width, and the spacing scale -- so it stands beside the header's buttons as one of them
409
+ * rather than as the one round thing a square Theme left behind.
405
410
  */
406
411
  .phi-dropdown-control__pill {
407
412
  display: inline-flex;
408
413
  align-items: center;
409
414
  justify-content: center;
410
415
  min-width: 3.5rem;
411
- padding: 4px 10px;
412
- border: 1px solid var(--ant-color-border);
413
- border-radius: 999px;
416
+ padding: var(--ant-padding-xxs) var(--ant-padding-sm);
417
+ border: var(--ant-line-width) solid var(--ant-color-border);
418
+ border-radius: var(--phi-control-radius-sm);
414
419
  color: inherit;
415
420
  font-size: inherit;
416
421
  line-height: 1;
@@ -0,0 +1,101 @@
1
+ /*
2
+ * Gradients and glass on Controls (theme/phi-theme-gradients.ts).
3
+ *
4
+ * Ant Design 6 draws a Button's ground with `background-color` from its own variables
5
+ * (`--ant-btn-bg-color`, `-hover`, `-active`) and never sets `background-image`. So a run laid on as
6
+ * `background-image` sits over Ant Design's colour without fighting it and keeps that colour as the edge
7
+ * a gradient cannot draw. A disabled Button is left out of every rule here: its run would outweigh the
8
+ * `background` shorthand Ant Design greys it out with. Text colour goes through Ant Design's text variables, which is
9
+ * what its hover and active rules read.
10
+ *
11
+ * The selectors repeat a class for the reason `control-shape.css` gives: Ant Design's rules weigh up to
12
+ * four classes, and a tie is settled by source order this file does not control.
13
+ */
14
+
15
+ /*
16
+ * Every primary Button, where the Theme fills them with a gradient (`theme.buttons.primaryGradient`).
17
+ * A Button of the `gradient` variant is primary underneath and has a run of its own, so it is left out.
18
+ */
19
+ .ant-btn.ant-btn.ant-btn-color-primary.ant-btn-variant-solid:not(.ant-btn-background-ghost):not(.phi-btn-gradient):not(:disabled):not(.ant-btn-disabled) {
20
+ background-image: var(--ant-phi-primary-button-gradient, none);
21
+ /* From the outer edge and once: from the padding box it tiled again under the border, and a pill's
22
+ ends showed the other end of the run. */
23
+ background-origin: border-box;
24
+ background-repeat: no-repeat;
25
+ will-change: filter;
26
+ --ant-btn-text-color: var(--ant-phi-primary-button-gradient-text, var(--ant-color-text-light-solid));
27
+ }
28
+
29
+ .ant-btn.ant-btn.ant-btn-color-primary.ant-btn-variant-solid:not(.ant-btn-background-ghost):not(.phi-btn-gradient):not(:disabled):not(.ant-btn-disabled):hover {
30
+ filter: var(--ant-phi-primary-button-gradient-hover, none);
31
+ }
32
+
33
+ .ant-btn.ant-btn.ant-btn-color-primary.ant-btn-variant-solid:not(.ant-btn-background-ghost):not(.phi-btn-gradient):not(:disabled):not(.ant-btn-disabled):active {
34
+ filter: var(--ant-phi-primary-button-gradient-active, none);
35
+ }
36
+
37
+ /*
38
+ * A Button of the `gradient` variant: its slot's run, whatever the Theme does with primary Buttons. The
39
+ * Control states the slot as `--phi-control-gradient` and its text as `--phi-control-gradient-text`.
40
+ */
41
+ .ant-btn.ant-btn.phi-btn-gradient.phi-btn-gradient:not(:disabled):not(.ant-btn-disabled) {
42
+ background-image: var(--phi-control-gradient);
43
+ background-origin: border-box;
44
+ background-repeat: no-repeat;
45
+ /* Its own layer at rest as well: the browser otherwise lifts the Button onto one only while the
46
+ filter eases, rasterises its rounded rim there, and the pill seemed to change size twice. */
47
+ will-change: filter;
48
+ /* The run is the whole ground: a colour beneath it showed through the anti-aliased rim of a pill. */
49
+ --ant-btn-bg-color: transparent;
50
+ --ant-btn-bg-color-hover: transparent;
51
+ --ant-btn-bg-color-active: transparent;
52
+ --ant-btn-border-color: transparent;
53
+ --ant-btn-border-color-hover: transparent;
54
+ --ant-btn-border-color-active: transparent;
55
+ --ant-btn-text-color: var(--phi-control-gradient-text);
56
+ --ant-btn-text-color-hover: var(--phi-control-gradient-text);
57
+ --ant-btn-text-color-active: var(--phi-control-gradient-text);
58
+ }
59
+
60
+ /*
61
+ * Under the pointer and pressed the run stays the same picture and only its light changes: Ant Design
62
+ * transitions every property of a Button, and a picture swapped on hover crossfaded badly as the pointer
63
+ * left. A filter eases with the rest.
64
+ */
65
+ .ant-btn.ant-btn.phi-btn-gradient.phi-btn-gradient:not(:disabled):not(.ant-btn-disabled):hover {
66
+ filter: brightness(1.18) saturate(1.15);
67
+ }
68
+
69
+ .ant-btn.ant-btn.phi-btn-gradient.phi-btn-gradient:not(:disabled):not(.ant-btn-disabled):active {
70
+ filter: brightness(0.88);
71
+ }
72
+
73
+ /*
74
+ * A Button of the `glass` variant: a pane of the container ground of the mode it stands in, frosting
75
+ * whatever shows through it -- a picture, a gradient. Inside a dark Surface tone the ground is the dark
76
+ * one, so the pane darkens instead of misting a dark picture white.
77
+ */
78
+ .ant-btn.ant-btn.phi-btn-glass.phi-btn-glass {
79
+ --ant-btn-bg-color: color-mix(in srgb, var(--ant-color-bg-container) 24%, transparent);
80
+ --ant-btn-bg-color-hover: color-mix(in srgb, var(--ant-color-bg-container) 38%, transparent);
81
+ --ant-btn-bg-color-active: color-mix(in srgb, var(--ant-color-bg-container) 48%, transparent);
82
+ --ant-btn-border-color: color-mix(in srgb, var(--ant-color-text) 24%, transparent);
83
+ --ant-btn-border-color-hover: color-mix(in srgb, var(--ant-color-text) 40%, transparent);
84
+ --ant-btn-border-color-active: color-mix(in srgb, var(--ant-color-text) 40%, transparent);
85
+ --ant-btn-text-color: var(--ant-color-text);
86
+ --ant-btn-text-color-hover: var(--ant-color-text);
87
+ --ant-btn-text-color-active: var(--ant-color-text);
88
+ /* The frost itself is inline on the Button: a `backdrop-filter` in a stylesheet does not survive the build (styles/shell.css). */
89
+ }
90
+
91
+ /* A Switch that is on, filled with its slot's run instead of the primary colour. */
92
+ .ant-switch.ant-switch.ant-switch.phi-switch-gradient.ant-switch-checked {
93
+ background-image: var(--phi-control-gradient);
94
+ }
95
+
96
+ /* The thumb a Segmented slides under its selected item, and the item itself once the thumb has gone. */
97
+ .ant-segmented.ant-segmented.phi-segmented-gradient .ant-segmented-thumb,
98
+ .ant-segmented.ant-segmented.phi-segmented-gradient .ant-segmented-item-selected {
99
+ background-image: var(--phi-control-gradient);
100
+ color: var(--phi-control-gradient-text);
101
+ }
package/styles/root.css CHANGED
@@ -237,3 +237,21 @@ samp {
237
237
  animation-delay: 0s !important;
238
238
  }
239
239
  }
240
+
241
+ /* The gates a paint per mode reads (`helpers/mode-paint.ts`): the open one is empty, the closed one is the
242
+ guaranteed-invalid value, so the closed mode's value is the one a `var()` falls back to. Light outside
243
+ the Root Layout as well -- a Modal portalled to <body> still reads one value. */
244
+ :root {
245
+ --phi-mode-light-gate: ;
246
+ --phi-mode-dark-gate: initial;
247
+ }
248
+
249
+ :where([data-phi-theme-mode="light"]) {
250
+ --phi-mode-light-gate: ;
251
+ --phi-mode-dark-gate: initial;
252
+ }
253
+
254
+ :where([data-phi-theme-mode="dark"]) {
255
+ --phi-mode-light-gate: initial;
256
+ --phi-mode-dark-gate: ;
257
+ }
package/styles/shell.css CHANGED
@@ -556,3 +556,67 @@
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
+ }
@@ -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>;