@dbcdk/react-components 0.0.154 → 0.0.156
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.
|
@@ -15,13 +15,16 @@ function getMaxWidthClass(value, styles2) {
|
|
|
15
15
|
return styles2.maxWidthMd;
|
|
16
16
|
}
|
|
17
17
|
const VALID_ENVIRONMENTS = ["production", "staging", "test"];
|
|
18
|
+
const ENVIRONMENT_ALIASES = { prod: "production" };
|
|
18
19
|
function resolveEnvBanner(environment, customEnv, customEnvSeverity) {
|
|
20
|
+
var _a;
|
|
19
21
|
if (customEnv != null && customEnvSeverity != null) {
|
|
20
22
|
return /* @__PURE__ */ jsxRuntime.jsx(EnvironmentBanner.EnvironmentBanner, { customLabel: customEnv, customSeverity: customEnvSeverity });
|
|
21
23
|
}
|
|
22
24
|
const normalised = environment == null ? void 0 : environment.toLowerCase();
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
const resolved = normalised != null ? (_a = ENVIRONMENT_ALIASES[normalised]) != null ? _a : normalised : void 0;
|
|
26
|
+
if (resolved != null && VALID_ENVIRONMENTS.includes(resolved)) {
|
|
27
|
+
return /* @__PURE__ */ jsxRuntime.jsx(EnvironmentBanner.EnvironmentBanner, { environment: resolved });
|
|
25
28
|
}
|
|
26
29
|
return null;
|
|
27
30
|
}
|
|
@@ -11,7 +11,8 @@ export interface PageLayoutProps extends PropsWithChildren {
|
|
|
11
11
|
containScrolling?: boolean;
|
|
12
12
|
orientation?: Orientation;
|
|
13
13
|
/** Pass a deployment environment string (e.g. process.env.DEPLOYMENT_ENV).
|
|
14
|
-
* Renders a banner for 'production', 'staging', or 'test'.
|
|
14
|
+
* Renders a banner for 'production', 'staging', or 'test'. 'prod' is accepted as an alias for
|
|
15
|
+
* 'production'. Ignored for unknown values or undefined. */
|
|
15
16
|
environment?: string;
|
|
16
17
|
/** Custom banner label — requires customEnvSeverity. */
|
|
17
18
|
customEnv?: string;
|
|
@@ -9,13 +9,16 @@ function getMaxWidthClass(value, styles2) {
|
|
|
9
9
|
return styles2.maxWidthMd;
|
|
10
10
|
}
|
|
11
11
|
const VALID_ENVIRONMENTS = ["production", "staging", "test"];
|
|
12
|
+
const ENVIRONMENT_ALIASES = { prod: "production" };
|
|
12
13
|
function resolveEnvBanner(environment, customEnv, customEnvSeverity) {
|
|
14
|
+
var _a;
|
|
13
15
|
if (customEnv != null && customEnvSeverity != null) {
|
|
14
16
|
return /* @__PURE__ */ jsx(EnvironmentBanner, { customLabel: customEnv, customSeverity: customEnvSeverity });
|
|
15
17
|
}
|
|
16
18
|
const normalised = environment == null ? void 0 : environment.toLowerCase();
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
const resolved = normalised != null ? (_a = ENVIRONMENT_ALIASES[normalised]) != null ? _a : normalised : void 0;
|
|
20
|
+
if (resolved != null && VALID_ENVIRONMENTS.includes(resolved)) {
|
|
21
|
+
return /* @__PURE__ */ jsx(EnvironmentBanner, { environment: resolved });
|
|
19
22
|
}
|
|
20
23
|
return null;
|
|
21
24
|
}
|
|
@@ -10,6 +10,12 @@
|
|
|
10
10
|
max-width: 100%;
|
|
11
11
|
display: grid;
|
|
12
12
|
gap: 0;
|
|
13
|
+
|
|
14
|
+
/* Banner height computed from its own tokens (not measured) — accurate for the
|
|
15
|
+
built-in EnvironmentBanner; off by the difference for a custom-height banner. */
|
|
16
|
+
--page-layout-banner-height: calc(
|
|
17
|
+
var(--spacing-2xs) * 2 + var(--font-size-md) * var(--line-height-normal)
|
|
18
|
+
);
|
|
13
19
|
}
|
|
14
20
|
|
|
15
21
|
/* Viewport handling:
|
|
@@ -44,38 +50,92 @@
|
|
|
44
50
|
flex: 0 0 auto;
|
|
45
51
|
}
|
|
46
52
|
|
|
47
|
-
/*
|
|
48
|
-
.
|
|
53
|
+
/* Keep the banner visible while scrolling instead of it scrolling away; header and
|
|
54
|
+
sidebar stick right below it (see their top offsets further down). */
|
|
55
|
+
.documentScrolling .banner {
|
|
56
|
+
position: sticky;
|
|
57
|
+
top: 0;
|
|
58
|
+
z-index: calc(var(--z-sticky) + 1);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/* Give the banner its natural height, then the rest to the sidebar+main row (the
|
|
62
|
+
`1fr` row grows beyond it if content needs more — the CSS-grid sticky-footer trick). */
|
|
63
|
+
.hasBanner {
|
|
49
64
|
grid-template-rows: auto 1fr;
|
|
50
65
|
}
|
|
51
66
|
|
|
67
|
+
/* documentScrolling only has `min-height` (so long content can still grow the
|
|
68
|
+
page), which leaves the grid container's own block-size indefinite — and an
|
|
69
|
+
indefinite container makes the `1fr` row above size itself from its content
|
|
70
|
+
(i.e. from the sidebar's own capped height below) instead of from real
|
|
71
|
+
leftover viewport space. Any drift between --page-layout-banner-height's
|
|
72
|
+
estimate and the banner's real rendered height then inflated the whole page,
|
|
73
|
+
but only once the sidenav's content was tall enough to hit that cap — giving
|
|
74
|
+
this one combination a real, definite block-size makes the `1fr` row's size
|
|
75
|
+
come from the banner's actual rendered height, so the estimate is only ever
|
|
76
|
+
used below as a cap, never as the page's actual size. */
|
|
77
|
+
.documentScrolling.vertical.hasBanner {
|
|
78
|
+
height: 100vh;
|
|
79
|
+
height: 100dvh;
|
|
80
|
+
}
|
|
81
|
+
|
|
52
82
|
/* Sidebar */
|
|
53
83
|
.sidebar {
|
|
54
84
|
min-width: 0;
|
|
85
|
+
min-block-size: 0; /* CRITICAL: else a tall sidenav grows the grid row instead of scrolling */
|
|
55
86
|
overflow: hidden;
|
|
56
87
|
background: var(--color-bg-surface);
|
|
88
|
+
|
|
89
|
+
/* Hug the sidebar's own content width instead of stretching to fill the "auto"
|
|
90
|
+
column — some browsers size that column wider than the content once a
|
|
91
|
+
descendant scrollbar reserves space, leaving a visible gap otherwise. */
|
|
92
|
+
justify-self: start;
|
|
57
93
|
}
|
|
58
94
|
|
|
95
|
+
/* The Sidebar/SidebarContainer inside already owns its own internal scrolling
|
|
96
|
+
(its root is height:100%; overflow:auto). This wrapper only needs to cap the
|
|
97
|
+
available height — if it *also* reserves its own scrollbar, that scrollbar's
|
|
98
|
+
width gets folded into this box's max-content size (used by `justify-self:
|
|
99
|
+
start` above), making it a scrollbar's-width wider than the fixed-width
|
|
100
|
+
Sidebar inside and leaving a gap on the right edge. */
|
|
59
101
|
.containScrolling .sidebar {
|
|
60
|
-
overflow:
|
|
61
|
-
-webkit-overflow-scrolling: touch;
|
|
102
|
+
overflow: hidden;
|
|
62
103
|
}
|
|
63
104
|
|
|
64
|
-
/*
|
|
65
|
-
|
|
105
|
+
/* Pin the sidebar to the viewport and let it scroll independently of the document.
|
|
106
|
+
max-block-size is a hard cap: a grid row's "auto" size still grows to fit a long
|
|
107
|
+
sidenav's content otherwise (min-block-size: 0 alone doesn't stop that). */
|
|
66
108
|
.documentScrolling.vertical .sidebar {
|
|
67
109
|
position: sticky;
|
|
68
110
|
top: 0;
|
|
111
|
+
max-block-size: 100vh;
|
|
112
|
+
max-block-size: 100dvh;
|
|
113
|
+
/* See the .containScrolling .sidebar comment above — same double-scrollbar
|
|
114
|
+
reasoning applies here. */
|
|
115
|
+
overflow: hidden;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/* Leave room for the banner's height, and stick below it instead of at top:0 so it
|
|
119
|
+
doesn't slide up underneath the now-sticky banner while scrolling. */
|
|
120
|
+
.documentScrolling.vertical.hasBanner .sidebar {
|
|
121
|
+
top: var(--page-layout-banner-height);
|
|
122
|
+
max-block-size: calc(100vh - var(--page-layout-banner-height));
|
|
123
|
+
max-block-size: calc(100dvh - var(--page-layout-banner-height));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/* Without a banner, the sidebar is the grid's only row (sizes to content, doesn't
|
|
127
|
+
stretch), so it needs an explicit height. With a banner, it stretches to fill the
|
|
128
|
+
`1fr` row instead (see .hasBanner above). */
|
|
129
|
+
.documentScrolling.vertical:not(.hasBanner) .sidebar {
|
|
69
130
|
align-self: start;
|
|
70
131
|
block-size: 100vh;
|
|
71
132
|
block-size: 100dvh;
|
|
72
|
-
overflow: auto;
|
|
73
|
-
-webkit-overflow-scrolling: touch;
|
|
74
133
|
}
|
|
75
134
|
|
|
76
|
-
/* In horizontal orientation, sidebar becomes a top block if used */
|
|
135
|
+
/* In horizontal orientation, sidebar becomes a full-width top block if used */
|
|
77
136
|
.horizontal .sidebar {
|
|
78
137
|
grid-column: 1 / -1;
|
|
138
|
+
justify-self: stretch;
|
|
79
139
|
border-right: none;
|
|
80
140
|
border-bottom: var(--border-width-thin) solid var(--color-border-subtle);
|
|
81
141
|
}
|
|
@@ -113,6 +173,11 @@
|
|
|
113
173
|
z-index: var(--z-sticky);
|
|
114
174
|
}
|
|
115
175
|
|
|
176
|
+
/* Stick right below the (also sticky) banner instead of underneath it. */
|
|
177
|
+
.documentScrolling.hasBanner .header {
|
|
178
|
+
top: var(--page-layout-banner-height);
|
|
179
|
+
}
|
|
180
|
+
|
|
116
181
|
.hero {
|
|
117
182
|
min-width: 0;
|
|
118
183
|
background: var(--color-bg-surface);
|