@guardian/stand 0.0.8 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. package/README.md +1148 -10
  2. package/dist/avatar.cjs +9 -0
  3. package/dist/avatar.js +2 -0
  4. package/dist/button.cjs +9 -0
  5. package/dist/button.js +2 -0
  6. package/dist/byline.cjs +9 -0
  7. package/dist/byline.js +2 -0
  8. package/dist/components/TitleText.cjs +28 -0
  9. package/dist/components/TitleText.js +22 -0
  10. package/dist/components/avatar/Avatar.cjs +57 -0
  11. package/dist/components/avatar/Avatar.js +27 -0
  12. package/dist/components/avatar/styles.cjs +33 -0
  13. package/dist/components/avatar/styles.js +29 -0
  14. package/dist/components/avatar/types.cjs +16 -0
  15. package/dist/components/avatar/types.js +14 -0
  16. package/dist/components/button/Button.cjs +29 -0
  17. package/dist/components/button/Button.js +14 -0
  18. package/dist/components/button/styles.cjs +58 -0
  19. package/dist/components/button/styles.js +53 -0
  20. package/dist/components/byline/styles.cjs +5 -5
  21. package/dist/components/byline/styles.js +1 -1
  22. package/dist/components/icon/Icon.cjs +46 -0
  23. package/dist/components/icon/Icon.js +19 -0
  24. package/dist/components/icon/styles.cjs +27 -0
  25. package/dist/components/icon/styles.js +20 -0
  26. package/dist/components/link-button/LinkButton.cjs +29 -0
  27. package/dist/components/link-button/LinkButton.js +14 -0
  28. package/dist/components/link-button/styles.cjs +9 -0
  29. package/dist/components/link-button/styles.js +6 -0
  30. package/dist/components/tag-picker/styles.cjs +11 -11
  31. package/dist/components/tag-picker/styles.js +1 -1
  32. package/dist/components/typography/Typography.cjs +26 -0
  33. package/dist/components/typography/Typography.js +13 -0
  34. package/dist/components/typography/styles.cjs +15 -0
  35. package/dist/components/typography/styles.js +12 -0
  36. package/dist/components/user-menu/PreferenceRadioGroup.cjs +53 -0
  37. package/dist/components/user-menu/PreferenceRadioGroup.js +19 -0
  38. package/dist/components/user-menu/UserMenu.cjs +67 -0
  39. package/dist/components/user-menu/UserMenu.js +11 -0
  40. package/dist/components/user-menu/default-options.cjs +109 -0
  41. package/dist/components/user-menu/default-options.js +105 -0
  42. package/dist/components/user-menu/styles.cjs +90 -0
  43. package/dist/components/user-menu/styles.js +83 -0
  44. package/dist/fonts/MaterialSymbolsOutlined.css +23 -0
  45. package/dist/fonts/MaterialSymbolsRound.css +23 -0
  46. package/dist/fonts/MaterialSymbolsSharp.css +23 -0
  47. package/dist/fonts/material-symbols-types.ts +3825 -0
  48. package/dist/icon.cjs +9 -0
  49. package/dist/icon.js +2 -0
  50. package/dist/index.cjs +22 -13
  51. package/dist/index.js +9 -4
  52. package/dist/link-button.cjs +7 -0
  53. package/dist/link-button.js +1 -0
  54. package/dist/styleD/build/css/{css/base → base}/colors.css +1 -1
  55. package/dist/styleD/build/css/{css/base → base}/sizing.css +4 -0
  56. package/dist/styleD/build/css/{css/base → base}/spacing.css +4 -0
  57. package/dist/styleD/build/css/{css/base → base}/typography.css +1 -0
  58. package/dist/styleD/build/css/component/avatar.css +54 -0
  59. package/dist/styleD/build/css/component/button.css +218 -0
  60. package/dist/styleD/build/css/{css/component → component}/byline.css +1 -1
  61. package/dist/styleD/build/css/component/icon.css +11 -0
  62. package/dist/styleD/build/css/component/typography.css +7 -0
  63. package/dist/styleD/build/css/component/userMenu.css +29 -0
  64. package/dist/styleD/build/css/semantic/colors.css +69 -0
  65. package/dist/styleD/build/css/{css/semantic → semantic}/sizing.css +2 -0
  66. package/dist/styleD/build/css/{css/semantic → semantic}/typography.css +9 -0
  67. package/dist/styleD/build/typescript/base/colors.cjs +1 -1
  68. package/dist/styleD/build/typescript/base/colors.js +1 -1
  69. package/dist/styleD/build/typescript/base/sizing.cjs +4 -0
  70. package/dist/styleD/build/typescript/base/sizing.js +4 -0
  71. package/dist/styleD/build/typescript/base/spacing.cjs +4 -0
  72. package/dist/styleD/build/typescript/base/spacing.js +4 -0
  73. package/dist/styleD/build/typescript/base/typography.cjs +2 -1
  74. package/dist/styleD/build/typescript/base/typography.js +2 -1
  75. package/dist/styleD/build/typescript/component/avatar.cjs +88 -0
  76. package/dist/styleD/build/typescript/component/avatar.js +86 -0
  77. package/dist/styleD/build/typescript/component/button.cjs +331 -0
  78. package/dist/styleD/build/typescript/component/button.js +329 -0
  79. package/dist/styleD/build/typescript/component/byline.cjs +1 -1
  80. package/dist/styleD/build/typescript/component/byline.js +1 -1
  81. package/dist/styleD/build/typescript/component/icon.cjs +19 -0
  82. package/dist/styleD/build/typescript/component/icon.js +17 -0
  83. package/dist/styleD/build/typescript/component/typography.cjs +7 -0
  84. package/dist/styleD/build/typescript/component/typography.js +5 -0
  85. package/dist/styleD/build/typescript/component/userMenu.cjs +37 -0
  86. package/dist/styleD/build/typescript/component/userMenu.js +35 -0
  87. package/dist/styleD/build/typescript/semantic/colors.cjs +47 -5
  88. package/dist/styleD/build/typescript/semantic/colors.js +47 -5
  89. package/dist/styleD/build/typescript/semantic/sizing.cjs +3 -1
  90. package/dist/styleD/build/typescript/semantic/sizing.js +3 -1
  91. package/dist/styleD/build/typescript/semantic/typography.cjs +15 -0
  92. package/dist/styleD/build/typescript/semantic/typography.js +15 -0
  93. package/dist/tag-picker.cjs +13 -0
  94. package/dist/tag-picker.js +4 -0
  95. package/dist/types/avatar.d.ts +19 -0
  96. package/dist/types/button.d.ts +20 -0
  97. package/dist/types/byline.d.ts +25 -0
  98. package/dist/types/components/TitleText.d.ts +6 -0
  99. package/dist/types/components/avatar/Avatar.d.ts +2 -0
  100. package/dist/types/components/avatar/styles.d.ts +8 -0
  101. package/dist/types/components/avatar/types.d.ts +45 -0
  102. package/dist/types/components/button/Button.d.ts +2 -0
  103. package/dist/types/components/button/styles.d.ts +7 -0
  104. package/dist/types/components/button/types.d.ts +13 -0
  105. package/dist/types/components/byline/Byline.d.ts +1 -1
  106. package/dist/types/components/byline/schema.d.ts +1 -1
  107. package/dist/types/components/byline/styles.d.ts +1 -1
  108. package/dist/types/components/byline/theme.d.ts +1 -1
  109. package/dist/types/components/icon/Icon.d.ts +2 -0
  110. package/dist/types/components/icon/styles.d.ts +8 -0
  111. package/dist/types/components/icon/types.d.ts +28 -0
  112. package/dist/types/components/link-button/LinkButton.d.ts +2 -0
  113. package/dist/types/components/link-button/styles.d.ts +330 -0
  114. package/dist/types/components/link-button/types.d.ts +13 -0
  115. package/dist/types/components/tag-picker/TagAutocomplete.d.ts +1 -1
  116. package/dist/types/components/tag-picker/TagTable.d.ts +1 -1
  117. package/dist/types/components/tag-picker/styles.d.ts +1 -1
  118. package/dist/types/components/typography/Typography.d.ts +6 -0
  119. package/dist/types/components/typography/styles.d.ts +7 -0
  120. package/dist/types/components/typography/types.d.ts +13 -0
  121. package/dist/types/components/user-menu/PreferenceRadioGroup.d.ts +15 -0
  122. package/dist/types/components/user-menu/UserMenu.d.ts +17 -0
  123. package/dist/types/components/user-menu/default-options.d.ts +5 -0
  124. package/dist/types/components/user-menu/model.d.ts +9 -0
  125. package/dist/types/components/user-menu/styles.d.ts +9 -0
  126. package/dist/types/components/user-menu/theme.d.ts +3 -0
  127. package/dist/types/components/user-menu/types.d.ts +5 -0
  128. package/dist/types/fonts/material-symbols-types.d.ts +3822 -0
  129. package/dist/types/icon.d.ts +27 -0
  130. package/dist/types/index.d.ts +25 -7
  131. package/dist/types/link-button.d.ts +20 -0
  132. package/dist/types/styleD/build/typescript/base/colors.d.ts +1 -1
  133. package/dist/types/styleD/build/typescript/base/sizing.d.ts +4 -0
  134. package/dist/types/styleD/build/typescript/base/spacing.d.ts +4 -0
  135. package/dist/types/styleD/build/typescript/base/typography.d.ts +1 -0
  136. package/dist/types/styleD/build/typescript/component/avatar.d.ts +88 -0
  137. package/dist/types/styleD/build/typescript/component/button.d.ts +331 -0
  138. package/dist/types/styleD/build/typescript/component/icon.d.ts +19 -0
  139. package/dist/types/styleD/build/typescript/component/typography.d.ts +7 -0
  140. package/dist/types/styleD/build/typescript/component/userMenu.d.ts +37 -0
  141. package/dist/types/styleD/build/typescript/semantic/colors.d.ts +45 -3
  142. package/dist/types/styleD/build/typescript/semantic/sizing.d.ts +2 -0
  143. package/dist/types/styleD/build/typescript/semantic/typography.d.ts +15 -0
  144. package/dist/types/tag-picker.d.ts +21 -0
  145. package/dist/types/typography.d.ts +19 -0
  146. package/dist/types/user-menu.d.ts +18 -0
  147. package/dist/types/util/mergeDeep.d.ts +1 -0
  148. package/dist/types/util/reset.d.ts +1 -0
  149. package/dist/types/util/storybookStyles.d.ts +1 -0
  150. package/dist/types/util/types.d.ts +34 -0
  151. package/dist/types/utils.d.ts +7 -0
  152. package/dist/typography.cjs +9 -0
  153. package/dist/typography.js +2 -0
  154. package/dist/user-menu.cjs +9 -0
  155. package/dist/user-menu.js +2 -0
  156. package/dist/util/css/reset.css +124 -0
  157. package/dist/util/reset.cjs +10 -0
  158. package/dist/util/reset.css.cjs +5 -0
  159. package/dist/util/reset.css.js +3 -0
  160. package/dist/util/reset.js +8 -0
  161. package/dist/utils.cjs +10 -0
  162. package/dist/utils.js +2 -0
  163. package/package.json +112 -3
  164. package/dist/styleD/build/css/css/semantic/colors.css +0 -29
  165. package/dist/types/components/util.d.ts +0 -4
  166. /package/dist/styleD/build/css/{css/base → base}/radius.css +0 -0
  167. /package/dist/styleD/build/css/{css/component → component}/tagAutocomplete.css +0 -0
  168. /package/dist/styleD/build/css/{css/component → component}/tagTable.css +0 -0
  169. /package/dist/{components/util.cjs → util/mergeDeep.cjs} +0 -0
  170. /package/dist/{components/util.js → util/mergeDeep.js} +0 -0
