@phis/ui 0.6.9 → 0.6.10

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.
@@ -3,8 +3,7 @@ import { PhiCmsRegionType } from "../../../constants/phi-cms";
3
3
  import { createPhiCmsPresetNodes } from "../../../helpers/cms-preset-nodes";
4
4
  import { PHI_SHARED_PACKAGE_NAME } from "../../../constants/package";
5
5
  import { createPhiPresetCmsInstanceId } from "../../../types/cms-instance-id";
6
- import { resolvePhiCmsAreaMask } from "../../../constants/cms-areas";
7
- import { PHI_PAGE } from "../../../theme/antd-css-var-contract";
6
+ import { resolvePhiPageInsetConfig } from "../../../helpers/page-inset";
8
7
  /**
9
8
  * The shared content-region scaffold of the built-in page presets.
10
9
  *
@@ -49,26 +48,17 @@ export function buildPhiBasePageLayoutNode(page) {
49
48
  label: PHI_BASE_PAGE_LAYOUT_LABEL,
50
49
  });
51
50
  }
52
- /** Public: its content Region stands in by the Theme's Page padding; the signed-in Areas by their own. */
53
- const PHI_PUBLIC_AREA_MASK = resolvePhiCmsAreaMask("public");
54
51
  /**
55
52
  * The distance from the screen's edge to a Page's content, on its content Region and nowhere else.
56
53
  *
57
- * Both are the Theme's (THEME.md "Page padding"): in Public `PHI_PAGE.padding` (21 on a phone and 34
58
- * from a tablet on unless the Theme says otherwise), in App and the staff Areas `PHI_PAGE.signedInPadding`
59
- * (13 on a phone, 21 from a tablet on). The Hero and the Footer top are Regions of their own and keep the
60
- * full width. The scaffold inside has no padding; what stands in it with a ground of its own -- the wash
61
- * column, a Split Card's cards -- insets its content by `base`.
54
+ * Both are the Theme's (THEME.md "Page padding"): in Public `PHI_PAGE.padding` (21 unless the Theme says
55
+ * otherwise), in App and the staff Areas `PHI_PAGE.signedInPadding` (13 on a phone, 21 from a tablet on).
56
+ * The Hero and the Footer top are Regions of their own and keep the full width. The scaffold inside has no
57
+ * padding; what stands in it with a ground of its own -- the wash column, a Split Card's cards -- insets
58
+ * its content by `base`.
62
59
  */
63
60
  function resolvePhiBasePageRegionInset(page) {
64
- const publicPage = page.areaMask !== 0 && (page.areaMask & ~PHI_PUBLIC_AREA_MASK) === 0;
65
- const inset = publicPage ? PHI_PAGE.padding : PHI_PAGE.signedInPadding;
66
- return {
67
- paddingTop: inset.top,
68
- paddingRight: inset.right,
69
- paddingBottom: inset.bottom,
70
- paddingLeft: inset.left,
71
- };
61
+ return resolvePhiPageInsetConfig(page.areaMask);
72
62
  }
