@guardian/stand 0.0.35 → 0.0.36

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 (35) hide show
  1. package/dist/components/grid/Grid.cjs +37 -0
  2. package/dist/components/grid/Grid.js +14 -0
  3. package/dist/components/grid/styles.cjs +106 -0
  4. package/dist/components/grid/styles.js +98 -0
  5. package/dist/components/layout/Layout.cjs +114 -0
  6. package/dist/components/layout/Layout.js +83 -0
  7. package/dist/components/layout/styles.cjs +92 -0
  8. package/dist/components/layout/styles.js +83 -0
  9. package/dist/grid.cjs +10 -0
  10. package/dist/grid.js +2 -0
  11. package/dist/index.cjs +4 -0
  12. package/dist/index.js +2 -0
  13. package/dist/layout.cjs +10 -0
  14. package/dist/layout.js +2 -0
  15. package/dist/styleD/build/css/component/grid.css +14 -0
  16. package/dist/styleD/build/css/component/layout.css +30 -0
  17. package/dist/styleD/build/typescript/component/grid.cjs +16 -0
  18. package/dist/styleD/build/typescript/component/grid.js +14 -0
  19. package/dist/styleD/build/typescript/component/layout.cjs +48 -0
  20. package/dist/styleD/build/typescript/component/layout.js +46 -0
  21. package/dist/types/components/grid/Grid.d.ts +3 -0
  22. package/dist/types/components/grid/sandbox.d.ts +5 -0
  23. package/dist/types/components/grid/styles.d.ts +11 -0
  24. package/dist/types/components/grid/styles.test.d.ts +1 -0
  25. package/dist/types/components/grid/types.d.ts +25 -0
  26. package/dist/types/components/layout/Layout.d.ts +19 -0
  27. package/dist/types/components/layout/sandbox.d.ts +5 -0
  28. package/dist/types/components/layout/styles.d.ts +16 -0
  29. package/dist/types/components/layout/types.d.ts +20 -0
  30. package/dist/types/grid.d.ts +20 -0
  31. package/dist/types/index.d.ts +4 -0
  32. package/dist/types/layout.d.ts +20 -0
  33. package/dist/types/styleD/build/typescript/component/grid.d.ts +16 -0
  34. package/dist/types/styleD/build/typescript/component/layout.d.ts +48 -0
  35. package/package.json +20 -2