@@ -0,0 +1,6 @@
1
+ import { buttonStyles, defaultButtonTheme } from '../button/styles.js';
2
+
3
+ const defaultLinkButtonTheme = defaultButtonTheme;
4
+ const linkButtonStyles = buttonStyles;
5
+
6
+ export { defaultLinkButtonTheme, linkButtonStyles };
@@ -3,10 +3,10 @@
3
3
  var react = require('@emotion/react');
4
4
  var tagAutocomplete = require('../../styleD/build/typescript/component/tagAutocomplete.cjs');
5
5
  var tagTable = require('../../styleD/build/typescript/component/tagTable.cjs');
6
- var util = require('../util.cjs');
6
+ var mergeDeep = require('../../util/mergeDeep.cjs');
7
7
 
8
8
  const tagAutocompleteInputStyles = (partialTheme = {}) => {
9
- const theme = util.mergeDeep(tagAutocomplete.componentTagAutocomplete, partialTheme);
9
+ const theme = mergeDeep.mergeDeep(tagAutocomplete.componentTagAutocomplete, partialTheme);
10
10
  return react.css`
11
11
  width: 100%;
12
12
  box-sizing: border-box;
@@ -23,7 +23,7 @@ const tagAutocompleteInputStyles = (partialTheme = {}) => {
23
23
  `;
24
24
  };
