braid-design-system 31.2.3 → 31.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # braid-design-system
2
2
 
3
+ ## 31.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - **vars:** Expose `contentWidth` theme tokens ([#1052](https://github.com/seek-oss/braid-design-system/pull/1052))
8
+
3
9
  ## 31.2.3
4
10
 
5
11
  ### Patch Changes
package/css/index.ts CHANGED
@@ -10,6 +10,7 @@ const {
10
10
  grid,
11
11
  space,
12
12
  touchableSize,
13
+ contentWidth,
13
14
  // TODO: COLORMODE RELEASE
14
15
  // Release new backgrounds
15
16
  backgroundColor: { surfaceDark: _, bodyDark: __, ...backgroundColor },
@@ -24,6 +25,7 @@ const vars = {
24
25
  grid,
25
26
  space,
26
27
  touchableSize,
28
+ contentWidth,
27
29
  backgroundColor,
28
30
  foregroundColor,
29
31
  textWeight,
package/css/vars.docs.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import React, { ReactNode } from 'react';
1
+ import React, { ReactNode, useEffect, useRef, useState } from 'react';
2
2
  import { vars } from '.';
3
3
  import {
4
4
  Text,
@@ -13,7 +13,7 @@ import {
13
13
  } from '../lib/components';
14
14
  import { ReactNodeNoStrings } from '../lib/components/private/ReactNodeNoStrings';
15
15
  import Code from '../site/src/App/Code/Code';
16
- import { ThemedExample } from '../site/src/App/ThemeSetting';
16
+ import { ThemedExample, useThemeSettings } from '../site/src/App/ThemeSetting';
17
17
  import { CssDoc } from '../site/src/types';
18
18
  import { VanillaMigrationBanner } from './VanillaMigrationBanner';
19
19
 
@@ -43,6 +43,32 @@ const Row = ({
43
43
  </Columns>
44
44
  );
45
45
 
46
+ const ContentWidthValue = ({ var: varName }: { var: string }) => {
47
+ const [size, setSize] = useState(0);
48
+ const { themeKey } = useThemeSettings();
49
+ const ref = useRef<HTMLDivElement | null>(null);
50
+
51
+ useEffect(() => {
52
+ if (ref.current && themeKey) {
53
+ setSize(ref.current.offsetWidth);
54
+ }
55
+ }, [themeKey]);
56
+
57
+ return (
58
+ <>
59
+ <Box
60
+ component="span"
61
+ position="absolute"
62
+ pointerEvents="none"
63
+ opacity={0}
64
+ ref={ref}
65
+ style={{ width: varName }}
66
+ />
67
+ {size > 0 ? `${size}px` : '&nbsp;'}
68
+ </>
69
+ );
70
+ };
71
+
46
72
  const varDocs: Record<keyof typeof vars, ReactNodeNoStrings> = {
47
73
  grid: (
48
74
  <Row name="grid">
@@ -67,6 +93,17 @@ const varDocs: Record<keyof typeof vars, ReactNodeNoStrings> = {
67
93
  />
68
94
  </Row>
69
95
  ),
96
+ contentWidth: (
97
+ <Stack space="medium" dividers>
98
+ {Object.entries(vars.contentWidth).map(([widthName, widthVar]) => (
99
+ <Row key={widthName} group="contentWidth" name={widthName}>
100
+ <Text>
101
+ <ContentWidthValue var={widthVar} />
102
+ </Text>
103
+ </Row>
104
+ ))}
105
+ </Stack>
106
+ ),
70
107
  space: (
71
108
  <Stack space="medium" dividers>
72
109
  {Object.entries(vars.space).map(([spaceName, spaceVar]) => (
@@ -215,8 +215,8 @@ const docs: ComponentDocs = {
215
215
  description: (
216
216
  <>
217
217
  <Text>
218
- For cases where actions need may need to be de-emphasized, you can
219
- set the button’s <Strong>tone</Strong> to <Strong>neutral.</Strong>
218
+ For cases where actions need to be de-emphasized, the{' '}
219
+ <Strong>tone</Strong> can be set to <Strong>neutral.</Strong>
220
220
  </Text>
221
221
  <Text>
222
222
  This makes the button follow the default text colour, including{' '}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "braid-design-system",
3
- "version": "31.2.3",
3
+ "version": "31.3.0",
4
4
  "description": "Themeable design system for the SEEK Group",
5
5
  "main": "lib/components/index.ts",
6
6
  "sideEffects": [