@@ -0,0 +1,37 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('@emotion/react/jsx-runtime');
4
+ var mergeDeep = require('../../util/mergeDeep.cjs');
5
+ var styles = require('./styles.cjs');
6
+
7
+ function Grid({
8
+ children,
9
+ theme = {},
10
+ cssOverrides,
11
+ as: Component = "div",
12
+ ...props
13
+ }) {
14
+ const mergedTheme = mergeDeep.mergeDeep(styles.defaultGridTheme, theme);
15
+ return /* @__PURE__ */ jsxRuntime.jsx(Component, { css: [styles.gridStyles(mergedTheme), cssOverrides], ...props, children });
16
+ }
17
+ function Item({
18
+ children,
19
+ theme = {},
20
+ cssOverrides,
21
+ size,
22
+ offset,
23
+ ...props
24
+ }) {
25
+ const mergedTheme = mergeDeep.mergeDeep(styles.defaultGridTheme, theme);
26
+ return /* @__PURE__ */ jsxRuntime.jsx(
27
+ "div",
28
+ {
29
+ css: [styles.itemStyles(mergedTheme, { size, offset }), cssOverrides],
30
+ ...props,
31
+ children
32
+ }
33
+ );
34
+ }
35
+
36
+ exports.Grid = Grid;
37
+ exports.Item = Item;
@@ -0,0 +1,14 @@
1
+ import { jsx } from '@emotion/react/jsx-runtime';
2
+ import { mergeDeep } from '../../util/mergeDeep.js';
3
+ import { gridStyles, itemStyles, defaultGridTheme } from './styles.js';
4
+
5
+ function Grid({ children, theme = {}, cssOverrides, as: Component = "div", ...props }) {
6
+ const mergedTheme = mergeDeep(defaultGridTheme, theme);
7
+ return jsx(Component, { css: [gridStyles(mergedTheme), cssOverrides], ...props, children });
8
+ }
9
+ function Item({ children, theme = {}, cssOverrides, size, offset, ...props }) {
10
+ const mergedTheme = mergeDeep(defaultGridTheme, theme);
11
+ return jsx("div", { css: [itemStyles(mergedTheme, { size, offset }), cssOverrides], ...props, children });
12
+ }
13
+
14
+ export { Grid, Item };
@@ -0,0 +1,106 @@
1
+ 'use strict';
2
+
3
+ var react = require('@emotion/react');
4
+ var grid = require('../../styleD/build/typescript/component/grid.cjs');
5
+ var mq = require('../../styleD/utils/semantic/mq.cjs');
6
+
7
+ const defaultGridTheme = grid.componentGrid;
8
+ const isResponsiveGridSize = (size) => typeof size === "object";
9
+ const isResponsiveOffset = (offset) => typeof offset === "object";
10
+ const clampToColumns = (value, columns) => Math.max(0, Math.min(value, columns));
11
+ const numericOffsetMargin = (offset, theme) => `calc(((100% - (${theme.shared.columns} - 1) * ${theme.shared.gap}) * ${offset} / ${theme.shared.columns}) + ${offset} * ${theme.shared.gap})`;
12
+ const numericSizeWidth = (size, theme) => `calc(((100% - (${theme.shared.columns} - 1) * ${theme.shared.gap}) * ${size} / ${theme.shared.columns}) + (${size} - 1) * ${theme.shared.gap})`;
13
+ const fixedSizeStyles = (size, theme) => {
14
+ if (size === "grow") {
15
+ return react.css`
16
+ flex-basis: 0;
17
+ flex-grow: 1;
18
+ max-width: 100%;
19
+ `;
20
+ }
21
+ if (size === "auto") {
22
+ return react.css`
23
+ flex-basis: auto;
24
+ flex-grow: 0;
25
+ flex-shrink: 0;
26
+ width: auto;
27
+ max-width: none;
28
+ `;
29
+ }
30
+ const clampedSize = clampToColumns(size, theme.shared.columns);
31
+ const width = numericSizeWidth(clampedSize, theme);
32
+ return react.css`
33
+ flex-basis: ${width};
34
+ flex-grow: 0;
35
+ width: ${width};
36
+ max-width: ${width};
37
+ `;
38
+ };
39
+ const fixedOffsetStyles = (offset, theme) => {
40
+ if (offset === "auto") {
41
+ return react.css`
42
+ margin-left: auto;
43
+ `;
44
+ }
45
+ const clampedOffset = clampToColumns(offset, theme.shared.columns);
46
+ return react.css`
47
+ margin-left: ${numericOffsetMargin(clampedOffset, theme)};
48
+ `;
49
+ };
50
+ const offsetStyles = (offset, theme) => {
51
+ if (typeof offset === "undefined") {
52
+ return react.css``;
53
+ }
54
+ if (!isResponsiveOffset(offset)) {
55
+ return fixedOffsetStyles(offset, theme);
56
+ }
57
+ return react.css`
58
+ ${Object.entries(offset).map(
59
+ ([breakpoint, breakpointOffset]) => react.css`
60
+ ${mq.from[breakpoint]} {
61
+ ${fixedOffsetStyles(breakpointOffset, theme)}
62
+ }
63
+ `
64
+ )}
65
+ `;
66
+ };
67
+ const sizeStyles = (size, theme) => {
68
+ if (typeof size === "undefined") {
69
+ return fixedSizeStyles(theme.shared.columns, theme);
70
+ }
71
+ if (!isResponsiveGridSize(size)) {
72
+ return fixedSizeStyles(size, theme);
73
+ }
74
+ return react.css`
75
+ ${Object.entries(size).map(
76
+ ([breakpoint, breakpointSize]) => react.css`
77
+ ${mq.from[breakpoint]} {
78
+ ${fixedSizeStyles(breakpointSize, theme)}
79
+ }
80
+ `
81
+ )}
82
+ `;
83
+ };
84
+ const gridStyles = (theme) => {
85
+ return react.css`
86
+ display: ${theme.shared.display};
87
+ width: ${theme.shared.width};
88
+ flex-direction: ${theme.shared.direction};
89
+ flex-wrap: ${theme.shared.wrap};
90
+ padding: 0 ${theme.shared.gap};
91
+ gap: ${theme.shared.gap};
92
+ justify-content: ${theme.shared.justifyContent};
93
+ align-items: ${theme.shared.alignItems};
94
+ `;
95
+ };
96
+ const itemStyles = (theme, { size, offset }) => {
97
+ return react.css`
98
+ min-width: 0;
99
+ ${sizeStyles(size, theme)}
100
+ ${offsetStyles(offset, theme)}
101
+ `;
102
+ };
103
+
104
+ exports.defaultGridTheme = defaultGridTheme;
105
+ exports.gridStyles = gridStyles;
106
+ exports.itemStyles = itemStyles;
@@ -0,0 +1,98 @@
1
+ import { css } from '@emotion/react';
2
+ import { componentGrid } from '../../styleD/build/typescript/component/grid.js';
3
+ import { from } from '../../styleD/utils/semantic/mq.js';
4
+
5
+ const defaultGridTheme = componentGrid;
6
+ const isResponsiveGridSize = (size) => typeof size === "object";
7
+ const isResponsiveOffset = (offset) => typeof offset === "object";
8
+ const clampToColumns = (value, columns) => Math.max(0, Math.min(value, columns));
9
+ const numericOffsetMargin = (offset, theme) => `calc(((100% - (${theme.shared.columns} - 1) * ${theme.shared.gap}) * ${offset} / ${theme.shared.columns}) + ${offset} * ${theme.shared.gap})`;
10
+ const numericSizeWidth = (size, theme) => `calc(((100% - (${theme.shared.columns} - 1) * ${theme.shared.gap}) * ${size} / ${theme.shared.columns}) + (${size} - 1) * ${theme.shared.gap})`;
11
+ const fixedSizeStyles = (size, theme) => {
12
+ if (size === "grow") {
13
+ return css`
14
+ flex-basis: 0;
15
+ flex-grow: 1;
16
+ max-width: 100%;
17
+ `;
18
+ }
19
+ if (size === "auto") {
20
+ return css`
21
+ flex-basis: auto;
22
+ flex-grow: 0;
23
+ flex-shrink: 0;
24
+ width: auto;
25
+ max-width: none;
26
+ `;
27
+ }
28
+ const clampedSize = clampToColumns(size, theme.shared.columns);
29
+ const width = numericSizeWidth(clampedSize, theme);
30
+ return css`
31
+ flex-basis: ${width};
32
+ flex-grow: 0;
33
+ width: ${width};
34
+ max-width: ${width};
35
+ `;
36
+ };
37
+ const fixedOffsetStyles = (offset, theme) => {
38
+ if (offset === "auto") {
39
+ return css`
40
+ margin-left: auto;
41
+ `;
42
+ }
43
+ const clampedOffset = clampToColumns(offset, theme.shared.columns);
44
+ return css`
45
+ margin-left: ${numericOffsetMargin(clampedOffset, theme)};
46
+ `;
47
+ };
48
+ const offsetStyles = (offset, theme) => {
49
+ if (typeof offset === "undefined") {
50
+ return css``;
51
+ }
52
+ if (!isResponsiveOffset(offset)) {
53
+ return fixedOffsetStyles(offset, theme);
54
+ }
55
+ return css`
56
+ ${Object.entries(offset).map(([breakpoint, breakpointOffset]) => css`
57
+ ${from[breakpoint]} {
58
+ ${fixedOffsetStyles(breakpointOffset, theme)}
59
+ }
60
+ `)}
61
+ `;
62
+ };
63
+ const sizeStyles = (size, theme) => {
64
+ if (typeof size === "undefined") {
65
+ return fixedSizeStyles(theme.shared.columns, theme);
66
+ }
67
+ if (!isResponsiveGridSize(size)) {
68
+ return fixedSizeStyles(size, theme);
69
+ }
70
+ return css`
71
+ ${Object.entries(size).map(([breakpoint, breakpointSize]) => css`
72
+ ${from[breakpoint]} {
73
+ ${fixedSizeStyles(breakpointSize, theme)}
74
+ }
75
+ `)}
76
+ `;
77
+ };
78
+ const gridStyles = (theme) => {
79
+ return css`
80
+ display: ${theme.shared.display};
81
+ width: ${theme.shared.width};
82
+ flex-direction: ${theme.shared.direction};
83
+ flex-wrap: ${theme.shared.wrap};
84
+ padding: 0 ${theme.shared.gap};
85
+ gap: ${theme.shared.gap};
86
+ justify-content: ${theme.shared.justifyContent};
87
+ align-items: ${theme.shared.alignItems};
88
+ `;
89
+ };
90
+ const itemStyles = (theme, { size, offset }) => {
91
+ return css`
92
+ min-width: 0;
93
+ ${sizeStyles(size, theme)}
94
+ ${offsetStyles(offset, theme)}
95
+ `;
96
+ };
97
+
98
+ export { defaultGridTheme, gridStyles, itemStyles };
@@ -0,0 +1,114 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('@emotion/react/jsx-runtime');
4
+ var react = require('@emotion/react');
5
+ var React = require('react');
6
+ var mergeDeep = require('../../util/mergeDeep.cjs');
7
+ var AlertBanner = require('../alert-banner/AlertBanner.cjs');
8
+ var Grid = require('../grid/Grid.cjs');
9
+ var TopBar = require('../topbar/TopBar.cjs');
10
+ var styles = require('./styles.cjs');
11
+
12
+ function Sidebar({
13
+ children,
14
+ layoutSmBreakpoint = "hidden",
15
+ theme = {},
16
+ cssOverrides,
17
+ ...props
18
+ }) {
19
+ const mergedTheme = mergeDeep.mergeDeep(styles.defaultSidebarTheme, theme);
20
+ return /* @__PURE__ */ jsxRuntime.jsx(
21
+ "aside",
22
+ {
23
+ css: [styles.sidebarStyles(mergedTheme, { layoutSmBreakpoint }), cssOverrides],
24
+ ...props,
25
+ children
26
+ }
27
+ );
28
+ }
29
+ function Layout({
30
+ children,
31
+ fluid = true,
32
+ theme = {},
33
+ cssOverrides,
34
+ ...props
35
+ }) {
36
+ const mergedTheme = mergeDeep.mergeDeep(styles.defaultLayoutTheme, theme);
37
+ let alertBanner = null;
38
+ let topBar = null;
39
+ let sidebar = null;
40
+ let main = null;
41
+ React.Children.forEach(children, (child) => {
42
+ if (!React.isValidElement(child)) {
43
+ return;
44
+ }
45
+ if (child.type === AlertBanner.AlertBanner) {
46
+ const alertBannerChild = child;
47
+ const alertBannerCssOverrides = Array.isArray(
48
+ alertBannerChild.props.cssOverrides
49
+ ) ? alertBannerChild.props.cssOverrides : alertBannerChild.props.cssOverrides ? [alertBannerChild.props.cssOverrides] : [];
50
+ alertBanner ?? (alertBanner = React.cloneElement(alertBannerChild, {
51
+ cssOverrides: [styles.alertBannerLayoutStyles(), ...alertBannerCssOverrides]
52
+ }));
53
+ return;
54
+ }
55
+ if (child.type === TopBar.TopBar) {
56
+ const topBarChild = child;
57
+ const topBarCssOverrides = Array.isArray(topBarChild.props.cssOverrides) ? topBarChild.props.cssOverrides : topBarChild.props.cssOverrides ? [topBarChild.props.cssOverrides] : [];
58
+ topBar ?? (topBar = React.cloneElement(topBarChild, {
59
+ cssOverrides: [styles.topBarLayoutStyles(), ...topBarCssOverrides]
60
+ }));
61
+ return;
62
+ }
63
+ if (child.type === Sidebar) {
64
+ const sidebarChild = child;
65
+ const sidebarCssOverrides = Array.isArray(sidebarChild.props.cssOverrides) ? sidebarChild.props.cssOverrides : sidebarChild.props.cssOverrides ? [sidebarChild.props.cssOverrides] : [];
66
+ sidebar ?? (sidebar = React.cloneElement(sidebarChild, {
67
+ cssOverrides: [styles.sidebarLayoutStyles(), ...sidebarCssOverrides]
68
+ }));
69
+ return;
70
+ }
71
+ if (child.type === Grid.Grid) {
72
+ const gridChild = child;
73
+ const gridCssOverrides = Array.isArray(gridChild.props.cssOverrides) ? gridChild.props.cssOverrides : gridChild.props.cssOverrides ? [gridChild.props.cssOverrides] : [];
74
+ main ?? (main = React.cloneElement(gridChild, {
75
+ as: "main",
76
+ cssOverrides: [
77
+ styles.mainLayoutStyles(mergedTheme, { fluid }),
78
+ ...gridCssOverrides
79
+ ]
80
+ }));
81
+ return;
82
+ }
83
+ if (!main) {
84
+ const childWithProps = child;
85
+ if ("cssOverrides" in childWithProps.props) {
86
+ const childCssOverrides = Array.isArray(
87
+ childWithProps.props.cssOverrides
88
+ ) ? childWithProps.props.cssOverrides : [childWithProps.props.cssOverrides ?? react.css``];
89
+ main ?? (main = React.cloneElement(childWithProps, {
90
+ cssOverrides: [
91
+ styles.mainLayoutStyles(mergedTheme, { fluid }),
92
+ ...childCssOverrides
93
+ ]
94
+ }));
95
+ } else {
96
+ main ?? (main = React.cloneElement(childWithProps, {
97
+ css: [
98
+ styles.mainLayoutStyles(mergedTheme, { fluid }),
99
+ childWithProps.props.css
100
+ ]
101
+ }));
102
+ }
103
+ }
104
+ });
105
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { css: [styles.layoutStyles(mergedTheme), cssOverrides], ...props, children: [
106
+ alertBanner,
107
+ topBar,
108
+ sidebar,
109
+ main
110
+ ] });
111
+ }
112
+
113
+ exports.Layout = Layout;
114
+ exports.Sidebar = Sidebar;
@@ -0,0 +1,83 @@
1
+ import { jsxs, jsx } from '@emotion/react/jsx-runtime';
2
+ import { css } from '@emotion/react';
3
+ import React from 'react';
4
+ import { mergeDeep } from '../../util/mergeDeep.js';
5
+ import { AlertBanner } from '../alert-banner/AlertBanner.js';
6
+ import { Grid } from '../grid/Grid.js';
7
+ import { TopBar } from '../topbar/TopBar.js';
8
+ import { alertBannerLayoutStyles, topBarLayoutStyles, sidebarLayoutStyles, mainLayoutStyles, layoutStyles, sidebarStyles, defaultSidebarTheme, defaultLayoutTheme } from './styles.js';
9
+
10
+ function Sidebar({ children, layoutSmBreakpoint = "hidden", theme = {}, cssOverrides, ...props }) {
11
+ const mergedTheme = mergeDeep(defaultSidebarTheme, theme);
12
+ return jsx("aside", { css: [sidebarStyles(mergedTheme, { layoutSmBreakpoint }), cssOverrides], ...props, children });
13
+ }
14
+ function Layout({ children, fluid = true, theme = {}, cssOverrides, ...props }) {
15
+ const mergedTheme = mergeDeep(defaultLayoutTheme, theme);
16
+ let alertBanner = null;
17
+ let topBar = null;
18
+ let sidebar = null;
19
+ let main = null;
20
+ React.Children.forEach(children, (child) => {
21
+ if (!React.isValidElement(child)) {
22
+ return;
23
+ }
24
+ if (child.type === AlertBanner) {
25
+ const alertBannerChild = child;
26
+ const alertBannerCssOverrides = Array.isArray(alertBannerChild.props.cssOverrides) ? alertBannerChild.props.cssOverrides : alertBannerChild.props.cssOverrides ? [alertBannerChild.props.cssOverrides] : [];
27
+ alertBanner ?? (alertBanner = React.cloneElement(alertBannerChild, {
28
+ cssOverrides: [alertBannerLayoutStyles(), ...alertBannerCssOverrides]
29
+ }));
30
+ return;
31
+ }
32
+ if (child.type === TopBar) {
33
+ const topBarChild = child;
34
+ const topBarCssOverrides = Array.isArray(topBarChild.props.cssOverrides) ? topBarChild.props.cssOverrides : topBarChild.props.cssOverrides ? [topBarChild.props.cssOverrides] : [];
35
+ topBar ?? (topBar = React.cloneElement(topBarChild, {
36
+ cssOverrides: [topBarLayoutStyles(), ...topBarCssOverrides]
37
+ }));
38
+ return;
39
+ }
40
+ if (child.type === Sidebar) {
41
+ const sidebarChild = child;
42
+ const sidebarCssOverrides = Array.isArray(sidebarChild.props.cssOverrides) ? sidebarChild.props.cssOverrides : sidebarChild.props.cssOverrides ? [sidebarChild.props.cssOverrides] : [];
43
+ sidebar ?? (sidebar = React.cloneElement(sidebarChild, {
44
+ cssOverrides: [sidebarLayoutStyles(), ...sidebarCssOverrides]
45
+ }));
46
+ return;
47
+ }
48
+ if (child.type === Grid) {
49
+ const gridChild = child;
50
+ const gridCssOverrides = Array.isArray(gridChild.props.cssOverrides) ? gridChild.props.cssOverrides : gridChild.props.cssOverrides ? [gridChild.props.cssOverrides] : [];
51
+ main ?? (main = React.cloneElement(gridChild, {
52
+ as: "main",
53
+ cssOverrides: [
54
+ mainLayoutStyles(mergedTheme, { fluid }),
55
+ ...gridCssOverrides
56
+ ]
57
+ }));
58
+ return;
59
+ }
60
+ if (!main) {
61
+ const childWithProps = child;
62
+ if ("cssOverrides" in childWithProps.props) {
63
+ const childCssOverrides = Array.isArray(childWithProps.props.cssOverrides) ? childWithProps.props.cssOverrides : [childWithProps.props.cssOverrides ?? css``];
64
+ main ?? (main = React.cloneElement(childWithProps, {
65
+ cssOverrides: [
66
+ mainLayoutStyles(mergedTheme, { fluid }),
67
+ ...childCssOverrides
68
+ ]
69
+ }));
70
+ } else {
71
+ main ?? (main = React.cloneElement(childWithProps, {
72
+ css: [
73
+ mainLayoutStyles(mergedTheme, { fluid }),
74
+ childWithProps.props.css
75
+ ]
76
+ }));
77
+ }
78
+ }
79
+ });
80
+ return jsxs("div", { css: [layoutStyles(mergedTheme), cssOverrides], ...props, children: [alertBanner, topBar, sidebar, main] });
81
+ }
82
+
83
+ export { Layout, Sidebar };
@@ -0,0 +1,92 @@
1
+ 'use strict';
2
+
3
+ var react = require('@emotion/react');
4
+ var layout = require('../../styleD/build/typescript/component/layout.cjs');
5
+ var mq = require('../../styleD/utils/semantic/mq.cjs');
6
+
7
+ const defaultLayoutTheme = layout.componentLayout["layout"];
8
+ const defaultSidebarTheme = layout.componentLayout["sidebar"];
9
+ const alertBannerLayoutStyles = () => {
10
+ return react.css`
11
+ grid-area: alertbanner;
12
+ `;
13
+ };
14
+ const topBarLayoutStyles = () => {
15
+ return react.css`
16
+ grid-area: topbar;
17
+ `;
18
+ };
19
+ const sidebarLayoutStyles = () => {
20
+ return react.css`
21
+ grid-area: sidebar;
22
+ `;
23
+ };
24
+ const mainLayoutStyles = (theme, { fluid }) => {
25
+ return react.css`
26
+ grid-area: main;
27
+ ${fluid ? "" : react.css`
28
+ max-width: ${theme.shared["max-width"]};
29
+ margin-left: ${theme.shared["margin-left"]};
30
+ margin-right: ${theme.shared["margin-right"]};
31
+ `}
32
+ `;
33
+ };
34
+ const layoutStyles = (theme) => {
35
+ return react.css`
36
+ display: ${theme.shared.display};
37
+ min-height: ${theme.shared.minHeight};
38
+ width: ${theme.shared.width};
39
+
40
+ grid-template-areas: ${theme.sm.gridTemplateAreas};
41
+ grid-template-columns: ${theme.sm.gridTemplateColumns};
42
+ grid-template-rows: ${theme.sm.gridTemplateRows};
43
+
44
+ ${mq.from.md} {
45
+ grid-template-areas: ${theme.md.gridTemplateAreas};
46
+ grid-template-columns: ${theme.md.gridTemplateColumns};
47
+ grid-template-rows: ${theme.md.gridTemplateRows};
48
+ }
49
+
50
+ ${mq.from.lg} {
51
+ grid-template-areas: ${theme.lg.gridTemplateAreas};
52
+ grid-template-columns: ${theme.lg.gridTemplateColumns};
53
+ grid-template-rows: ${theme.lg.gridTemplateRows};
54
+ }
55
+ `;
56
+ };
57
+ const sidebarStyles = (theme, { layoutSmBreakpoint }) => {
58
+ return react.css`
59
+ ${mq.from.sm} {
60
+ ${(() => {
61
+ switch (layoutSmBreakpoint) {
62
+ case "above-grid":
63
+ return react.css`
64
+ display: ${theme.sm.aboveGrid.display};
65
+ `;
66
+ case "hidden":
67
+ return react.css`
68
+ display: ${theme.sm.hidden.display};
69
+ `;
70
+ }
71
+ })()}
72
+ }
73
+
74
+ ${mq.from.md} {
75
+ display: ${theme.md.display};
76
+ width: ${theme.md.width};
77
+ }
78
+
79
+ ${mq.from.lg} {
80
+ width: ${theme.lg.width};
81
+ }
82
+ `;
83
+ };
84
+
85
+ exports.alertBannerLayoutStyles = alertBannerLayoutStyles;
86
+ exports.defaultLayoutTheme = defaultLayoutTheme;
87
+ exports.defaultSidebarTheme = defaultSidebarTheme;
88
+ exports.layoutStyles = layoutStyles;
89
+ exports.mainLayoutStyles = mainLayoutStyles;
90
+ exports.sidebarLayoutStyles = sidebarLayoutStyles;
91
+ exports.sidebarStyles = sidebarStyles;
92
+ exports.topBarLayoutStyles = topBarLayoutStyles;
@@ -0,0 +1,83 @@
1
+ import { css } from '@emotion/react';
2
+ import { componentLayout } from '../../styleD/build/typescript/component/layout.js';
3
+ import { from } from '../../styleD/utils/semantic/mq.js';
4
+
5
+ const defaultLayoutTheme = componentLayout["layout"];
6
+ const defaultSidebarTheme = componentLayout["sidebar"];
7
+ const alertBannerLayoutStyles = () => {
8
+ return css`
9
+ grid-area: alertbanner;
10
+ `;
11
+ };
12
+ const topBarLayoutStyles = () => {
13
+ return css`
14
+ grid-area: topbar;
15
+ `;
16
+ };
17
+ const sidebarLayoutStyles = () => {
18
+ return css`
19
+ grid-area: sidebar;
20
+ `;
21
+ };
22
+ const mainLayoutStyles = (theme, { fluid }) => {
23
+ return css`
24
+ grid-area: main;
25
+ ${fluid ? "" : css`
26
+ max-width: ${theme.shared["max-width"]};
27
+ margin-left: ${theme.shared["margin-left"]};
28
+ margin-right: ${theme.shared["margin-right"]};
29
+ `}
30
+ `;
31
+ };
32
+ const layoutStyles = (theme) => {
33
+ return css`
34
+ display: ${theme.shared.display};
35
+ min-height: ${theme.shared.minHeight};
36
+ width: ${theme.shared.width};
37
+
38
+ grid-template-areas: ${theme.sm.gridTemplateAreas};
39
+ grid-template-columns: ${theme.sm.gridTemplateColumns};
40
+ grid-template-rows: ${theme.sm.gridTemplateRows};
41
+
42
+ ${from.md} {
43
+ grid-template-areas: ${theme.md.gridTemplateAreas};
44
+ grid-template-columns: ${theme.md.gridTemplateColumns};
45
+ grid-template-rows: ${theme.md.gridTemplateRows};
46
+ }
47
+
48
+ ${from.lg} {
49
+ grid-template-areas: ${theme.lg.gridTemplateAreas};
50
+ grid-template-columns: ${theme.lg.gridTemplateColumns};
51
+ grid-template-rows: ${theme.lg.gridTemplateRows};
52
+ }
53
+ `;
54
+ };
55
+ const sidebarStyles = (theme, { layoutSmBreakpoint }) => {
56
+ return css`
57
+ ${from.sm} {
58
+ ${(() => {
59
+ switch (layoutSmBreakpoint) {
60
+ case "above-grid":
61
+ return css`
62
+ display: ${theme.sm.aboveGrid.display};
63
+ `;
64
+ case "hidden":
65
+ return css`
66
+ display: ${theme.sm.hidden.display};
67
+ `;
68
+ }
69
+ })()}
70
+ }
71
+
72
+ ${from.md} {
73
+ display: ${theme.md.display};
74
+ width: ${theme.md.width};
75
+ }
76
+
77
+ ${from.lg} {
78
+ width: ${theme.lg.width};
79
+ }
80
+ `;
81
+ };
82
+
83
+ export { alertBannerLayoutStyles, defaultLayoutTheme, defaultSidebarTheme, layoutStyles, mainLayoutStyles, sidebarLayoutStyles, sidebarStyles, topBarLayoutStyles };
package/dist/grid.cjs ADDED
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ var Grid = require('./components/grid/Grid.cjs');
4
+ var grid = require('./styleD/build/typescript/component/grid.cjs');
5
+
6
+
7
+
8
+ exports.Grid = Grid.Grid;
9
+ exports.Item = Grid.Item;
10
+ exports.componentGrid = grid.componentGrid;
package/dist/grid.js ADDED
@@ -0,0 +1,2 @@
1
+ export { Grid, Item } from './components/grid/Grid.js';
2
+ export { componentGrid } from './styleD/build/typescript/component/grid.js';
package/dist/index.cjs CHANGED
@@ -10,10 +10,12 @@ var button = require('./styleD/build/typescript/component/button.cjs');
10
10
  var checkbox = require('./styleD/build/typescript/component/checkbox.cjs');
