@dbcdk/react-components 0.0.126 → 0.0.128
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/environment-banner/EnvironmentBanner.d.ts +1 -2
- package/dist/components/page-layout/PageLayout.cjs +21 -4
- package/dist/components/page-layout/PageLayout.d.ts +8 -0
- package/dist/components/page-layout/PageLayout.js +21 -4
- package/dist/components/page-layout/PageLayout.module.css +4 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { JSX } from 'react';
|
|
2
2
|
import type { Severity } from '../../constants/severity.types';
|
|
3
|
-
type Environment = 'production' | 'staging' | 'test';
|
|
3
|
+
export type Environment = 'production' | 'staging' | 'test';
|
|
4
4
|
export type EnvironmentBannerProps = {
|
|
5
5
|
environment: Environment;
|
|
6
6
|
customLabel?: never;
|
|
@@ -11,4 +11,3 @@ export type EnvironmentBannerProps = {
|
|
|
11
11
|
customSeverity: Severity;
|
|
12
12
|
};
|
|
13
13
|
export declare function EnvironmentBanner(props: EnvironmentBannerProps): JSX.Element;
|
|
14
|
-
export {};
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var react = require('react');
|
|
5
|
+
var EnvironmentBanner = require('../../components/environment-banner/EnvironmentBanner');
|
|
5
6
|
var styles = require('./PageLayout.module.css');
|
|
6
7
|
|
|
7
8
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -13,6 +14,17 @@ function getMaxWidthClass(value, styles2) {
|
|
|
13
14
|
if (value === "sm") return styles2.maxWidthSm;
|
|
14
15
|
return styles2.maxWidthMd;
|
|
15
16
|
}
|
|
17
|
+
const VALID_ENVIRONMENTS = ["production", "staging", "test"];
|
|
18
|
+
function resolveEnvBanner(environment, customEnv, customEnvSeverity) {
|
|
19
|
+
if (customEnv != null && customEnvSeverity != null) {
|
|
20
|
+
return /* @__PURE__ */ jsxRuntime.jsx(EnvironmentBanner.EnvironmentBanner, { customLabel: customEnv, customSeverity: customEnvSeverity });
|
|
21
|
+
}
|
|
22
|
+
const normalised = environment == null ? void 0 : environment.toLowerCase();
|
|
23
|
+
if (normalised != null && VALID_ENVIRONMENTS.includes(normalised)) {
|
|
24
|
+
return /* @__PURE__ */ jsxRuntime.jsx(EnvironmentBanner.EnvironmentBanner, { environment: normalised });
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
16
28
|
function getSlotName(el) {
|
|
17
29
|
var _a;
|
|
18
30
|
const t = el.type;
|
|
@@ -71,19 +83,24 @@ PageLayoutFooter.__PAGE_LAYOUT_SLOT__ = "Footer";
|
|
|
71
83
|
const PageLayoutBase = ({
|
|
72
84
|
children,
|
|
73
85
|
containScrolling = false,
|
|
74
|
-
orientation = "vertical"
|
|
86
|
+
orientation = "vertical",
|
|
87
|
+
environment,
|
|
88
|
+
customEnv,
|
|
89
|
+
customEnvSeverity
|
|
75
90
|
}) => {
|
|
76
|
-
var _a;
|
|
91
|
+
var _a, _b;
|
|
77
92
|
const { slots, rest } = splitSlots(children);
|
|
93
|
+
const envBanner = resolveEnvBanner(environment, customEnv, customEnvSeverity);
|
|
78
94
|
const content = (_a = slots.Content) != null ? _a : rest.length ? /* @__PURE__ */ jsxRuntime.jsx(PageLayoutContent, { maxWidth: "md", children: rest }) : void 0;
|
|
79
95
|
const rootClass = [
|
|
80
96
|
styles__default.default.root,
|
|
81
97
|
orientation === "vertical" ? styles__default.default.vertical : styles__default.default.horizontal,
|
|
82
98
|
containScrolling ? styles__default.default.containScrolling : styles__default.default.documentScrolling,
|
|
83
|
-
slots.Banner ? styles__default.default.hasBanner : ""
|
|
99
|
+
slots.Banner || envBanner ? styles__default.default.hasBanner : ""
|
|
84
100
|
].filter(Boolean).join(" ");
|
|
101
|
+
const banner = (_b = slots.Banner) != null ? _b : envBanner;
|
|
85
102
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: rootClass, children: [
|
|
86
|
-
|
|
103
|
+
banner ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles__default.default.banner, children: banner }) : null,
|
|
87
104
|
slots.Sidebar ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles__default.default.sidebar, children: slots.Sidebar }) : null,
|
|
88
105
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles__default.default.mainColumn, children: [
|
|
89
106
|
slots.Header ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles__default.default.header, children: slots.Header }) : null,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { FC, PropsWithChildren, ReactNode } from 'react';
|
|
2
|
+
import type { Severity } from '../../constants/severity.types';
|
|
2
3
|
type Orientation = 'vertical' | 'horizontal';
|
|
3
4
|
export type PageLayoutMaxWidth = boolean | 'sm' | 'md';
|
|
4
5
|
export interface PageLayoutProps extends PropsWithChildren {
|
|
@@ -9,6 +10,13 @@ export interface PageLayoutProps extends PropsWithChildren {
|
|
|
9
10
|
*/
|
|
10
11
|
containScrolling?: boolean;
|
|
11
12
|
orientation?: Orientation;
|
|
13
|
+
/** Pass a deployment environment string (e.g. process.env.DEPLOYMENT_ENV).
|
|
14
|
+
* Renders a banner for 'production', 'staging', or 'test'. Ignored for unknown values or undefined. */
|
|
15
|
+
environment?: string;
|
|
16
|
+
/** Custom banner label — requires customEnvSeverity. */
|
|
17
|
+
customEnv?: string;
|
|
18
|
+
/** Severity for the custom banner. */
|
|
19
|
+
customEnvSeverity?: Severity;
|
|
12
20
|
}
|
|
13
21
|
export interface PageLayoutHeaderProps {
|
|
14
22
|
maxWidth?: PageLayoutMaxWidth;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import { Children, isValidElement } from 'react';
|
|
3
|
+
import { EnvironmentBanner } from '../../components/environment-banner/EnvironmentBanner';
|
|
3
4
|
import styles from './PageLayout.module.css';
|
|
4
5
|
|
|
5
6
|
function getMaxWidthClass(value, styles2) {
|
|
@@ -7,6 +8,17 @@ function getMaxWidthClass(value, styles2) {
|
|
|
7
8
|
if (value === "sm") return styles2.maxWidthSm;
|
|
8
9
|
return styles2.maxWidthMd;
|
|
9
10
|
}
|
|
11
|
+
const VALID_ENVIRONMENTS = ["production", "staging", "test"];
|
|
12
|
+
function resolveEnvBanner(environment, customEnv, customEnvSeverity) {
|
|
13
|
+
if (customEnv != null && customEnvSeverity != null) {
|
|
14
|
+
return /* @__PURE__ */ jsx(EnvironmentBanner, { customLabel: customEnv, customSeverity: customEnvSeverity });
|
|
15
|
+
}
|
|
16
|
+
const normalised = environment == null ? void 0 : environment.toLowerCase();
|
|
17
|
+
if (normalised != null && VALID_ENVIRONMENTS.includes(normalised)) {
|
|
18
|
+
return /* @__PURE__ */ jsx(EnvironmentBanner, { environment: normalised });
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
10
22
|
function getSlotName(el) {
|
|
11
23
|
var _a;
|
|
12
24
|
const t = el.type;
|
|
@@ -65,19 +77,24 @@ PageLayoutFooter.__PAGE_LAYOUT_SLOT__ = "Footer";
|
|
|
65
77
|
const PageLayoutBase = ({
|
|
66
78
|
children,
|
|
67
79
|
containScrolling = false,
|
|
68
|
-
orientation = "vertical"
|
|
80
|
+
orientation = "vertical",
|
|
81
|
+
environment,
|
|
82
|
+
customEnv,
|
|
83
|
+
customEnvSeverity
|
|
69
84
|
}) => {
|
|
70
|
-
var _a;
|
|
85
|
+
var _a, _b;
|
|
71
86
|
const { slots, rest } = splitSlots(children);
|
|
87
|
+
const envBanner = resolveEnvBanner(environment, customEnv, customEnvSeverity);
|
|
72
88
|
const content = (_a = slots.Content) != null ? _a : rest.length ? /* @__PURE__ */ jsx(PageLayoutContent, { maxWidth: "md", children: rest }) : void 0;
|
|
73
89
|
const rootClass = [
|
|
74
90
|
styles.root,
|
|
75
91
|
orientation === "vertical" ? styles.vertical : styles.horizontal,
|
|
76
92
|
containScrolling ? styles.containScrolling : styles.documentScrolling,
|
|
77
|
-
slots.Banner ? styles.hasBanner : ""
|
|
93
|
+
slots.Banner || envBanner ? styles.hasBanner : ""
|
|
78
94
|
].filter(Boolean).join(" ");
|
|
95
|
+
const banner = (_b = slots.Banner) != null ? _b : envBanner;
|
|
79
96
|
return /* @__PURE__ */ jsxs("div", { className: rootClass, children: [
|
|
80
|
-
|
|
97
|
+
banner ? /* @__PURE__ */ jsx("div", { className: styles.banner, children: banner }) : null,
|
|
81
98
|
slots.Sidebar ? /* @__PURE__ */ jsx("div", { className: styles.sidebar, children: slots.Sidebar }) : null,
|
|
82
99
|
/* @__PURE__ */ jsxs("div", { className: styles.mainColumn, children: [
|
|
83
100
|
slots.Header ? /* @__PURE__ */ jsx("div", { className: styles.header, children: slots.Header }) : null,
|