@guardian/stand 0.0.59 → 0.0.60

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 (25) hide show
  1. package/dist/HtmlPreviewLoader.cjs +7 -0
  2. package/dist/HtmlPreviewLoader.d.cts +4 -0
  3. package/dist/HtmlPreviewLoader.d.ts +4 -0
  4. package/dist/HtmlPreviewLoader.js +4 -0
  5. package/dist/components/HtmlPreviewLoader/HtmlPreview.cjs +99 -0
  6. package/dist/components/HtmlPreviewLoader/HtmlPreview.d.cts +19 -0
  7. package/dist/components/HtmlPreviewLoader/HtmlPreview.d.ts +19 -0
  8. package/dist/components/HtmlPreviewLoader/HtmlPreview.js +99 -0
  9. package/dist/components/HtmlPreviewLoader/HtmlPreviewLoader.cjs +27 -0
  10. package/dist/components/HtmlPreviewLoader/HtmlPreviewLoader.d.cts +6 -0
  11. package/dist/components/HtmlPreviewLoader/HtmlPreviewLoader.d.ts +6 -0
  12. package/dist/components/HtmlPreviewLoader/HtmlPreviewLoader.js +27 -0
  13. package/dist/components/HtmlPreviewLoader/styles.cjs +96 -0
  14. package/dist/components/HtmlPreviewLoader/styles.d.cts +8 -0
  15. package/dist/components/HtmlPreviewLoader/styles.d.ts +8 -0
  16. package/dist/components/HtmlPreviewLoader/styles.js +87 -0
  17. package/dist/components/HtmlPreviewLoader/types.d.cts +28 -0
  18. package/dist/components/HtmlPreviewLoader/types.d.ts +28 -0
  19. package/dist/styleD/build/css/component/htmlPreviewLoader.css +22 -0
  20. package/dist/styleD/build/css/component/previewFrame.css +10 -0
  21. package/dist/styleD/build/typescript/component/htmlPreviewLoader.cjs +30 -0
  22. package/dist/styleD/build/typescript/component/htmlPreviewLoader.d.cts +33 -0
  23. package/dist/styleD/build/typescript/component/htmlPreviewLoader.d.ts +33 -0
  24. package/dist/styleD/build/typescript/component/htmlPreviewLoader.js +30 -0
  25. package/package.json +11 -1