11
11
  var favicon = require('./styleD/build/typescript/component/favicon.cjs');
12
12
  var datePicker = require('./styleD/build/typescript/component/datePicker.cjs');
13
+ var grid = require('./styleD/build/typescript/component/grid.cjs');
13
14
  var form = require('./styleD/build/typescript/component/form.cjs');
14
15
  var icon = require('./styleD/build/typescript/component/icon.cjs');
15
16
  var inlineMessage = require('./styleD/build/typescript/component/inlineMessage.cjs');
16
17
  var menu = require('./styleD/build/typescript/component/menu.cjs');
18
+ var layout = require('./styleD/build/typescript/component/layout.cjs');
17
19
  var link = require('./styleD/build/typescript/component/link.cjs');
18
20
  var alertBanner = require('./styleD/build/typescript/component/alertBanner.cjs');
19
21
  var radioGroup = require('./styleD/build/typescript/component/radioGroup.cjs');
@@ -45,10 +47,12 @@ exports.componentButton = button.componentButton;
45
47
  exports.componentCheckbox = checkbox.componentCheckbox;
46
48
  exports.componentFavicon = favicon.componentFavicon;
47
49
  exports.componentDatePicker = datePicker.componentDatePicker;
50
+ exports.componentGrid = grid.componentGrid;
48
51
  exports.componentForm = form.componentForm;