25
25
  const listboxStyles = (partialTheme = {}) => {
26
- const theme = util.mergeDeep(tagAutocomplete.componentTagAutocomplete, partialTheme);
26
+ const theme = mergeDeep.mergeDeep(tagAutocomplete.componentTagAutocomplete, partialTheme);
27
27
  return react.css`
28
28
  padding: ${theme.listbox.paddingY} ${theme.listbox.paddingX};
29
29
  max-height: 320px;
@@ -35,7 +35,7 @@ const listboxStyles = (partialTheme = {}) => {
35
35
  `;
36
36
  };
37
37
  const listboxItemStyles = (partialTheme = {}) => {
38
- const theme = util.mergeDeep(tagAutocomplete.componentTagAutocomplete, partialTheme);
38
+ const theme = mergeDeep.mergeDeep(tagAutocomplete.componentTagAutocomplete, partialTheme);
39
39
  return react.css`
40
40
  padding: ${theme.listbox.item.paddingY} ${theme.listbox.item.paddingX};
41
41
  cursor: pointer;
@@ -48,13 +48,13 @@ const listboxItemStyles = (partialTheme = {}) => {
48
48
  `;
49
49
  };
50
50
  const listboxInfoStyles = (partialTheme = {}) => {
51
- const theme = util.mergeDeep(tagAutocomplete.componentTagAutocomplete, partialTheme);
51
+ const theme = mergeDeep.mergeDeep(tagAutocomplete.componentTagAutocomplete, partialTheme);
52
52
  return react.css`
53
53
  padding: ${theme.listbox.item.paddingY} ${theme.listbox.item.paddingX};
54
54
  `;
55
55
  };
56
56
  const tagTableHeadingStyles = (partialTheme = {}) => {
57
- const theme = util.mergeDeep(tagTable.componentTagTable, partialTheme);
57
+ const theme = mergeDeep.mergeDeep(tagTable.componentTagTable, partialTheme);
58
58
  return react.css`
59
59
  background-color: ${theme.heading.backgroundColor};
60
60
  font-weight: ${theme.heading.fontWeight};
@@ -63,7 +63,7 @@ const tagTableHeadingStyles = (partialTheme = {}) => {
63
63
  `;
64
64
  };