73
63
  /**
74
64
  * Content region rooted on the scaffold. The region keeps its per-page identity -- `regionId` stays the
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Which of the Theme's Page insets a Page stands in by (THEME.md "Page padding"): Public's
3
+ * (`PHI_PAGE.padding`) for a Page of Public alone, the signed-in Areas' (`PHI_PAGE.signedInPadding`) for
4
+ * every other. Read where the base Pages are built and where a preset Page is checked, so both agree.
5
+ */
6
+ export declare function resolvePhiPageInset(areaMask: number | null | undefined): {
7
+ readonly top: "var(--phi-page-inset-top, var(--phi-page-padding-top-desktop))";
8
+ readonly right: "var(--phi-page-inset-right, var(--phi-page-padding-right-desktop))";
9
+ readonly bottom: "var(--phi-page-inset-bottom, var(--phi-page-padding-bottom-desktop))";
10
+ readonly left: "var(--phi-page-inset-left, var(--phi-page-padding-left-desktop))";
11
+ } | {
12
+ readonly top: "var(--phi-signed-in-page-inset-top, var(--phi-signed-in-page-padding-top-desktop))";
13
+ readonly right: "var(--phi-signed-in-page-inset-right, var(--phi-signed-in-page-padding-right-desktop))";
14
+ readonly bottom: "var(--phi-signed-in-page-inset-bottom, var(--phi-signed-in-page-padding-bottom-desktop))";
15
+ readonly left: "var(--phi-signed-in-page-inset-left, var(--phi-signed-in-page-padding-left-desktop))";
16
+ };
17
+ /** The inset as the four sides of a Region's config. */
18
+ export declare function resolvePhiPageInsetConfig(areaMask: number | null | undefined): {
19
+ paddingTop: "var(--phi-page-inset-top, var(--phi-page-padding-top-desktop))" | "var(--phi-signed-in-page-inset-top, var(--phi-signed-in-page-padding-top-desktop))";
20
+ paddingRight: "var(--phi-page-inset-right, var(--phi-page-padding-right-desktop))" | "var(--phi-signed-in-page-inset-right, var(--phi-signed-in-page-padding-right-desktop))";
21
+ paddingBottom: "var(--phi-page-inset-bottom, var(--phi-page-padding-bottom-desktop))" | "var(--phi-signed-in-page-inset-bottom, var(--phi-signed-in-page-padding-bottom-desktop))";
22
+ paddingLeft: "var(--phi-page-inset-left, var(--phi-page-padding-left-desktop))" | "var(--phi-signed-in-page-inset-left, var(--phi-signed-in-page-padding-left-desktop))";
23
+ };
@@ -0,0 +1,23 @@
1
+ import { resolvePhiCmsAreaMask } from "../constants/cms-areas";
2
+ import { PHI_PAGE } from "../theme/antd-css-var-contract";
3
+ const PHI_PUBLIC_AREA_MASK = resolvePhiCmsAreaMask("public");
4
+ /**
5
+ * Which of the Theme's Page insets a Page stands in by (THEME.md "Page padding"): Public's
6
+ * (`PHI_PAGE.padding`) for a Page of Public alone, the signed-in Areas' (`PHI_PAGE.signedInPadding`) for
7
+ * every other. Read where the base Pages are built and where a preset Page is checked, so both agree.
8
+ */
9
+ export function resolvePhiPageInset(areaMask) {
10
+ const mask = areaMask ?? 0;
11
+ const publicPage = mask !== 0 && (mask & ~PHI_PUBLIC_AREA_MASK) === 0;
12
+ return publicPage ? PHI_PAGE.padding : PHI_PAGE.signedInPadding;
13
+ }
14
+ /** The inset as the four sides of a Region's config. */
15
+ export function resolvePhiPageInsetConfig(areaMask) {
16
+ const inset = resolvePhiPageInset(areaMask);
17
+ return {
18
+ paddingTop: inset.top,
19
+ paddingRight: inset.right,
20
+ paddingBottom: inset.bottom,
21
+ paddingLeft: inset.left,
22
+ };
23
+ }
@@ -1,5 +1,6 @@
1
1
  import { PhiCmsRegionType } from "../constants/phi-cms";
2
2
  import { PHI_PAGE, PHI_SPACE } from "../theme/antd-css-var-contract";
3
+ import { resolvePhiPageInset } from "./page-inset";
3
4
  import { parsePhiCmsCarouselLayoutConfig, parsePhiCmsCollapsibleLayoutConfig, parsePhiCmsContentLayoutConfig, parsePhiCmsFlexLayoutConfig, parsePhiCmsFlexVerticalLayoutConfig, parsePhiCmsGridLayoutConfig, parsePhiCmsMasonryLayoutConfig, parsePhiCmsSplitCardLayoutConfig, parsePhiCmsStackLayoutConfig, parsePhiCmsThreeColumnLayoutConfig, } from "../types/cms-config";
4
5
  import { readPhiSurface } from "../types/surface";
5
6
  const SPACING_KEYS = ["padding", "paddingTop", "paddingRight", "paddingBottom", "paddingLeft", "gap"];