49
52
  exports.componentIcon = icon.componentIcon;
50
53
  exports.componentInlineMessage = inlineMessage.componentInlineMessage;
51
54
  exports.componentMenu = menu.componentMenu;
55
+ exports.componentLayout = layout.componentLayout;
52
56
  exports.componentLink = link.componentLink;
53
57
  exports.componentAlertBanner = alertBanner.componentAlertBanner;
54
58
  exports.componentRadioGroup = radioGroup.componentRadioGroup;
package/dist/index.js CHANGED
@@ -8,10 +8,12 @@ export { componentButton } from './styleD/build/typescript/component/button.js';
8
8
  export { componentCheckbox } from './styleD/build/typescript/component/checkbox.js';
9
9
  export { componentFavicon } from './styleD/build/typescript/component/favicon.js';
10
10
  export { componentDatePicker } from './styleD/build/typescript/component/datePicker.js';
11
+ export { componentGrid } from './styleD/build/typescript/component/grid.js';
11
12
  export { componentForm } from './styleD/build/typescript/component/form.js';
12
13
  export { componentIcon } from './styleD/build/typescript/component/icon.js';
13
14
  export { componentInlineMessage } from './styleD/build/typescript/component/inlineMessage.js';
14
15
  export { componentMenu } from './styleD/build/typescript/component/menu.js';