65
65
  const tagTableCellStyles = (partialTheme = {}) => {
66
- const theme = util.mergeDeep(tagTable.componentTagTable, partialTheme);
66
+ const theme = mergeDeep.mergeDeep(tagTable.componentTagTable, partialTheme);
67
67
  return react.css`
68
68
  padding: ${theme.cell.paddingY} ${theme.cell.paddingX};
69
69
 
@@ -79,7 +79,7 @@ const tagTableCellStyles = (partialTheme = {}) => {
79
79
  `;
80
80
  };
81
81
  const tagTableRowStyles = (canDrag, partialTheme = {}) => {
82
- const theme = util.mergeDeep(tagTable.componentTagTable, partialTheme);
82
+ const theme = mergeDeep.mergeDeep(tagTable.componentTagTable, partialTheme);
83
83
  return react.css`
84
84
  background-color: ${theme.row.backgroundColor};
85
85
  height: ${theme.row.height};
@@ -106,7 +106,7 @@ const tagTableRowStyles = (canDrag, partialTheme = {}) => {
106
106
  `;
107
107
  };
108
108
  const tagTableStyles = (canRemoveTag, partialTheme = {}) => {
109
- const theme = util.mergeDeep(tagTable.componentTagTable, partialTheme);
109
+ const theme = mergeDeep.mergeDeep(tagTable.componentTagTable, partialTheme);
110
110
  return react.css`
111
111
  width: 100%;
112
112
  border-collapse: collapse;
@@ -129,7 +129,7 @@ const tagTableRemoveButtonStyles = react.css`
129
129
  }
130
130
  `;
131
131
  const tagTableAddButtonStyles = (partialTheme = {}) => {
132
- const theme = util.mergeDeep(tagTable.componentTagTable, partialTheme);
132
+ const theme = mergeDeep.mergeDeep(tagTable.componentTagTable, partialTheme);
133
133
  return react.css`