@@ -0,0 +1,7 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_htmlPreviewLoader = require("./styleD/build/typescript/component/htmlPreviewLoader.cjs");
3
+ const require_HtmlPreview = require("./components/HtmlPreviewLoader/HtmlPreview.cjs");
4
+ const require_HtmlPreviewLoader = require("./components/HtmlPreviewLoader/HtmlPreviewLoader.cjs");
5
+ exports.HtmlPreview = require_HtmlPreview.HtmlPreview;
6
+ exports.HtmlPreviewLoader = require_HtmlPreviewLoader.HtmlPreviewLoader;
7
+ exports.componentHtmlPreviewLoader = require_htmlPreviewLoader.componentHtmlPreviewLoader;
@@ -0,0 +1,4 @@
1
+ import { ComponentHtmlPreviewLoader, componentHtmlPreviewLoader } from "./styleD/build/typescript/component/htmlPreviewLoader.cjs";
2
+ import { HtmlPreviewLoader } from "./components/HtmlPreviewLoader/HtmlPreviewLoader.cjs";
3
+ import { HtmlPreview } from "./components/HtmlPreviewLoader/HtmlPreview.cjs";
4
+ export { type ComponentHtmlPreviewLoader, HtmlPreview, HtmlPreviewLoader, componentHtmlPreviewLoader };
@@ -0,0 +1,4 @@
1
+ import { ComponentHtmlPreviewLoader, componentHtmlPreviewLoader } from "./styleD/build/typescript/component/htmlPreviewLoader.js";
2
+ import { HtmlPreviewLoader } from "./components/HtmlPreviewLoader/HtmlPreviewLoader.js";
3
+ import { HtmlPreview } from "./components/HtmlPreviewLoader/HtmlPreview.js";
4
+ export { type ComponentHtmlPreviewLoader, HtmlPreview, HtmlPreviewLoader, componentHtmlPreviewLoader };
@@ -0,0 +1,4 @@
1
+ import { componentHtmlPreviewLoader } from "./styleD/build/typescript/component/htmlPreviewLoader.js";
2
+ import { HtmlPreview } from "./components/HtmlPreviewLoader/HtmlPreview.js";
3
+ import { HtmlPreviewLoader } from "./components/HtmlPreviewLoader/HtmlPreviewLoader.js";
4
+ export { HtmlPreview, HtmlPreviewLoader, componentHtmlPreviewLoader };
@@ -0,0 +1,99 @@
1
+ const require_mergeDeep = require("../../util/mergeDeep.cjs");
2
+ const require_Icon = require("../Icon/Icon.cjs");
3
+ const require_AlertBanner = require("../AlertBanner/AlertBanner.cjs");
4
+ const require_Button = require("../Button/Button.cjs");
5
+ const require_Typography = require("../Typography/Typography.cjs");
6
+ const require_RadioGroup = require("../RadioGroup/RadioGroup.cjs");
7
+ const require_styles = require("./styles.cjs");
8
+ let react = require("react");
9
+ let _emotion_react = require("@emotion/react");
10
+ let _emotion_react_jsx_runtime = require("@emotion/react/jsx-runtime");
11
+ //#region src/components/HtmlPreviewLoader/HtmlPreview.tsx
12
+ const defaultWidthOptions = [
13
+ 320,
14
+ 375,
15
+ 425,
16
+ 650
17
+ ];
18
+ const HtmlPreview = ({ html, isLoading = false, errorMessage, attemptLoad, minHeight = 600, title, widthOptions = defaultWidthOptions, defaultWidth = 425, frameBackground = "white", allowReloading = false, cssOverrides, theme }) => {
19
+ const mergedTheme = require_mergeDeep.mergeDeep(require_styles.defaultHtmlPreviewLoaderTheme, theme ?? {});
20
+ const [frameWidth, setFrameWidth] = (0, react.useState)(defaultWidth);
21
+ const showReloadButton = allowReloading && !errorMessage && !isLoading && !!attemptLoad;
22
+ return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)("div", {
23
+ css: [require_styles.htmlPreviewLoaderStyles(mergedTheme), cssOverrides],
24
+ children: [
25
+ /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)("header", {
26
+ css: require_styles.headerStyles(),
27
+ children: [typeof title === "string" ? /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(require_Typography.Typography, {
28
+ variant: "titleMd",
29
+ children: title
30
+ }) : title, widthOptions.length > 0 && /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(require_RadioGroup.RadioGroup, {
31
+ size: "sm",
32
+ label: "width",
33
+ orientation: "horizontal",
34
+ formInputContainerTheme: { shared: { container: {
35
+ width: "unset",
36
+ flexDirection: "row"
37
+ } } },
38
+ cssOverrides: (0, _emotion_react.css)({ alignItems: "center" }),
39
+ value: String(frameWidth),
40
+ onChange: (value) => setFrameWidth(Number(value)),
41
+ children: widthOptions.map((width, index) => /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)(require_RadioGroup.Radio, {
42
+ value: String(width),
43
+ children: [width, "px"]
44
+ }, index))
45
+ })]
46
+ }),
47
+ /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)("div", {
48
+ css: [require_styles.previewFrameStyle(mergedTheme), { minHeight }],
49
+ children: [html && /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("iframe", {
50
+ sandbox: "",
51
+ style: {
52
+ minWidth: frameWidth,
53
+ maxWidth: frameWidth,
54
+ background: frameBackground
55
+ },
56
+ css: require_styles.iframeStyle(isLoading || !!errorMessage),
57
+ title: "preview",
58
+ srcDoc: html
59
+ }), showReloadButton && /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
60
+ css: require_styles.reloadButtonStyle(mergedTheme),
61
+ children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(require_Button.Button, {
62
+ icon: "refresh",
63
+ size: "md",
64
+ variant: "primary",
65
+ onPress: attemptLoad,
66
+ children: "reload"
67
+ })
68
+ })]
69
+ }),
70
+ isLoading && /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
71
+ css: require_styles.centeredStyle(),
72
+ children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(require_Icon.Icon, {
73
+ css: require_styles.loadingIconStyle(mergedTheme),
74
+ symbol: "progress_activity",
75
+ cssOverrides: require_styles.spinAnimationStyle()
76
+ })
77
+ }),
78
+ errorMessage && /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
79
+ css: require_styles.centeredStyle(),
80
+ children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(require_AlertBanner.AlertBanner, {
81
+ showIcon: true,
82
+ level: "error",
83
+ children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)("div", {
84
+ css: require_styles.alertBannerContentsStyle(),
85
+ children: [errorMessage, attemptLoad && /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(require_Button.Button, {
86
+ icon: "refresh",
87
+ size: "sm",
88
+ variant: "secondary",
89
+ onPress: attemptLoad,
90
+ children: "retry"
91
+ })]
92
+ })
93
+ })
94
+ })
95
+ ]
96
+ });
97
+ };
98
+ //#endregion
99
+ exports.HtmlPreview = HtmlPreview;
@@ -0,0 +1,19 @@
1
+ import { HtmlPreviewProps } from "./types.cjs";
2
+
3
+ //#region src/components/HtmlPreviewLoader/HtmlPreview.d.ts
4
+ declare const HtmlPreview: ({
5
+ html,
6
+ isLoading,
7
+ errorMessage,
8
+ attemptLoad,
9
+ minHeight,
10
+ title,
11
+ widthOptions,
12
+ defaultWidth,
13
+ frameBackground,
14
+ allowReloading,
15
+ cssOverrides,
16
+ theme
17
+ }: HtmlPreviewProps) => import("@emotion/react/jsx-runtime").JSX.Element;
18
+ //#endregion
19
+ export { HtmlPreview };
@@ -0,0 +1,19 @@
1
+ import { HtmlPreviewProps } from "./types.js";
2
+
3
+ //#region src/components/HtmlPreviewLoader/HtmlPreview.d.ts
4
+ declare const HtmlPreview: ({
5
+ html,
6
+ isLoading,
7
+ errorMessage,
8
+ attemptLoad,
9
+ minHeight,
10
+ title,
11
+ widthOptions,
12
+ defaultWidth,
13
+ frameBackground,
14
+ allowReloading,
15
+ cssOverrides,
16
+ theme
17
+ }: HtmlPreviewProps) => import("@emotion/react/jsx-runtime").JSX.Element;
18
+ //#endregion
19
+ export { HtmlPreview };
@@ -0,0 +1,99 @@
1
+ import { mergeDeep } from "../../util/mergeDeep.js";
2
+ import { Icon } from "../Icon/Icon.js";
3
+ import { AlertBanner } from "../AlertBanner/AlertBanner.js";
4
+ import { Button } from "../Button/Button.js";
5
+ import { Typography } from "../Typography/Typography.js";
6
+ import { Radio, RadioGroup } from "../RadioGroup/RadioGroup.js";
7
+ import { alertBannerContentsStyle, centeredStyle, defaultHtmlPreviewLoaderTheme, headerStyles, htmlPreviewLoaderStyles, iframeStyle, loadingIconStyle, previewFrameStyle, reloadButtonStyle, spinAnimationStyle } from "./styles.js";
8
+ import { useState } from "react";
9
+ import { css } from "@emotion/react";
10
+ import { jsx, jsxs } from "@emotion/react/jsx-runtime";
11
+ //#region src/components/HtmlPreviewLoader/HtmlPreview.tsx
12
+ const defaultWidthOptions = [
13
+ 320,
14
+ 375,
15
+ 425,
16
+ 650
17
+ ];
18
+ const HtmlPreview = ({ html, isLoading = false, errorMessage, attemptLoad, minHeight = 600, title, widthOptions = defaultWidthOptions, defaultWidth = 425, frameBackground = "white", allowReloading = false, cssOverrides, theme }) => {
19
+ const mergedTheme = mergeDeep(defaultHtmlPreviewLoaderTheme, theme ?? {});
20
+ const [frameWidth, setFrameWidth] = useState(defaultWidth);
21
+ const showReloadButton = allowReloading && !errorMessage && !isLoading && !!attemptLoad;
22
+ return /* @__PURE__ */ jsxs("div", {
23
+ css: [htmlPreviewLoaderStyles(mergedTheme), cssOverrides],
24
+ children: [
25
+ /* @__PURE__ */ jsxs("header", {
26
+ css: headerStyles(),
27
+ children: [typeof title === "string" ? /* @__PURE__ */ jsx(Typography, {
28
+ variant: "titleMd",
29
+ children: title
30
+ }) : title, widthOptions.length > 0 && /* @__PURE__ */ jsx(RadioGroup, {
31
+ size: "sm",
32
+ label: "width",
33
+ orientation: "horizontal",
34
+ formInputContainerTheme: { shared: { container: {
35
+ width: "unset",
36
+ flexDirection: "row"
37
+ } } },
38
+ cssOverrides: css({ alignItems: "center" }),
39
+ value: String(frameWidth),
40
+ onChange: (value) => setFrameWidth(Number(value)),
41
+ children: widthOptions.map((width, index) => /* @__PURE__ */ jsxs(Radio, {
42
+ value: String(width),
43
+ children: [width, "px"]
44
+ }, index))
45
+ })]
46
+ }),
47
+ /* @__PURE__ */ jsxs("div", {
48
+ css: [previewFrameStyle(mergedTheme), { minHeight }],
49
+ children: [html && /* @__PURE__ */ jsx("iframe", {
50
+ sandbox: "",
51
+ style: {
52
+ minWidth: frameWidth,
53
+ maxWidth: frameWidth,
54
+ background: frameBackground
55
+ },
56
+ css: iframeStyle(isLoading || !!errorMessage),
57
+ title: "preview",
58
+ srcDoc: html
59
+ }), showReloadButton && /* @__PURE__ */ jsx("div", {
60
+ css: reloadButtonStyle(mergedTheme),
61
+ children: /* @__PURE__ */ jsx(Button, {
62
+ icon: "refresh",
63
+ size: "md",
64
+ variant: "primary",
65
+ onPress: attemptLoad,
66
+ children: "reload"
67
+ })
68
+ })]
69
+ }),
70
+ isLoading && /* @__PURE__ */ jsx("div", {
71
+ css: centeredStyle(),
72
+ children: /* @__PURE__ */ jsx(Icon, {
73
+ css: loadingIconStyle(mergedTheme),
74
+ symbol: "progress_activity",
75
+ cssOverrides: spinAnimationStyle()
76
+ })
77
+ }),
78
+ errorMessage && /* @__PURE__ */ jsx("div", {
79
+ css: centeredStyle(),
80
+ children: /* @__PURE__ */ jsx(AlertBanner, {
81
+ showIcon: true,
82
+ level: "error",
83
+ children: /* @__PURE__ */ jsxs("div", {
84
+ css: alertBannerContentsStyle(),
85
+ children: [errorMessage, attemptLoad && /* @__PURE__ */ jsx(Button, {
86
+ icon: "refresh",
87
+ size: "sm",
88
+ variant: "secondary",
89
+ onPress: attemptLoad,
90
+ children: "retry"
91
+ })]
92
+ })
93
+ })
94
+ })
95
+ ]
96
+ });
97
+ };
98
+ //#endregion
99
+ export { HtmlPreview };
@@ -0,0 +1,27 @@
1
+ const require_HtmlPreview = require("./HtmlPreview.cjs");
2
+ let react = require("react");
3
+ let _emotion_react_jsx_runtime = require("@emotion/react/jsx-runtime");
4
+ //#region src/components/HtmlPreviewLoader/HtmlPreviewLoader.tsx
5
+ const HtmlPreviewLoader = (props) => {
6
+ const { fetchHtml, ...rest } = props;
7
+ const [html, setHtml] = (0, react.useState)();
8
+ const [error, setError] = (0, react.useState)();
9
+ const [isLoading, setIsLoading] = (0, react.useState)(true);
10
+ const attemptLoad = (0, react.useCallback)(() => {
11
+ setIsLoading(true);
12
+ setError(void 0);
13
+ fetchHtml().then(setHtml).catch(setError).finally(() => setIsLoading(false));
14
+ }, [fetchHtml]);
15
+ (0, react.useEffect)(() => {
16
+ attemptLoad();
17
+ }, [attemptLoad]);
18
+ return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(require_HtmlPreview.HtmlPreview, {
19
+ html,
20
+ isLoading,
21
+ errorMessage: error ? "failed to load" : void 0,
22
+ attemptLoad,
23
+ ...rest
24
+ });
25
+ };
26
+ //#endregion
27
+ exports.HtmlPreviewLoader = HtmlPreviewLoader;
@@ -0,0 +1,6 @@
1
+ import { HtmlPreviewLoaderProps } from "./types.cjs";
2
+
3
+ //#region src/components/HtmlPreviewLoader/HtmlPreviewLoader.d.ts
4
+ declare const HtmlPreviewLoader: (props: HtmlPreviewLoaderProps) => import("@emotion/react/jsx-runtime").JSX.Element;
5
+ //#endregion
6
+ export { HtmlPreviewLoader };
@@ -0,0 +1,6 @@
1
+ import { HtmlPreviewLoaderProps } from "./types.js";
2
+
3
+ //#region src/components/HtmlPreviewLoader/HtmlPreviewLoader.d.ts
4
+ declare const HtmlPreviewLoader: (props: HtmlPreviewLoaderProps) => import("@emotion/react/jsx-runtime").JSX.Element;
5
+ //#endregion
6
+ export { HtmlPreviewLoader };
@@ -0,0 +1,27 @@
1
+ import { HtmlPreview } from "./HtmlPreview.js";
2
+ import { useCallback, useEffect, useState } from "react";
3
+ import { jsx } from "@emotion/react/jsx-runtime";
4
+ //#region src/components/HtmlPreviewLoader/HtmlPreviewLoader.tsx
5
+ const HtmlPreviewLoader = (props) => {
6
+ const { fetchHtml, ...rest } = props;
7
+ const [html, setHtml] = useState();
8
+ const [error, setError] = useState();
9
+ const [isLoading, setIsLoading] = useState(true);
10
+ const attemptLoad = useCallback(() => {
11
+ setIsLoading(true);
12
+ setError(void 0);
13
+ fetchHtml().then(setHtml).catch(setError).finally(() => setIsLoading(false));
14
+ }, [fetchHtml]);
15
+ useEffect(() => {
16
+ attemptLoad();
17
+ }, [attemptLoad]);
18
+ return /* @__PURE__ */ jsx(HtmlPreview, {
19
+ html,
20
+ isLoading,
21
+ errorMessage: error ? "failed to load" : void 0,
22
+ attemptLoad,
23
+ ...rest
24
+ });
25
+ };
26
+ //#endregion
27
+ export { HtmlPreviewLoader };
@@ -0,0 +1,96 @@
1
+ const require_htmlPreviewLoader = require("../../styleD/build/typescript/component/htmlPreviewLoader.cjs");
2
+ let _emotion_react = require("@emotion/react");
3
+ //#region src/components/HtmlPreviewLoader/styles.ts
4
+ const defaultHtmlPreviewLoaderTheme = require_htmlPreviewLoader.componentHtmlPreviewLoader;
5
+ const htmlPreviewLoaderStyles = (theme) => {
6
+ return _emotion_react.css`
7
+ background-color: ${theme.shared.color.background};
8
+ color: ${theme.shared.color.text};
9
+ padding-top: ${theme.paddingTop};
10
+ padding-bottom: ${theme.paddingBottom};
11
+ padding-left: ${theme.paddingLeft};
12
+ padding-right: ${theme.paddingRight};
13
+ position: relative;
14
+ `;
15
+ };
16
+ const headerStyles = () => {
17
+ return _emotion_react.css`
18
+ display: flex;
19
+ align-items: center;
20
+ flex-wrap: wrap;
21
+ justify-content: space-between;
22
+ `;
23
+ };
24
+ const previewFrameStyle = ({ previewFrame }) => {
25
+ return _emotion_react.css`
26
+ border-color: ${previewFrame.borderColor};
27
+ border-style: ${previewFrame.borderStyle};
28
+ border-width: ${previewFrame.borderWidth};
29
+ background-color: ${previewFrame.backgroundColor};
30
+ padding-top: ${previewFrame.paddingTop};
31
+ padding-bottom: ${previewFrame.paddingBottom};
32
+ padding-left: ${previewFrame.paddingLeft};
33
+ padding-right: ${previewFrame.paddingRight};
34
+ width: 100%;
35
+ display: flex;
36
+ justify-content: center;
37
+ position: relative;
38
+ `;
39
+ };
40
+ const iframeStyle = (isNotLoaded) => {
41
+ return _emotion_react.css`
42
+ border: none;
43
+ transition: 'filter 0.25s';
44
+ ${isNotLoaded ? `
45
+ filter: blur(3px);
46
+ pointer-events: none;
47
+ ` : ""}
48
+ `;
49
+ };
50
+ const reloadButtonStyle = ({ previewFrame }) => {
51
+ return _emotion_react.css`
52
+ position: absolute;
53
+ bottom: ${previewFrame.paddingBottom};
54
+ right: ${previewFrame.paddingRight};
55
+ `;
56
+ };
57
+ const loadingIconStyle = ({ loadingIcon }) => {
58
+ return _emotion_react.css`
59
+ font-size: ${loadingIcon.size};
60
+ color: ${loadingIcon.color};
61
+ `;
62
+ };
63
+ const spinAnimationStyle = () => {
64
+ return _emotion_react.css`
65
+ animation: ${(0, _emotion_react.keyframes)({
66
+ from: { transform: "rotate(0deg)" },
67
+ to: { transform: "rotate(360deg)" }
68
+ })} 1s linear infinite;
69
+ `;
70
+ };
71
+ const centeredStyle = () => {
72
+ return _emotion_react.css`
73
+ position: absolute;
74
+ top: 50%;
75
+ left: 50%;
76
+ transform: translateX(-50%) translateY(-50%);
77
+ `;
78
+ };
79
+ const alertBannerContentsStyle = () => {
80
+ return _emotion_react.css`
81
+ display: flex;
82
+ gap: 10;
83
+ align-items: center;
84
+ `;
85
+ };
86
+ //#endregion
87
+ exports.alertBannerContentsStyle = alertBannerContentsStyle;
88
+ exports.centeredStyle = centeredStyle;
89
+ exports.defaultHtmlPreviewLoaderTheme = defaultHtmlPreviewLoaderTheme;
90
+ exports.headerStyles = headerStyles;
91
+ exports.htmlPreviewLoaderStyles = htmlPreviewLoaderStyles;
92
+ exports.iframeStyle = iframeStyle;
93
+ exports.loadingIconStyle = loadingIconStyle;
94
+ exports.previewFrameStyle = previewFrameStyle;
95
+ exports.reloadButtonStyle = reloadButtonStyle;
96
+ exports.spinAnimationStyle = spinAnimationStyle;
@@ -0,0 +1,8 @@
1
+ import { Prettify } from "../../util/types.cjs";
2
+ import { ComponentHtmlPreviewLoader } from "../../styleD/build/typescript/component/htmlPreviewLoader.cjs";
3
+ import { SerializedStyles } from "@emotion/react";
4
+
5
+ //#region src/components/HtmlPreviewLoader/styles.d.ts
6
+ type HtmlPreviewLoaderTheme = Prettify<ComponentHtmlPreviewLoader>;
7
+ //#endregion
8
+ export { HtmlPreviewLoaderTheme };
@@ -0,0 +1,8 @@
1
+ import { Prettify } from "../../util/types.js";
2
+ import { ComponentHtmlPreviewLoader } from "../../styleD/build/typescript/component/htmlPreviewLoader.js";
3
+ import { SerializedStyles } from "@emotion/react";
4
+
5
+ //#region src/components/HtmlPreviewLoader/styles.d.ts
6
+ type HtmlPreviewLoaderTheme = Prettify<ComponentHtmlPreviewLoader>;
7
+ //#endregion
8
+ export { HtmlPreviewLoaderTheme };
@@ -0,0 +1,87 @@
1
+ import { componentHtmlPreviewLoader } from "../../styleD/build/typescript/component/htmlPreviewLoader.js";
2
+ import { css, keyframes } from "@emotion/react";
3
+ //#region src/components/HtmlPreviewLoader/styles.ts
4
+ const defaultHtmlPreviewLoaderTheme = componentHtmlPreviewLoader;
5
+ const htmlPreviewLoaderStyles = (theme) => {
6
+ return css`
7
+ background-color: ${theme.shared.color.background};
8
+ color: ${theme.shared.color.text};
9
+ padding-top: ${theme.paddingTop};
10
+ padding-bottom: ${theme.paddingBottom};
11
+ padding-left: ${theme.paddingLeft};
12
+ padding-right: ${theme.paddingRight};
13
+ position: relative;
14
+ `;
15
+ };
16
+ const headerStyles = () => {
17
+ return css`
18
+ display: flex;
19
+ align-items: center;
20
+ flex-wrap: wrap;
21
+ justify-content: space-between;
22
+ `;
23
+ };
24
+ const previewFrameStyle = ({ previewFrame }) => {
25
+ return css`
26
+ border-color: ${previewFrame.borderColor};
27
+ border-style: ${previewFrame.borderStyle};
28
+ border-width: ${previewFrame.borderWidth};
29
+ background-color: ${previewFrame.backgroundColor};
30
+ padding-top: ${previewFrame.paddingTop};
31
+ padding-bottom: ${previewFrame.paddingBottom};
32
+ padding-left: ${previewFrame.paddingLeft};
33
+ padding-right: ${previewFrame.paddingRight};
34
+ width: 100%;
35
+ display: flex;
36
+ justify-content: center;
37
+ position: relative;
38
+ `;
39
+ };
40
+ const iframeStyle = (isNotLoaded) => {
41
+ return css`
42
+ border: none;
43
+ transition: 'filter 0.25s';
44
+ ${isNotLoaded ? `
45
+ filter: blur(3px);
46
+ pointer-events: none;
47
+ ` : ""}
48
+ `;
49
+ };
50
+ const reloadButtonStyle = ({ previewFrame }) => {
51
+ return css`
52
+ position: absolute;
53
+ bottom: ${previewFrame.paddingBottom};
54
+ right: ${previewFrame.paddingRight};
55
+ `;
56
+ };
57
+ const loadingIconStyle = ({ loadingIcon }) => {
58
+ return css`
59
+ font-size: ${loadingIcon.size};
60
+ color: ${loadingIcon.color};
61
+ `;
62
+ };
63
+ const spinAnimationStyle = () => {
64
+ return css`
65
+ animation: ${keyframes({
66
+ from: { transform: "rotate(0deg)" },
67
+ to: { transform: "rotate(360deg)" }
68
+ })} 1s linear infinite;
69
+ `;
70
+ };
71
+ const centeredStyle = () => {
72
+ return css`
73
+ position: absolute;
74
+ top: 50%;
75
+ left: 50%;
76
+ transform: translateX(-50%) translateY(-50%);
77
+ `;
78
+ };
79
+ const alertBannerContentsStyle = () => {
80
+ return css`
81
+ display: flex;
82
+ gap: 10;
83
+ align-items: center;
84
+ `;
85
+ };
86
+ //#endregion
87
+ export { alertBannerContentsStyle, centeredStyle, defaultHtmlPreviewLoaderTheme, headerStyles, htmlPreviewLoaderStyles, iframeStyle, loadingIconStyle, previewFrameStyle, reloadButtonStyle, spinAnimationStyle };
@@ -0,0 +1,28 @@
1
+ import { DefaultProps } from "../../util/types.cjs";
2
+ import { HtmlPreviewLoaderTheme } from "./styles.cjs";
3
+ import { CSSProperties, ReactNode } from "react";
4
+
5
+ //#region src/components/HtmlPreviewLoader/types.d.ts
6
+ type CommonProps = {
7
+ minHeight?: number;
8
+ title: ReactNode;
9
+ widthOptions?: number[];
10
+ defaultWidth?: number;
11
+ frameBackground?: CSSProperties['background'];
12
+ allowReloading?: boolean;
13
+ };
14
+ type HtmlPreviewLoaderProps = DefaultProps<HtmlPreviewLoaderTheme> & CommonProps & {
15
+ fetchHtml: {
16
+ (): Promise<string>;
17
+ };
18
+ };
19
+ type HtmlPreviewProps = DefaultProps<HtmlPreviewLoaderTheme> & CommonProps & {
20
+ html?: string;
21
+ isLoading?: boolean;
22
+ errorMessage?: string;
23
+ attemptLoad?: {
24
+ (): void;
25
+ };
26
+ };
27
+ //#endregion
28
+ export { HtmlPreviewLoaderProps, HtmlPreviewProps };
@@ -0,0 +1,28 @@
1
+ import { DefaultProps } from "../../util/types.js";
2
+ import { HtmlPreviewLoaderTheme } from "./styles.js";
3
+ import { CSSProperties, ReactNode } from "react";
4
+
5
+ //#region src/components/HtmlPreviewLoader/types.d.ts
6
+ type CommonProps = {
7
+ minHeight?: number;
8
+ title: ReactNode;
9
+ widthOptions?: number[];
10
+ defaultWidth?: number;
11
+ frameBackground?: CSSProperties['background'];
12
+ allowReloading?: boolean;
13
+ };
14
+ type HtmlPreviewLoaderProps = DefaultProps<HtmlPreviewLoaderTheme> & CommonProps & {
15
+ fetchHtml: {
16
+ (): Promise<string>;
17
+ };
18
+ };
19
+ type HtmlPreviewProps = DefaultProps<HtmlPreviewLoaderTheme> & CommonProps & {
20
+ html?: string;
21
+ isLoading?: boolean;
22
+ errorMessage?: string;
23
+ attemptLoad?: {
24
+ (): void;
25
+ };
26
+ };
27
+ //#endregion
28
+ export { HtmlPreviewLoaderProps, HtmlPreviewProps };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Do not edit directly, this file was auto-generated.
3
+ */
4
+
5
+ :root {
6
+ --component-html-preview-loader-padding-top: 0px;
7
+ --component-html-preview-loader-padding-right: 0.5rem;
8
+ --component-html-preview-loader-padding-bottom: 0px;
9
+ --component-html-preview-loader-padding-left: 0.5rem;
10
+ --component-html-preview-loader-shared-color-background: #ffffff;
11
+ --component-html-preview-loader-shared-color-text: #000000;
12
+ --component-html-preview-loader-preview-frame-background-color: #ededed;
13
+ --component-html-preview-loader-preview-frame-border-width: 0.0625rem;
14
+ --component-html-preview-loader-preview-frame-border-style: solid;
15
+ --component-html-preview-loader-preview-frame-border-color: #545454;
16
+ --component-html-preview-loader-preview-frame-padding-top: 0.5rem;
17
+ --component-html-preview-loader-preview-frame-padding-right: 0.5rem;
18
+ --component-html-preview-loader-preview-frame-padding-bottom: 0.5rem;
19
+ --component-html-preview-loader-preview-frame-padding-left: 0.5rem;
20
+ --component-html-preview-loader-loading-icon-color: #8d8d8d;
21
+ --component-html-preview-loader-loading-icon-size: 3rem;
22
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Do not edit directly, this file was auto-generated.
3
+ */
4
+
5
+ :root {
6
+ --component-preview-frame-background-color: #545454;
7
+ --component-preview-frame-border-width: 0.0625rem;
8
+ --component-preview-frame-border-style: solid;
9
+ --component-preview-frame-border-color: #545454;
10
+ }
@@ -0,0 +1,30 @@
1
+ //#region src/styleD/build/typescript/component/htmlPreviewLoader.ts
2
+ /**
3
+ * Do not edit directly, this file was auto-generated.
4
+ */
5
+ const componentHtmlPreviewLoader = {
6
+ paddingTop: "0px",
7
+ paddingRight: "0.5rem",
8
+ paddingBottom: "0px",
9
+ paddingLeft: "0.5rem",
10
+ shared: { color: {
11
+ background: "#ffffff",
12
+ text: "#000000"
13
+ } },
14
+ previewFrame: {
15
+ backgroundColor: "#ededed",
16
+ borderWidth: "0.0625rem",
17
+ borderStyle: "solid",
18
+ borderColor: "#545454",
19
+ paddingTop: "0.5rem",
20
+ paddingRight: "0.5rem",
21
+ paddingBottom: "0.5rem",
22
+ paddingLeft: "0.5rem"
23
+ },
24
+ loadingIcon: {
25
+ color: "#8d8d8d",
26
+ size: "3rem"
27
+ }
28
+ };
29
+ //#endregion
30
+ exports.componentHtmlPreviewLoader = componentHtmlPreviewLoader;
@@ -0,0 +1,33 @@
1
+ //#region src/styleD/build/typescript/component/htmlPreviewLoader.d.ts
2
+ /**
3
+ * Do not edit directly, this file was auto-generated.
4
+ */
5
+ declare const componentHtmlPreviewLoader: {
6
+ paddingTop: string;
7
+ paddingRight: string;
8
+ paddingBottom: string;
9
+ paddingLeft: string;
10
+ shared: {
11
+ color: {
12
+ background: string;
13
+ text: string;
14
+ };
15
+ };
16
+ previewFrame: {
17
+ backgroundColor: string;
18
+ borderWidth: string;
19
+ borderStyle: string;
20
+ borderColor: string;
21
+ paddingTop: string;
22
+ paddingRight: string;
23
+ paddingBottom: string;
24
+ paddingLeft: string;
25
+ };
26
+ loadingIcon: {
27
+ color: string;
28
+ size: string;
29
+ };
30
+ };
31
+ type ComponentHtmlPreviewLoader = typeof componentHtmlPreviewLoader;
32
+ //#endregion
33
+ export { ComponentHtmlPreviewLoader, componentHtmlPreviewLoader };
@@ -0,0 +1,33 @@
1
+ //#region src/styleD/build/typescript/component/htmlPreviewLoader.d.ts
2
+ /**
3
+ * Do not edit directly, this file was auto-generated.
4
+ */
5
+ declare const componentHtmlPreviewLoader: {
6
+ paddingTop: string;
7
+ paddingRight: string;
8
+ paddingBottom: string;
9
+ paddingLeft: string;
10
+ shared: {
11
+ color: {
12
+ background: string;
13
+ text: string;
14
+ };
15
+ };
16
+ previewFrame: {
17
+ backgroundColor: string;
18
+ borderWidth: string;
19
+ borderStyle: string;
20
+ borderColor: string;
21
+ paddingTop: string;
22
+ paddingRight: string;
23
+ paddingBottom: string;
24
+ paddingLeft: string;
25
+ };
26
+ loadingIcon: {
27
+ color: string;
28
+ size: string;
29
+ };
30
+ };
31
+ type ComponentHtmlPreviewLoader = typeof componentHtmlPreviewLoader;
32
+ //#endregion
33
+ export { ComponentHtmlPreviewLoader, componentHtmlPreviewLoader };
@@ -0,0 +1,30 @@
1
+ //#region src/styleD/build/typescript/component/htmlPreviewLoader.ts
2
+ /**
3
+ * Do not edit directly, this file was auto-generated.
4
+ */
5
+ const componentHtmlPreviewLoader = {
6
+ paddingTop: "0px",
7
+ paddingRight: "0.5rem",
8
+ paddingBottom: "0px",
9
+ paddingLeft: "0.5rem",
10
+ shared: { color: {
11
+ background: "#ffffff",
12
+ text: "#000000"
13
+ } },
14
+ previewFrame: {
15
+ backgroundColor: "#ededed",
16
+ borderWidth: "0.0625rem",
17
+ borderStyle: "solid",
18
+ borderColor: "#545454",
19
+ paddingTop: "0.5rem",
20
+ paddingRight: "0.5rem",
21
+ paddingBottom: "0.5rem",
22
+ paddingLeft: "0.5rem"
23
+ },
24
+ loadingIcon: {
25
+ color: "#8d8d8d",
26
+ size: "3rem"
27
+ }
28
+ };
29
+ //#endregion
30
+ export { componentHtmlPreviewLoader };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guardian/stand",
3
- "version": "0.0.59",
3
+ "version": "0.0.60",
4
4
  "repository": {
5
5
  "url": "https://github.com/guardian/stand"
6
6
  },
@@ -327,6 +327,16 @@
327
327
  "default": "./dist/Tabs.cjs"
328
328
  }
329
329
  },
330
+ "./HtmlPreviewLoader": {
331
+ "import": {
332
+ "types": "./dist/HtmlPreviewLoader.d.ts",
333
+ "default": "./dist/HtmlPreviewLoader.js"
334
+ },
335
+ "require": {
336
+ "types": "./dist/HtmlPreviewLoader.d.cts",
337
+ "default": "./dist/HtmlPreviewLoader.cjs"
338
+ }
339
+ },
330
340
  "./utils": {
331
341
  "import": {
332
342
  "types": "./dist/utils.d.ts",