16
+ export { componentLayout } from './styleD/build/typescript/component/layout.js';
15
17
  export { componentLink } from './styleD/build/typescript/component/link.js';
16
18
  export { componentAlertBanner } from './styleD/build/typescript/component/alertBanner.js';
17
19
  export { componentRadioGroup } from './styleD/build/typescript/component/radioGroup.js';
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ var Layout = require('./components/layout/Layout.cjs');
4
+ var layout = require('./styleD/build/typescript/component/layout.cjs');
5
+
6
+
7
+
8
+ exports.Layout = Layout.Layout;
9
+ exports.Sidebar = Layout.Sidebar;
10
+ exports.componentLayout = layout.componentLayout;
package/dist/layout.js ADDED
@@ -0,0 +1,2 @@
1
+ export { Layout, Sidebar } from './components/layout/Layout.js';
2
+ export { componentLayout } from './styleD/build/typescript/component/layout.js';
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Do not edit directly, this file was auto-generated.
3
+ */
4
+
5
+ :root {
6
+ --component-grid-shared-display: flex;
7
+ --component-grid-shared-width: 100%;
8
+ --component-grid-shared-columns: 12;
9
+ --component-grid-shared-gap: 8px;
10
+ --component-grid-shared-direction: row;
11
+ --component-grid-shared-wrap: wrap;
12
+ --component-grid-shared-justify-content: flex-start;
13
+ --component-grid-shared-align-items: stretch;
14
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Do not edit directly, this file was auto-generated.
3
+ */
4
+
5
+ :root {
6
+ --component-layout-layout-shared-display: grid;
7
+ --component-layout-layout-shared-min-height: 100svh;
8
+ --component-layout-layout-shared-width: 100%;
9
+ --component-layout-layout-shared-max-width: 1584px;
10
+ --component-layout-layout-shared-margin-left: auto;
11
+ --component-layout-layout-shared-margin-right: auto;
12
+ --component-layout-layout-sm-grid-template-areas: 'alertbanner' 'topbar'
13
+ 'sidebar' 'main';
14
+ --component-layout-layout-sm-grid-template-columns: 1fr;
15
+ --component-layout-layout-sm-grid-template-rows: min-content min-content
16
+ min-content 1fr;
17
+ --component-layout-layout-md-grid-template-areas: 'alertbanner alertbanner'
18
+ 'topbar topbar' 'sidebar main';
19
+ --component-layout-layout-md-grid-template-columns: min-content 1fr;
20
+ --component-layout-layout-md-grid-template-rows: min-content min-content 1fr;
21
+ --component-layout-layout-lg-grid-template-areas: 'alertbanner alertbanner'
22
+ 'topbar topbar' 'sidebar main';
23
+ --component-layout-layout-lg-grid-template-columns: min-content 1fr;
24
+ --component-layout-layout-lg-grid-template-rows: min-content min-content 1fr;
25
+ --component-layout-sidebar-sm-hidden-display: none;
26
+ --component-layout-sidebar-sm-above-grid-display: block;
27
+ --component-layout-sidebar-md-display: block;
28
+ --component-layout-sidebar-md-width: 200px;
29
+ --component-layout-sidebar-lg-width: 320px;
30
+ }
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ const componentGrid = {
4
+ shared: {
5
+ display: "flex",
6
+ width: "100%",
7
+ columns: 12,
8
+ gap: "8px",
9
+ direction: "row",
10
+ wrap: "wrap",
11
+ justifyContent: "flex-start",
12
+ alignItems: "stretch"
13
+ }
14
+ };
15
+
16
+ exports.componentGrid = componentGrid;
@@ -0,0 +1,14 @@
1
+ const componentGrid = {
2
+ shared: {
3
+ display: "flex",
4
+ width: "100%",
5
+ columns: 12,
6
+ gap: "8px",
7
+ direction: "row",
8
+ wrap: "wrap",
9
+ justifyContent: "flex-start",
10
+ alignItems: "stretch"
11
+ }
12
+ };
13
+
14
+ export { componentGrid };
@@ -0,0 +1,48 @@
1
+ 'use strict';
2
+
3
+ const componentLayout = {
4
+ layout: {
5
+ shared: {
6
+ display: "grid",
7
+ minHeight: "100svh",
8
+ width: "100%",
9
+ "max-width": "1584px",
10
+ "margin-left": "auto",
11
+ "margin-right": "auto"
12
+ },
13
+ sm: {
14
+ gridTemplateAreas: "'alertbanner'\n'topbar'\n'sidebar'\n'main'",
15
+ gridTemplateColumns: "1fr",
16
+ gridTemplateRows: "min-content min-content min-content 1fr"
17
+ },
18
+ md: {
19
+ gridTemplateAreas: "'alertbanner alertbanner'\n'topbar topbar'\n'sidebar main'",
20
+ gridTemplateColumns: "min-content 1fr",
21
+ gridTemplateRows: "min-content min-content 1fr"
22
+ },
23
+ lg: {
24
+ gridTemplateAreas: "'alertbanner alertbanner'\n'topbar topbar'\n'sidebar main'",
25
+ gridTemplateColumns: "min-content 1fr",
26
+ gridTemplateRows: "min-content min-content 1fr"
27
+ }
28
+ },
29
+ sidebar: {
30
+ sm: {
31
+ hidden: {
32
+ display: "none"
33
+ },
34
+ aboveGrid: {
35
+ display: "block"
36
+ }
37
+ },
38
+ md: {
39
+ display: "block",
40
+ width: "200px"
41
+ },
42
+ lg: {
43
+ width: "320px"
44
+ }
45
+ }
46
+ };
47
+
48
+ exports.componentLayout = componentLayout;
@@ -0,0 +1,46 @@
1
+ const componentLayout = {
2
+ layout: {
3
+ shared: {
4
+ display: "grid",
5
+ minHeight: "100svh",
6
+ width: "100%",
7
+ "max-width": "1584px",
8
+ "margin-left": "auto",
9
+ "margin-right": "auto"
10
+ },
11
+ sm: {
12
+ gridTemplateAreas: "'alertbanner'\n'topbar'\n'sidebar'\n'main'",
13
+ gridTemplateColumns: "1fr",
14
+ gridTemplateRows: "min-content min-content min-content 1fr"
15
+ },
16
+ md: {
17
+ gridTemplateAreas: "'alertbanner alertbanner'\n'topbar topbar'\n'sidebar main'",
18
+ gridTemplateColumns: "min-content 1fr",
19
+ gridTemplateRows: "min-content min-content 1fr"
20
+ },
21
+ lg: {
22
+ gridTemplateAreas: "'alertbanner alertbanner'\n'topbar topbar'\n'sidebar main'",
23
+ gridTemplateColumns: "min-content 1fr",
24
+ gridTemplateRows: "min-content min-content 1fr"
25
+ }
26
+ },
27
+ sidebar: {
28
+ sm: {
29
+ hidden: {
30
+ display: "none"
31
+ },
32
+ aboveGrid: {
33
+ display: "block"
34
+ }
35
+ },
36
+ md: {
37
+ display: "block",
38
+ width: "200px"
39
+ },
40
+ lg: {
41
+ width: "320px"
42
+ }
43
+ }
44
+ };
45
+
46
+ export { componentLayout };
@@ -0,0 +1,3 @@
1
+ import type { GridProps, ItemProps } from './types';
2
+ export declare function Grid({ children, theme, cssOverrides, as: Component, ...props }: GridProps): import("@emotion/react/jsx-runtime").JSX.Element;
3
+ export declare function Item({ children, theme, cssOverrides, size, offset, ...props }: ItemProps): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1,5 @@
1
+ export declare const componentName = "Grid";
2
+ export declare const componentTsx = "import { Grid, Item } from '@guardian/stand/grid';\n\nexport const Component = () => (\n\t<Grid>\n\t\t<Item size={{ sm: 12, md: 8, lg: 6 }}>Main content - sm:12, md:8, lg:6</Item>\n\t\t<Item size={{ sm: 12, md: 4, lg: 3 }} offset={{ md: 1, lg: 2 }}>\n\t\t\tMore content - sm:12, md:4, lg:3, offset md:1, lg:2\n\t\t</Item>\n\t\t<Item size=\"auto\">Auto width</Item>\n\t\t<Item size=\"grow\">Grows to fill</Item>\n\t</Grid>\n);\n";
3
+ export declare const componentCss = "\n/* import the grid styles */\n@import '@guardian/stand/component/grid.css';\n\n.stand-grid-container {\n\tdisplay: var(--component-grid-shared-display);\n\tflex-direction: row;\n\tflex-wrap: wrap;\n\tjustify-content: flex-start;\n\talign-items: stretch;\n\tgap: 16px;\n}\n\n.stand-grid-item {\n\tbox-sizing: border-box;\n\tpadding: 16px;\n\tbackground: #eff3ff;\n\tborder: 1px solid #b8c9ff;\n\tborder-radius: 6px;\n\ttext-align: center;\n}\n\n.stand-grid-item--main {\n\tflex: 0 0 calc(((100% - 11 * 16px) * 6 / 12) + 5 * 16px);\n}\n\n.stand-grid-item--sidebar {\n\tflex: 0 0 calc(((100% - 11 * 16px) * 3 / 12) + 2 * 16px);\n\tmargin-left: calc(((100% - 11 * 16px) * 1 / 12) + 1 * 16px);\n}\n\n.stand-grid-item--auto {\n\tflex: 0 0 auto;\n\twidth: auto;\n\tmax-width: none;\n\twhite-space: nowrap;\n}\n\n.stand-grid-item--grow {\n\tflex-basis: 0;\n\tflex-grow: 1;\n\tmax-width: 100%;\n}\n";
4
+ export declare const componentHtml = "<div class=\"container\">\n\t<div class=\"stand-grid-container\">\n\t\t<div class=\"stand-grid-item stand-grid-item--main\">Main content</div>\n\t\t<div class=\"stand-grid-item stand-grid-item--sidebar\">Sidebar</div>\n\t\t<div class=\"stand-grid-item stand-grid-item--auto\">Auto width</div>\n\t\t<div class=\"stand-grid-item stand-grid-item--grow\">Grows to fill</div>\n\t</div>\n</div>\n";
5
+ export declare const componentJs = "\nimport { componentGrid } from \"@guardian/stand\";\n\nconst containerStyle = `\n\tdisplay: ${componentGrid.shared.display};\n\tflex-direction: row;\n\tflex-wrap: wrap;\n\tjustify-content: flex-start;\n\talign-items: stretch;\n\tgap: 16px;\n`;\n\nconst itemStyle = `\n\tbox-sizing: border-box;\n\tpadding: 16px;\n\tbackground: #eff3ff;\n\tborder: 1px solid #b8c9ff;\n\tborder-radius: 6px;\n\ttext-align: center;\n`;\n\ndocument.getElementById(\"app\").innerHTML = `\n\t<div style=\"${containerStyle}\">\n\t\t<div style=\"${itemStyle}; flex: 0 0 calc(((100% - 11 * 16px) * 6 / 12) + 5 * 16px);\">Main content</div>\n\t\t<div style=\"${itemStyle}; flex: 0 0 calc(((100% - 11 * 16px) * 3 / 12) + 2 * 16px); margin-left: calc(((100% - 11 * 16px) * 1 / 12) + 1 * 16px);\">Sidebar</div>\n\t\t<div style=\"${itemStyle}; flex: 0 0 auto; width: auto; max-width: none; white-space: nowrap;\">Auto width</div>\n\t\t<div style=\"${itemStyle}; flex-basis: 0; flex-grow: 1; max-width: 100%;\">Grows to fill</div>\n\t</div>\n`;\n";
@@ -0,0 +1,11 @@
1
+ import type { SerializedStyles } from '@emotion/react';
2
+ import type { ComponentGrid } from '../../styleD/build/typescript/component/grid';
3
+ import type { DeepPartial, Prettify } from '../../util/types';
4
+ import type { ItemProps } from './types';
5
+ export type GridTheme = Prettify<ComponentGrid>;
6
+ export type PartialGridTheme = Prettify<DeepPartial<GridTheme>>;
7
+ export declare const defaultGridTheme: GridTheme;
8
+ type GridItemOwnerState = Pick<ItemProps, 'size' | 'offset'>;
9
+ export declare const gridStyles: (theme: GridTheme) => SerializedStyles;
10
+ export declare const itemStyles: (theme: GridTheme, { size, offset }: GridItemOwnerState) => SerializedStyles;
11
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,25 @@
1
+ import type { ElementType, HTMLAttributes } from 'react';
2
+ import type { Breakpoint } from '../../styleD/utils/semantic/mq';
3
+ import type { DefaultPropsWithChildren } from '../../util/types';
4
+ import type { GridTheme } from './styles';
5
+ export type ResponsiveGridValue<T> = Partial<Record<Breakpoint, T>>;
6
+ export type GridSizeValue = number | 'auto' | 'grow';
7
+ export type GridOffsetValue = number | 'auto';
8
+ export interface GridProps extends DefaultPropsWithChildren<GridTheme>, Omit<HTMLAttributes<HTMLElement>, 'children'> {
9
+ /**
10
+ * Element used to render the Grid container.
11
+ */
12
+ as?: ElementType;
13
+ }
14
+ export interface ItemProps extends DefaultPropsWithChildren<GridTheme>, Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
15
+ /**
16
+ * Number of columns the item should span, or responsive values keyed by breakpoint.
17
+ */
18
+ size?: GridSizeValue | ResponsiveGridValue<GridSizeValue>;
19
+ /**
20
+ * Columns to offset the item from the left. Numbers push the item that many columns
21
+ * to the right. 'auto' pushes it to the far right of the row.
22
+ * Responsive values keyed by breakpoint are also accepted.
23
+ */
24
+ offset?: GridOffsetValue | ResponsiveGridValue<GridOffsetValue>;
25
+ }
@@ -0,0 +1,19 @@
1
+ import type { LayoutProps, SidebarProps } from './types';
2
+ /**
3
+ * Currently a WIP (Subject to change, but usable) sidebar that can be used in the Layout, it supports two different layout behaviors at the sm breakpoint,
4
+ * either 'above-grid' which will place the sidebar above the grid content effectively making it a horizontal bar at the top of the page,
5
+ * or 'hidden' which will hide the sidebar entirely at the sm breakpoint.
6
+ *
7
+ * The consumer can choose how to make the sidebar content accessible through other means (e.g. a collapsible menu in the TopBar) when using the 'hidden' option.
8
+ */
9
+ export declare function Sidebar({ children, layoutSmBreakpoint, theme, cssOverrides, ...props }: SidebarProps): import("@emotion/react/jsx-runtime").JSX.Element;
10
+ /**
11
+ * A layout component that defines a grid structure for the page, it has specific areas for an AlertBanner, TopBar, Sidebar and Grid content.
12
+ *
13
+ * The layout adjusts based on the defined breakpoints in the theme, allowing for responsive design.
14
+ *
15
+ * The Layout component will look through its children and place them in the correct grid area based on their type (AlertBanner, TopBar, Sidebar, Grid), it ignores any children that are not of these types.
16
+ *
17
+ * Consumers can customize the layout by providing their own themes and CSS overrides for each of the components.
18
+ */
19
+ export declare function Layout({ children, fluid, theme, cssOverrides, ...props }: LayoutProps): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1,5 @@
1
+ export declare const componentName = "Layout";
2
+ export declare const componentTsx = "import { Grid, Item } from '@guardian/stand/grid';\nimport { Layout, Sidebar } from '@guardian/stand/layout';\nimport { TopBar, TopBarToolName } from '@guardian/stand/TopBar';\n\nexport const Component = () => (\n\t<Layout>\n\t\t<TopBar>\n\t\t\t<TopBarToolName name=\"Layout Demo\" favicon={{ letter: 'L' }} />\n\t\t</TopBar>\n\t\t<Sidebar layoutSmBreakpoint=\"above-grid\">\n\t\t\t<div style={{ padding: '8px' }}>Sidebar content</div>\n\t\t</Sidebar>\n\t\t<Grid>\n\t\t\t<Item size={{ sm: 12, md: 8 }}>Main content</Item>\n\t\t\t<Item size={{ sm: 12, md: 4 }}>Secondary content</Item>\n\t\t</Grid>\n\t</Layout>\n);\n";
3
+ export declare const componentCss = "\n/* import the layout styles */\n@import '@guardian/stand/component/layout.css';\n@import '@guardian/stand/semantic/breakpoints.css';\n\n/*\n * Use the TopBar and Grid/Item custom CSS examples from their respective\n * component docs to style the content placed inside these layout regions.\n */\n\n.stand-layout {\n\tdisplay: var(--component-layout-layout-shared-display);\n\tmin-height: var(--component-layout-layout-shared-min-height);\n\twidth: var(--component-layout-layout-shared-width);\n\tgrid-template-areas: var(--component-layout-layout-sm-grid-template-areas);\n\tgrid-template-columns: var(--component-layout-layout-sm-grid-template-columns);\n\tgrid-template-rows: var(--component-layout-layout-sm-grid-template-rows);\n}\n\n.stand-layout-alert-banner {\n\tgrid-area: alertbanner;\n}\n\n.stand-layout-top-bar {\n\tgrid-area: topbar;\n}\n\n.stand-layout-sidebar {\n\tgrid-area: sidebar;\n\tbackground: #f2f2f2;\n\tpadding: 8px;\n}\n\n.stand-layout-main {\n\tgrid-area: main;\n\tpadding: 8px;\n}\n\n@media (min-width: var(--semantic-breakpoints-md)) {\n\t.stand-layout {\n\t\tgrid-template-areas: var(--component-layout-layout-md-grid-template-areas);\n\t\tgrid-template-columns: var(--component-layout-layout-md-grid-template-columns);\n\t\tgrid-template-rows: var(--component-layout-layout-md-grid-template-rows);\n\t}\n\n\t.stand-layout-sidebar {\n\t\tdisplay: var(--component-layout-sidebar-md-display);\n\t\twidth: var(--component-layout-sidebar-md-width);\n\t}\n}\n";
4
+ export declare const componentHtml = "<div class=\"container\">\n\t<div class=\"stand-layout\">\n\t\t<div class=\"stand-layout-alert-banner\">Alert banner area</div>\n\t\t<div class=\"stand-layout-top-bar\">Top bar area</div>\n\t\t<div class=\"stand-layout-sidebar\">Sidebar area</div>\n\t\t<div class=\"stand-layout-main\">Main content area</div>\n\t</div>\n</div>\n";
5
+ export declare const componentJs = "\nimport { componentLayout, semanticBreakpoints } from \"@guardian/stand\";\n\n// Use the TopBar and Grid/Item custom JS examples from their respective\n// component docs to style the content placed inside these layout regions.\n\n\tconst sheet = new CSSStyleSheet();\n\n\tsheet.replaceSync(`\n\t .js-stand-layout {\n\t display: ${componentLayout.layout.shared.display};\n\t min-height: ${componentLayout.layout.shared.minHeight};\n\t width: ${componentLayout.layout.shared.width};\n\t grid-template-areas: ${componentLayout.layout.sm.gridTemplateAreas};\n\t grid-template-columns: ${componentLayout.layout.sm.gridTemplateColumns};\n\t grid-template-rows: ${componentLayout.layout.sm.gridTemplateRows};\n\t }\n\t .js-stand-layout-alert-banner {\n\t grid-area: alertbanner;\n\t }\n\t .js-stand-layout-top-bar {\n\t grid-area: topbar;\n\t }\n\t .js-stand-layout-sidebar {\n\t grid-area: sidebar;\n\t display: ${componentLayout.sidebar.sm.aboveGrid.display};\n\t background: #f2f2f2;\n\t padding: 8px;\n\t }\n\t .js-stand-layout-main {\n\t grid-area: main;\n\t padding: 8px;\n\t }\n\t @media (min-width: ${semanticBreakpoints.md}) {\n\t .js-stand-layout {\n\t grid-template-areas: ${componentLayout.layout.md.gridTemplateAreas};\n\t grid-template-columns: ${componentLayout.layout.md.gridTemplateColumns};\n\t grid-template-rows: ${componentLayout.layout.md.gridTemplateRows};\n\t }\n\t .js-stand-layout-sidebar {\n\t display: ${componentLayout.sidebar.md.display};\n\t width: ${componentLayout.sidebar.md.width};\n\t }\n\t }\n\t`);\n\n\tdocument.adoptedStyleSheets.push(sheet);\n\n\tdocument.getElementById(\"app\").innerHTML = `\n\t <div class=\"js-stand-layout\">\n\t <div class=\"js-stand-layout-alert-banner\">Alert banner area</div>\n\t <div class=\"js-stand-layout-top-bar\">Top bar area</div>\n\t <div class=\"js-stand-layout-sidebar\">Sidebar area</div>\n\t <div class=\"js-stand-layout-main\">Main content area</div>\n\t </div>\n\t`;\n";
@@ -0,0 +1,16 @@
1
+ import type { SerializedStyles } from '@emotion/react';
2
+ import type { ComponentLayout } from '../../styleD/build/typescript/component/layout';
3
+ import type { DeepPartial, Prettify } from '../../util/types';
4
+ import type { LayoutProps, SidebarProps } from './types';
5
+ export type LayoutTheme = Prettify<ComponentLayout['layout']>;
6
+ export type PartialLayoutTheme = Prettify<DeepPartial<LayoutTheme>>;
7
+ export declare const defaultLayoutTheme: LayoutTheme;
8
+ export type SidebarTheme = Prettify<ComponentLayout['sidebar']>;
9
+ export type PartialSidebarTheme = Prettify<DeepPartial<SidebarTheme>>;
10
+ export declare const defaultSidebarTheme: SidebarTheme;
11
+ export declare const alertBannerLayoutStyles: () => SerializedStyles;
12
+ export declare const topBarLayoutStyles: () => SerializedStyles;
13
+ export declare const sidebarLayoutStyles: () => SerializedStyles;
14
+ export declare const mainLayoutStyles: (theme: LayoutTheme, { fluid }: Required<Pick<LayoutProps, 'fluid'>>) => SerializedStyles;
15
+ export declare const layoutStyles: (theme: LayoutTheme) => SerializedStyles;
16
+ export declare const sidebarStyles: (theme: SidebarTheme, { layoutSmBreakpoint }: Required<Pick<SidebarProps, 'layoutSmBreakpoint'>>) => SerializedStyles;
@@ -0,0 +1,20 @@
1
+ import type { DefaultPropsWithChildren } from '../../util/types';
2
+ import type { LayoutTheme, SidebarTheme } from './styles';
3
+ export interface LayoutProps extends DefaultPropsWithChildren<LayoutTheme> {
4
+ /**
5
+ * When `true`, the layout will take up the full width of its container, enabled by default.
6
+ * When `false`, the layout will have a max-width of 1584px and be centered within its container.
7
+ * This can be used to prevent the layout from becoming too stretched on very wide screens.
8
+ */
9
+ fluid?: boolean;
10
+ }
11
+ export interface SidebarProps extends DefaultPropsWithChildren<SidebarTheme> {
12
+ /**
13
+ * Defines the layout behavior of the sidebar at the sm breakpoint.
14
+ *
15
+ * - 'above-grid' will place the sidebar above the grid content, effectively making it a horizontal bar at the top of the page, consumers may want to adjust the sidebar content styling for this breakpoint to make it look good in a horizontal layout.
16
+ * - 'hidden' will hide the sidebar entirely at the sm breakpoint, the consumer can choose how to make the sidebar content accessible through other means (e.g. a collapsible menu in the TopBar).
17
+ *
18
+ */
19
+ layoutSmBreakpoint?: 'above-grid' | 'hidden';
20
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Grid component entry point
3
+ *
4
+ * Peer dependencies required to use these components:
5
+ * - `@emotion/react`
6
+ * - `react`
7
+ * - `react-dom`
8
+ * - `typescript`
9
+ *
10
+ * See the `peerDependencies` section of package.json for compatible versions.
11
+ *
12
+ * If you only need the built CSS (./component/grid.css),
13
+ * you don't need to install these.
14
+ */
15
+ export { Grid } from './components/grid/Grid';
16
+ export { Item } from './components/grid/Grid';
17
+ export type { GridProps, ItemProps } from './components/grid/types';
18
+ export type { PartialGridTheme as GridTheme } from './components/grid/styles';
19
+ export { componentGrid } from './styleD/build/typescript/component/grid';
20
+ export type { ComponentGrid } from './styleD/build/typescript/component/grid';
@@ -28,6 +28,8 @@ export { componentFavicon } from './styleD/build/typescript/component/favicon';
28
28
  export type { ComponentFavicon } from './styleD/build/typescript/component/favicon';
29
29
  export { componentDatePicker } from './styleD/build/typescript/component/datePicker';
30
30
  export type { ComponentDatePicker } from './styleD/build/typescript/component/datePicker';
31
+ export { componentGrid } from './styleD/build/typescript/component/grid';
32
+ export type { ComponentGrid } from './styleD/build/typescript/component/grid';
31
33
  export { componentForm } from './styleD/build/typescript/component/form';
32
34
  export type { ComponentForm } from './styleD/build/typescript/component/form';
33
35
  export { componentIcon } from './styleD/build/typescript/component/icon';
@@ -36,6 +38,8 @@ export { componentInlineMessage } from './styleD/build/typescript/component/inli
36
38
  export type { ComponentInlineMessage } from './styleD/build/typescript/component/inlineMessage';
37
39
  export { componentMenu } from './styleD/build/typescript/component/menu';
38
40
  export type { ComponentMenu } from './styleD/build/typescript/component/menu';
41
+ export { componentLayout } from './styleD/build/typescript/component/layout';
42
+ export type { ComponentLayout } from './styleD/build/typescript/component/layout';
39
43
  export { componentLink } from './styleD/build/typescript/component/link';
40
44
  export type { ComponentLink } from './styleD/build/typescript/component/link';
41
45
  export { componentAlertBanner } from './styleD/build/typescript/component/alertBanner';
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Layout component entry point
3
+ *
4
+ * Peer dependencies required to use these components:
5
+ * - `@emotion/react`
6
+ * - `react`
7
+ * - `react-dom`
8
+ * - `typescript`
9
+ * - `react-aria-components` (for the `TopBar` components used in the example)
10
+ *
11
+ * See the `peerDependencies` section of package.json for compatible versions.
12
+ *
13
+ * If you only need the built CSS (./component/layout.css),
14
+ * you don't need to install these.
15
+ */
16
+ export { Layout, Sidebar } from './components/layout/Layout';
17
+ export type { LayoutProps, SidebarProps } from './components/layout/types';
18
+ export type { PartialLayoutTheme as LayoutTheme, PartialSidebarTheme as SidebarTheme, } from './components/layout/styles';
19
+ export { componentLayout } from './styleD/build/typescript/component/layout';
20
+ export type { ComponentLayout } from './styleD/build/typescript/component/layout';
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Do not edit directly, this file was auto-generated.
3
+ */
4
+ export declare const componentGrid: {
5
+ shared: {
6
+ display: string;
7
+ width: string;
8
+ columns: number;
9
+ gap: string;
10
+ direction: string;
11
+ wrap: string;
12
+ justifyContent: string;
13
+ alignItems: string;
14
+ };
15
+ };
16
+ export type ComponentGrid = typeof componentGrid;
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Do not edit directly, this file was auto-generated.
3
+ */
4
+ export declare const componentLayout: {
5
+ layout: {
6
+ shared: {
7
+ display: string;
8
+ minHeight: string;
9
+ width: string;
10
+ 'max-width': string;
11
+ 'margin-left': string;
12
+ 'margin-right': string;
13
+ };
14
+ sm: {
15
+ gridTemplateAreas: string;
16
+ gridTemplateColumns: string;
17
+ gridTemplateRows: string;
18
+ };
19
+ md: {
20
+ gridTemplateAreas: string;
21
+ gridTemplateColumns: string;
22
+ gridTemplateRows: string;
23
+ };
24
+ lg: {
25
+ gridTemplateAreas: string;
26
+ gridTemplateColumns: string;
27
+ gridTemplateRows: string;
28
+ };
29
+ };
30
+ sidebar: {
31
+ sm: {
32
+ hidden: {
33
+ display: string;
34
+ };
35
+ aboveGrid: {
36
+ display: string;
37
+ };
38
+ };
39
+ md: {
40
+ display: string;
41
+ width: string;
42
+ };
43
+ lg: {
44
+ width: string;
45
+ };
46
+ };
47
+ };
48
+ export type ComponentLayout = typeof componentLayout;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guardian/stand",
3
- "version": "0.0.35",
3
+ "version": "0.0.36",
4
4
  "repository": {
5
5
  "url": "https://github.com/guardian/stand"
6
6
  },
@@ -117,6 +117,11 @@
117
117
  "import": "./dist/date-picker.js",
118
118
  "require": "./dist/date-picker.cjs"
119
119
  },