134
134
  :hover {
135
135
  cursor: pointer;
@@ -172,7 +172,7 @@ const tagTableDragButtonStyles = react.css`
172
172
  }
173
173
  `;
174
174
  const tagTableTypeBadgeStyles = (partialTheme = {}) => {
175
- const theme = util.mergeDeep(tagTable.componentTagTable, partialTheme);
175
+ const theme = mergeDeep.mergeDeep(tagTable.componentTagTable, partialTheme);
176
176
  return react.css`
177
177
  white-space: nowrap;
178
178
  text-transform: uppercase;
@@ -1,7 +1,7 @@
1
1
  import { css } from '@emotion/react';
2
2
  import { componentTagAutocomplete } from '../../styleD/build/typescript/component/tagAutocomplete.js';
3
3
  import { componentTagTable } from '../../styleD/build/typescript/component/tagTable.js';
4
- import { mergeDeep } from '../util.js';
4
+ import { mergeDeep } from '../../util/mergeDeep.js';
5
5
 
6
6
  const tagAutocompleteInputStyles = (partialTheme = {}) => {
7
7
  const theme = mergeDeep(componentTagAutocomplete, partialTheme);
@@ -0,0 +1,26 @@
1
+ 'use strict';
2
+
3
+ var react = require('@emotion/react');
4
+ var mergeDeep = require('../../util/mergeDeep.cjs');
5
+ var styles = require('./styles.cjs');
6
+
7
+ const Typography = ({
8
+ element = "span",
9
+ variant = "body-md",
10
+ children,
11
+ cssOverrides,
12
+ theme = {},
13
+ ...props
14
+ }) => {
15
+ const mergedTheme = mergeDeep.mergeDeep(styles.defaultTypographyTheme, theme);
16
+ return react.jsx(
17
+ element,
18
+ {
19
+ css: [styles.typographyStyles(mergedTheme, { variant }), cssOverrides],
20
+ ...props
21
+ },
22
+ children
23
+ );
24
+ };
25
+
26
+ exports.Typography = Typography;
@@ -0,0 +1,13 @@
1
+ import { jsx } from '@emotion/react';
2
+ import { mergeDeep } from '../../util/mergeDeep.js';
3
+ import { typographyStyles, defaultTypographyTheme } from './styles.js';
4
+
5
+ const Typography = ({ element = "span", variant = "body-md", children, cssOverrides, theme = {}, ...props }) => {
6
+ const mergedTheme = mergeDeep(defaultTypographyTheme, theme);
7
+ return jsx(element, {
8
+ css: [typographyStyles(mergedTheme, { variant }), cssOverrides],
9
+ ...props
10
+ }, children);
11
+ };
12
+
13
+ export { Typography };
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ var react = require('@emotion/react');
4
+ var typography$2 = require('../../styleD/build/typescript/component/typography.cjs');
5
+ var typography = require('../../styleD/utils/semantic/typography.cjs');
6
+ var typography$1 = require('../../styleD/build/typescript/semantic/typography.cjs');
7
+
8
+ const defaultTypographyTheme = typography$2.componentTypography;
9
+ const typographyStyles = (theme, { variant }) => react.css`
10
+ ${typography.convertTypographyToEmotionStringStyle(typography$1.semanticTypography[variant])}
11
+ color: ${theme.color};
12
+ `;
13
+
14
+ exports.defaultTypographyTheme = defaultTypographyTheme;
15
+ exports.typographyStyles = typographyStyles;
@@ -0,0 +1,12 @@
1
+ import { css } from '@emotion/react';
2
+ import { componentTypography } from '../../styleD/build/typescript/component/typography.js';
3
+ import { convertTypographyToEmotionStringStyle } from '../../styleD/utils/semantic/typography.js';
4
+ import { semanticTypography } from '../../styleD/build/typescript/semantic/typography.js';
5
+
6
+ const defaultTypographyTheme = componentTypography;
7
+ const typographyStyles = (theme, { variant }) => css`
8
+ ${convertTypographyToEmotionStringStyle(semanticTypography[variant])}
9
+ color: ${theme.color};
10
+ `;
11
+
12
+ export { defaultTypographyTheme, typographyStyles };
@@ -0,0 +1,53 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('@emotion/react/jsx-runtime');
4
+ var react = require('@emotion/react');
5
+ var reactAriaComponents = require('react-aria-components');
6
+ var styles = require('./styles.cjs');
7
+
8
+ function PreferenceRadioGroup({
9
+ name,
10
+ options,
11
+ currentValue,
12
+ changeValue,
13
+ theme,
14
+ format = "stack"
15
+ }) {
16
+ const groupCss = format === "stack" ? styles.toggleButtonStackedGroupStyles(theme) : styles.toggleButtonRowsGroupStyles(theme);
17
+ const buttonStyle = format === "stack" ? styles.toggleButtonStyles(theme) : [styles.toggleButtonStyles(theme), react.css({ flexBasis: "30%" })];
18
+ const defaultOptionId = options.find((option) => option.isDefault)?.id;
19
+ const selectedKeys = currentValue ? [currentValue] : defaultOptionId ? [defaultOptionId] : [];
20
+ return /* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
21
+ /* @__PURE__ */ jsxRuntime.jsx("div", { css: styles.radioGroupLabelStyles(theme), children: name }),
22
+ /* @__PURE__ */ jsxRuntime.jsx(
23
+ reactAriaComponents.ToggleButtonGroup,
24
+ {
25
+ css: groupCss,
26
+ selectionMode: "single",
27
+ orientation: format === "stack" ? "vertical" : "horizontal",
28
+ selectedKeys,
29
+ onSelectionChange: (e) => {
30
+ const newValue = Array.from(e).pop() ?? currentValue;
31
+ if (typeof newValue === "string") {
32
+ changeValue(newValue);
33
+ }
34
+ },
35
+ children: options.map((option, index) => /* @__PURE__ */ jsxRuntime.jsxs(
36
+ reactAriaComponents.ToggleButton,
37
+ {
38
+ id: option.id,
39
+ css: buttonStyle,
40
+ style: option.buttonStyle,
41
+ children: [
42
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: option.labelStyle, children: option.label ?? option.id }),
43
+ /* @__PURE__ */ jsxRuntime.jsx("div", { children: option.description })
44
+ ]
45
+ },
46
+ index
47
+ ))
48
+ }
49
+ )
50
+ ] });
51
+ }
52
+
53
+ exports.PreferenceRadioGroup = PreferenceRadioGroup;
@@ -0,0 +1,19 @@
1
+ import { jsxs, jsx } from '@emotion/react/jsx-runtime';
2
+ import { css } from '@emotion/react';
3
+ import { ToggleButtonGroup, ToggleButton } from 'react-aria-components';
4
+ import { toggleButtonStackedGroupStyles, toggleButtonRowsGroupStyles, toggleButtonStyles, radioGroupLabelStyles } from './styles.js';
5
+
6
+ function PreferenceRadioGroup({ name, options, currentValue, changeValue, theme, format = "stack" }) {
7
+ const groupCss = format === "stack" ? toggleButtonStackedGroupStyles(theme) : toggleButtonRowsGroupStyles(theme);
8
+ const buttonStyle = format === "stack" ? toggleButtonStyles(theme) : [toggleButtonStyles(theme), css({ flexBasis: "30%" })];
9
+ const defaultOptionId = options.find((option) => option.isDefault)?.id;
10
+ const selectedKeys = currentValue ? [currentValue] : defaultOptionId ? [defaultOptionId] : [];
11
+ return jsxs("label", { children: [jsx("div", { css: radioGroupLabelStyles(theme), children: name }), jsx(ToggleButtonGroup, { css: groupCss, selectionMode: "single", orientation: format === "stack" ? "vertical" : "horizontal", selectedKeys, onSelectionChange: (e) => {
12
+ const newValue = Array.from(e).pop() ?? currentValue;
13
+ if (typeof newValue === "string") {
14
+ changeValue(newValue);
15
+ }
16
+ }, children: options.map((option, index) => jsxs(ToggleButton, { id: option.id, css: buttonStyle, style: option.buttonStyle, children: [jsx("div", { style: option.labelStyle, children: option.label ?? option.id }), jsx("div", { children: option.description })] }, index)) })] });
17
+ }
18
+
19
+ export { PreferenceRadioGroup };
@@ -0,0 +1,67 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('@emotion/react/jsx-runtime');
4
+ var TitleText = require('../TitleText.cjs');
5
+ var defaultOptions = require('./default-options.cjs');
6
+ var PreferenceRadioGroup = require('./PreferenceRadioGroup.cjs');
7
+ var styles = require('./styles.cjs');
8
+
9
+ function UserMenu({
10
+ theme,
11
+ feedBacklink,
12
+ preferences,
13
+ updatePreferences,
14
+ textSizeOptions,
15
+ fontFamilyOptions,
16
+ colorSchemeOptions,
17
+ headingLevel
18
+ }) {
19
+ return /* @__PURE__ */ jsxRuntime.jsxs("aside", { css: styles.userMenuStyles(theme), children: [
20
+ /* @__PURE__ */ jsxRuntime.jsx(
21
+ TitleText.TitleText,
22
+ {
23
+ headingLevel,
24
+ css: styles.userMenuHeadingStyles(theme),
25
+ children: "Accessibility Settings"
26
+ }
27
+ ),
28
+ /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsxs("p", { children: [
29
+ "Customise your reading & writing experience.",
30
+ " ",
31
+ feedBacklink && /* @__PURE__ */ jsxRuntime.jsx("a", { href: feedBacklink, target: "_blank", rel: "noreferrer", children: "Send feedback" })
32
+ ] }) }),
33
+ (!textSizeOptions || textSizeOptions.length > 0) && /* @__PURE__ */ jsxRuntime.jsx(
34
+ PreferenceRadioGroup.PreferenceRadioGroup,
35
+ {
36
+ theme,
37
+ options: textSizeOptions ?? defaultOptions.textSizes,
38
+ name: "Text Size",
39
+ currentValue: preferences.fontpreferences,
40
+ changeValue: (fontpreferences) => updatePreferences({ fontpreferences })
41
+ }
42
+ ),
43
+ (!fontFamilyOptions || fontFamilyOptions.length > 0) && /* @__PURE__ */ jsxRuntime.jsx(
44
+ PreferenceRadioGroup.PreferenceRadioGroup,
45
+ {
46
+ theme,
47
+ options: fontFamilyOptions ?? defaultOptions.fontFamilies,
48
+ name: "Font Family",
49
+ currentValue: preferences.fontType,
50
+ changeValue: (fontType) => updatePreferences({ fontType })
51
+ }
52
+ ),
53
+ (!colorSchemeOptions || colorSchemeOptions.length > 0) && /* @__PURE__ */ jsxRuntime.jsx(
54
+ PreferenceRadioGroup.PreferenceRadioGroup,
55
+ {
56
+ theme,
57
+ format: "rows",
58
+ options: colorSchemeOptions ?? defaultOptions.colorSchemes,
59
+ name: "Color scheme",
60
+ currentValue: preferences.colorScheme,
61
+ changeValue: (colorScheme) => updatePreferences({ colorScheme })
62
+ }
63
+ )
64
+ ] });
65
+ }
66
+
67
+ exports.UserMenu = UserMenu;
@@ -0,0 +1,11 @@
1
+ import { jsxs, jsx } from '@emotion/react/jsx-runtime';
2
+ import { TitleText } from '../TitleText.js';
3
+ import { textSizes, fontFamilies, colorSchemes } from './default-options.js';
4
+ import { PreferenceRadioGroup } from './PreferenceRadioGroup.js';
5
+ import { userMenuStyles, userMenuHeadingStyles } from './styles.js';
6
+
7
+ function UserMenu({ theme, feedBacklink, preferences, updatePreferences, textSizeOptions, fontFamilyOptions, colorSchemeOptions, headingLevel }) {
8
+ return jsxs("aside", { css: userMenuStyles(theme), children: [jsx(TitleText, { headingLevel, css: userMenuHeadingStyles(theme), children: "Accessibility Settings" }), jsx("div", { children: jsxs("p", { children: ["Customise your reading & writing experience.", " ", feedBacklink && jsx("a", { href: feedBacklink, target: "_blank", rel: "noreferrer", children: "Send feedback" })] }) }), (!textSizeOptions || textSizeOptions.length > 0) && jsx(PreferenceRadioGroup, { theme, options: textSizeOptions ?? textSizes, name: "Text Size", currentValue: preferences.fontpreferences, changeValue: (fontpreferences) => updatePreferences({ fontpreferences }) }), (!fontFamilyOptions || fontFamilyOptions.length > 0) && jsx(PreferenceRadioGroup, { theme, options: fontFamilyOptions ?? fontFamilies, name: "Font Family", currentValue: preferences.fontType, changeValue: (fontType) => updatePreferences({ fontType }) }), (!colorSchemeOptions || colorSchemeOptions.length > 0) && jsx(PreferenceRadioGroup, { theme, format: "rows", options: colorSchemeOptions ?? colorSchemes, name: "Color scheme", currentValue: preferences.colorScheme, changeValue: (colorScheme) => updatePreferences({ colorScheme }) })] });
9
+ }
10
+
11
+ export { UserMenu };
@@ -0,0 +1,109 @@
1
+ 'use strict';
2
+
3
+ var spacing = require('../../styleD/build/typescript/base/spacing.cjs');
4
+ var typography = require('../../styleD/build/typescript/base/typography.cjs');
5
+
6
+ const textSizes = [
7
+ {
8
+ id: "font-preference-small",
9
+ label: "Small",
10
+ description: "Compact reading",
11
+ labelStyle: {
12
+ fontSize: typography.baseTypography.size["12-px"]
13
+ }
14
+ },
15
+ {
16
+ id: "font-preference-medium",
17
+ label: "Medium",
18
+ description: "Standard reading",
19
+ labelStyle: {
20
+ fontSize: typography.baseTypography.size["16-px"]
21
+ }
22
+ },
23
+ {
24
+ id: "font-preference-large",
25
+ label: "Large",
26
+ description: "Comfortable reading",
27
+ labelStyle: {
28
+ fontSize: typography.baseTypography.size["20-px"]
29
+ }
30
+ }
31
+ ];
32
+ const fontFamilies = [
33
+ {
34
+ id: "font-serif",
35
+ label: "Guardian Text Egyptian",
36
+ description: "Classic Guardian Serif",
37
+ labelStyle: {
38
+ fontFamily: typography.baseTypography.family["Guardian Text Egyptian"],
39
+ fontSize: typography.baseTypography.size["20-px"]
40
+ }
41
+ },
42
+ {
43
+ id: "open-sans-compact",
44
+ label: "Open Sans Compact",
45
+ description: "compact sans-Serif",
46
+ labelStyle: {
47
+ fontFamily: typography.baseTypography.family["Open Sans Compact"],
48
+ fontSize: typography.baseTypography.size["20-px"]
49
+ }
50
+ },
51
+ {
52
+ id: "open-sans",
53
+ label: "Open Sans",
54
+ description: "Sans-Serif",
55
+ labelStyle: {
56
+ fontFamily: typography.baseTypography.family["Open Sans"],
57
+ fontSize: typography.baseTypography.size["20-px"]
58
+ }
59
+ }
60
+ ];
61
+ const colorSchemes = [
62
+ {
63
+ id: "white",
64
+ buttonStyle: {
65
+ backgroundColor: "white",
66
+ padding: spacing.baseSpacing["10-rem"]
67
+ },
68
+ isDefault: true
69
+ },
70
+ {
71
+ id: "cream",
72
+ buttonStyle: {
73
+ backgroundColor: "antiquewhite",
74
+ padding: spacing.baseSpacing["10-rem"]
75
+ }
76
+ },
77
+ {
78
+ id: "green",
79
+ buttonStyle: {
80
+ backgroundColor: "lightgreen",
81
+ padding: spacing.baseSpacing["10-rem"]
82
+ }
83
+ },
84
+ {
85
+ id: "pink",
86
+ buttonStyle: {
87
+ backgroundColor: "pink",
88
+ padding: spacing.baseSpacing["10-rem"]
89
+ }
90
+ },
91
+ {
92
+ id: "blue",
93
+ buttonStyle: {
94
+ backgroundColor: "skyblue",
95
+ padding: spacing.baseSpacing["10-rem"]
96
+ }
97
+ },
98
+ {
99
+ id: "orange",
100
+ buttonStyle: {
101
+ backgroundColor: "orange",
102
+ padding: spacing.baseSpacing["10-rem"]
103
+ }
104
+ }
105
+ ];
106
+
107
+ exports.colorSchemes = colorSchemes;
108
+ exports.fontFamilies = fontFamilies;
109
+ exports.textSizes = textSizes;
@@ -0,0 +1,105 @@
1
+ import { baseSpacing } from '../../styleD/build/typescript/base/spacing.js';
2
+ import { baseTypography } from '../../styleD/build/typescript/base/typography.js';
3
+
4
+ const textSizes = [
5
+ {
6
+ id: "font-preference-small",
7
+ label: "Small",
8
+ description: "Compact reading",
9
+ labelStyle: {
10
+ fontSize: baseTypography.size["12-px"]
11
+ }
12
+ },
13
+ {
14
+ id: "font-preference-medium",
15
+ label: "Medium",
16
+ description: "Standard reading",
17
+ labelStyle: {
18
+ fontSize: baseTypography.size["16-px"]
19
+ }
20
+ },
21
+ {
22
+ id: "font-preference-large",
23
+ label: "Large",
24
+ description: "Comfortable reading",
25
+ labelStyle: {
26
+ fontSize: baseTypography.size["20-px"]
27
+ }
28
+ }
29
+ ];
30
+ const fontFamilies = [
31
+ {
32
+ id: "font-serif",
33
+ label: "Guardian Text Egyptian",
34
+ description: "Classic Guardian Serif",
35
+ labelStyle: {
36
+ fontFamily: baseTypography.family["Guardian Text Egyptian"],
37
+ fontSize: baseTypography.size["20-px"]
38
+ }
39
+ },
40
+ {
41
+ id: "open-sans-compact",
42
+ label: "Open Sans Compact",
43
+ description: "compact sans-Serif",
44
+ labelStyle: {
45
+ fontFamily: baseTypography.family["Open Sans Compact"],
46
+ fontSize: baseTypography.size["20-px"]
47
+ }
48
+ },
49
+ {
50
+ id: "open-sans",
51
+ label: "Open Sans",
52
+ description: "Sans-Serif",
53
+ labelStyle: {
54
+ fontFamily: baseTypography.family["Open Sans"],
55
+ fontSize: baseTypography.size["20-px"]
56
+ }
57
+ }
58
+ ];
59
+ const colorSchemes = [
60
+ {
61
+ id: "white",
62
+ buttonStyle: {
63
+ backgroundColor: "white",
64
+ padding: baseSpacing["10-rem"]
65
+ },
66
+ isDefault: true
67
+ },
68
+ {
69
+ id: "cream",
70
+ buttonStyle: {
71
+ backgroundColor: "antiquewhite",
72
+ padding: baseSpacing["10-rem"]
73
+ }
74
+ },
75
+ {
76
+ id: "green",
77
+ buttonStyle: {
78
+ backgroundColor: "lightgreen",
79
+ padding: baseSpacing["10-rem"]
80
+ }
81
+ },
82
+ {
83
+ id: "pink",
84
+ buttonStyle: {
85
+ backgroundColor: "pink",
86
+ padding: baseSpacing["10-rem"]
87
+ }
88
+ },
89
+ {
90
+ id: "blue",
91
+ buttonStyle: {
92
+ backgroundColor: "skyblue",
93
+ padding: baseSpacing["10-rem"]
94
+ }
95
+ },
96
+ {
97
+ id: "orange",
98
+ buttonStyle: {
99
+ backgroundColor: "orange",
100
+ padding: baseSpacing["10-rem"]
101
+ }
102
+ }
103
+ ];
104
+
105
+ export { colorSchemes, fontFamilies, textSizes };
@@ -0,0 +1,90 @@
1
+ 'use strict';
2
+
3
+ var react = require('@emotion/react');
4
+ var userMenu = require('../../styleD/build/typescript/component/userMenu.cjs');
5
+ var mergeDeep = require('../../util/mergeDeep.cjs');
6
+
7
+ const userMenuStyles = (partialTheme = {}) => {
8
+ const { container } = mergeDeep.mergeDeep(userMenu.componentUserMenu, partialTheme);
9
+ return react.css`
10
+ background-color: ${container.backgroundColor};
11
+ display: flex;
12
+ flex-direction: column;
13
+ width: ${container.width};
14
+ padding-left: ${container.paddingX};
15
+ padding-right: ${container.paddingX};
16
+ padding-top: ${container.paddingY};
17
+ padding-bottom: ${container.paddingY};
18
+ `;
19
+ };
20
+ const userMenuHeadingStyles = (partialTheme = {}) => {
21
+ const { heading } = mergeDeep.mergeDeep(userMenu.componentUserMenu, partialTheme);
22
+ return react.css`
23
+ font-weight: ${heading.fontWeight};
24
+ font-size: ${heading.fontSize};
25
+ text-align: ${heading.textAlign};
26
+ padding-left: ${heading.paddingLeft};
27
+ padding-right: ${heading.paddingRight};
28
+ padding-top: ${heading.paddingTop};
29
+ padding-bottom: ${heading.paddingBottom};
30
+ `;
31
+ };
32
+ const toggleButtonStackedGroupStyles = (partialTheme = {}) => {
33
+ const { toggleButton } = mergeDeep.mergeDeep(userMenu.componentUserMenu, partialTheme);
34
+ return react.css`
35
+ display: flex;
36
+ flex-direction: column;
37
+ gap: ${toggleButton.gap};
38
+ `;
39
+ };
40
+ const radioGroupLabelStyles = (partialTheme = {}) => {
41
+ const { label } = mergeDeep.mergeDeep(userMenu.componentUserMenu, partialTheme);
42
+ return react.css`
43
+ font-weight: ${label.fontWeight};
44
+ font-size: ${label.fontSize};
45
+ text-align: ${label.textAlign};
46
+ padding-left: ${label.paddingLeft};
47
+ padding-right: ${label.paddingRight};
48
+ padding-top: ${label.paddingTop};
49
+ padding-bottom: ${label.paddingBottom};
50
+ `;
51
+ };
52
+ const toggleButtonRowsGroupStyles = (partialTheme = {}) => {
53
+ const { toggleButton } = mergeDeep.mergeDeep(userMenu.componentUserMenu, partialTheme);
54
+ return react.css`
55
+ display: flex;
56
+ flex-direction: row;
57
+ justify-content: space-between;
58
+ flex-wrap: wrap;
59
+ gap: ${toggleButton.gap};
60
+ `;
61
+ };
62
+ const toggleButtonStyles = (partialTheme = {}) => {
63
+ const { toggleButton } = mergeDeep.mergeDeep(userMenu.componentUserMenu, partialTheme);
64
+ return react.css`
65
+ border-radius: 0;
66
+ border-style: solid;
67
+ border-color: ${toggleButton.baseBorderColor};
68
+ background-color: ${toggleButton.baseBackgroundColor};
69
+
70
+ &[data-disabled] {
71
+ background-color: ${toggleButton.disabledBackgroundColor};
72
+ }
73
+
74
+ &[data-focus-visible] {
75
+ outline-offset: 1px;
76
+ outline: 2px solid blue;
77
+ }
78
+
79
+ &[data-selected] {
80
+ border-color: ${toggleButton.selectedBorderColor};
81
+ }
82
+ `;
83
+ };
84
+
85
+ exports.radioGroupLabelStyles = radioGroupLabelStyles;
86
+ exports.toggleButtonRowsGroupStyles = toggleButtonRowsGroupStyles;
87
+ exports.toggleButtonStackedGroupStyles = toggleButtonStackedGroupStyles;
88
+ exports.toggleButtonStyles = toggleButtonStyles;
89
+ exports.userMenuHeadingStyles = userMenuHeadingStyles;
90
+ exports.userMenuStyles = userMenuStyles;