@@ -26,7 +27,8 @@ const LAYOUT_CONFIG_PARSERS = {
26
27
  * The Theme's Page inset (`PHI_PAGE.padding`, THEME.md "Page padding") is a step of the spacing scale per
27
28
  * side and screen, chosen by the Theme: a distance like any other, at the preset level.
28
29
  */
29
- const PAGE_INSET_REFERENCES = new Set(Object.values(PHI_PAGE.padding));
30
+ const PAGE_INSET_REFERENCES = new Set([...Object.values(PHI_PAGE.padding), ...Object.values(PHI_PAGE.signedInPadding)]);
31
+ const PAGE_INSET_SIDES = [["paddingTop", "top"], ["paddingRight", "right"], ["paddingBottom", "bottom"], ["paddingLeft", "left"]];
30
32
  function stepOf(value) {
31
33
  if (value === 0 || value === "0")
32
34
  return "none";
@@ -57,11 +59,16 @@ export function checkPhiPagePresetLayout(tree) {
57
59
  const regionConfig = (contentRegion?.config ?? {});
58
60
  const heroOverlap = heroRegion ? regionConfig.heroOverlap : undefined;
59
61
  if (contentRegion) {
60
- const edge = stepOf(regionConfig.padding);
61
- if (edge !== "md") {
62
+ /*
63
+ * The Page's edge is the Theme's, on all four sides: a number, or a step of the scale, would stay what
64
+ * it was the day the preset was written, whatever the Site's Theme says.
65
+ */
66
+ const inset = resolvePhiPageInset(tree.page?.areaMask);
67
+ const scope = inset === PHI_PAGE.padding ? "PHI_PAGE.padding" : "PHI_PAGE.signedInPadding";
68
+ if (PAGE_INSET_SIDES.some(([key, side]) => regionConfig[key] !== inset[side])) {
62
69
  findings.push({
63
70
  node: `region ${contentRegion.id}`,
64
- message: "The content Region is the Page's edge and states `padding: PHI_SPACE.md`.",
71
+ message: `The content Region is the Page's edge and states the Theme's inset on all four sides: \`paddingTop\` to \`paddingLeft\` from \`${scope}\`.`,
65
72
  });
66
73
  }
67
74
  if (heroOverlap != null && stepOf(heroOverlap) == null) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phis/ui",
3
- "version": "0.6.9",
3
+ "version": "0.6.10",
4
4
  "license": "Apache-2.0",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -91,8 +91,8 @@ export declare const PHI_LAYOUT: {
91
91
  readonly pageMax: 1220;
92
92
  readonly pagePadding: {
93
93
  readonly phone: "base";
94
- readonly tablet: "md";
95
- readonly desktop: "md";
94
+ readonly tablet: "base";
95
+ readonly desktop: "base";
96
96
  };
97
97
  readonly signedInPagePadding: {
98
98
  readonly phone: "sm";
@@ -144,15 +144,15 @@ export const PHI_LAYOUT = {
144
144
  * How far a Page's content stands in from the room it is given, by the screen it is drawn on: the
145
145
  * Shell's device bands on `phi-render-viewport` (styles/shell.css), a phone below 768, a tablet below
146
146
  * 1200, a desktop from there -- not the block profiles' 377 and 610, which measure room and would put
147
- * two phones of one class on opposite sides. Steps of the spacing scale, the same on all four sides; a
148
- * phone one step below the rest. The Theme's to decide, as `pageMax` is: a Page reads it as
149
- * `PHI_PAGE.padding`, and a Layout that states its own padding keeps it.
147
+ * two phones of one class on opposite sides. Steps of the spacing scale, the same on all four sides:
148
+ * `base` on every screen. A Site that wants more room states it in its Theme, as `pageMax` is the
149
+ * Theme's: a Page reads it as `PHI_PAGE.padding`, and a Layout that states its own padding keeps it.
150
150
  */
151
- pagePadding: { phone: "base", tablet: "md", desktop: "md" },
151
+ pagePadding: { phone: "base", tablet: "base", desktop: "base" },
152
152
  /*
153
153
  * The same inset in the signed-in Areas -- App and the staff Areas -- where a Page is a tool among the
154
- * Shell's navigation rather than a page to read: one step below Public, a phone again one below the
155
- * rest. The Theme's as well, read as `PHI_PAGE.signedInPadding`.
154
+ * Shell's navigation rather than a page to read: Public's step from a tablet on, a phone one below it.
155
+ * The Theme's as well, read as `PHI_PAGE.signedInPadding`.
156
156
  */
157
157
  signedInPagePadding: { phone: "sm", tablet: "base", desktop: "base" },
158
158
  /*