120
+ "./grid": {
121
+ "types": "./dist/types/grid.d.ts",
122
+ "import": "./dist/grid.js",
123
+ "require": "./dist/grid.cjs"
124
+ },
120
125
  "./byline": {
121
126
  "types": "./dist/types/byline.d.ts",
122
127
  "import": "./dist/byline.js",
@@ -147,6 +152,11 @@
147
152
  "import": "./dist/link.js",
148
153
  "require": "./dist/link.cjs"
149
154
  },
155
+ "./layout": {
156
+ "types": "./dist/types/layout.d.ts",
157
+ "import": "./dist/layout.js",
158
+ "require": "./dist/layout.cjs"
159
+ },
150
160
  "./fonts/OpenSans.css": "./dist/fonts/OpenSans.css",
151
161
  "./fonts/MaterialSymbolsOutlined.css": "./dist/fonts/MaterialSymbolsOutlined.css",
152
162
  "./fonts/MaterialSymbolsRound.css": "./dist/fonts/MaterialSymbolsRound.css",
@@ -183,7 +193,9 @@
183
193
  "./component/alertBanner.css": "./dist/styleD/build/css/component/alertBanner.css",
184
194
  "./component/datePicker.css": "./dist/styleD/build/css/component/datePicker.css",
185
195
  "./component/intendedAudienceSignifier.css": "./dist/styleD/build/css/component/intendedAudienceSignifier.css",
186
- "./component/link.css": "./dist/styleD/build/css/component/link.css"
196
+ "./component/link.css": "./dist/styleD/build/css/component/link.css",
197
+ "./component/grid.css": "./dist/styleD/build/css/component/grid.css",
198
+ "./component/layout.css": "./dist/styleD/build/css/component/layout.css"
187
199
  },
188
200
  "main": "./dist/index.cjs",
189
201
  "module": "./dist/index.js",
@@ -270,6 +282,12 @@
270
282
  ],
271
283
  "link": [
272
284
  "./dist/types/link.d.ts"
285
+ ],
286
+ "grid": [
287
+ "./dist/types/grid.d.ts"
288
+ ],
289
+ "layout": [
290
+ "./dist/types/layout.d.ts"
273
291
  ]
274
292
  }
275
293
  },