braid-design-system 30.4.2 → 30.6.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/lib/components/Actions/Actions.docs.tsx +1 -1
  3. package/lib/components/Autosuggest/Autosuggest.screenshots.tsx +43 -1
  4. package/lib/components/Autosuggest/Autosuggest.tsx +2 -1
  5. package/lib/components/Badge/Badge.docs.tsx +1 -1
  6. package/lib/components/Button/Button.docs.tsx +1 -1
  7. package/lib/components/ButtonLink/ButtonLink.docs.tsx +1 -1
  8. package/lib/components/Card/Card.docs.tsx +1 -1
  9. package/lib/components/Checkbox/Checkbox.docs.tsx +17 -9
  10. package/lib/components/Checkbox/CheckboxStandalone.screenshots.tsx +17 -9
  11. package/lib/components/Divider/Divider.docs.tsx +1 -1
  12. package/lib/components/Dropdown/Dropdown.docs.tsx +16 -7
  13. package/lib/components/Dropdown/Dropdown.screenshots.tsx +51 -1
  14. package/lib/components/Dropdown/Dropdown.tsx +1 -1
  15. package/lib/components/FieldLabel/FieldLabel.docs.tsx +150 -12
  16. package/lib/components/FieldLabel/FieldLabel.screenshots.tsx +13 -0
  17. package/lib/components/FieldLabel/FieldLabel.tsx +3 -1
  18. package/lib/components/FieldMessage/FieldMessage.docs.tsx +4 -21
  19. package/lib/components/Loader/Loader.css.ts +3 -8
  20. package/lib/components/MonthPicker/MonthPicker.screenshots.tsx +23 -1
  21. package/lib/components/Notice/Notice.docs.tsx +1 -1
  22. package/lib/components/PasswordField/PasswordField.screenshots.tsx +32 -10
  23. package/lib/components/PasswordField/PasswordField.tsx +2 -1
  24. package/lib/components/Radio/Radio.screenshots.tsx +17 -9
  25. package/lib/components/RadioGroup/RadioGroup.screenshots.tsx +14 -17
  26. package/lib/components/Tabs/Tabs.docs.tsx +1 -1
  27. package/lib/components/Tag/Tag.docs.tsx +1 -1
  28. package/lib/components/TextField/TextField.docs.tsx +3 -3
  29. package/lib/components/TextField/TextField.screenshots.tsx +70 -32
  30. package/lib/components/TextField/TextField.tsx +2 -1
  31. package/lib/components/TextLinkButton/TextLinkButton.docs.tsx +2 -2
  32. package/lib/components/TextLinkButton/TextLinkButton.tsx +3 -1
  33. package/lib/components/Textarea/Textarea.docs.tsx +2 -2
  34. package/lib/components/Textarea/Textarea.screenshots.tsx +61 -28
  35. package/lib/components/Textarea/Textarea.tsx +1 -1
  36. package/lib/components/private/Field/ClearField.tsx +1 -0
  37. package/lib/components/private/Field/Field.tsx +9 -3
  38. package/lib/components/private/FieldGroup/FieldGroup.tsx +1 -0
  39. package/lib/components/private/FieldOverlay/FieldOverlay.tsx +1 -0
  40. package/lib/css/atoms/sprinkles.css.ts +13 -13
  41. package/lib/css/reset/reset.css.ts +9 -6
  42. package/package.json +6 -6
@@ -1,9 +1,4 @@
1
- import {
2
- composeStyles,
3
- keyframes,
4
- style,
5
- styleVariants,
6
- } from '@vanilla-extract/css';
1
+ import { keyframes, style, styleVariants } from '@vanilla-extract/css';
7
2
  import { responsiveStyle } from '../../css/responsiveStyle';
8
3
  import { vars } from '../../themes/vars.css';
9
4
 
@@ -52,7 +47,7 @@ const bounceAnimation = style({
52
47
  });
53
48
 
54
49
  const animationDelayInMs = 70;
55
- export const circle = composeStyles(
50
+ export const circle = style([
56
51
  bounceAnimation,
57
52
  style({
58
53
  transform: `translateY(1.4em)`,
@@ -65,7 +60,7 @@ export const circle = composeStyles(
65
60
  },
66
61
  },
67
62
  }),
68
- );
63
+ ]);
69
64
 
70
65
  export const animationDelayValueInMs = 800;
71
66
 
@@ -1,6 +1,6 @@
1
1
  import React, { ReactNode } from 'react';
2
2
  import { ComponentScreenshot } from '../../../site/src/types';
3
- import { MonthPicker } from '../';
3
+ import { MonthPicker, Stack } from '../';
4
4
 
5
5
  const Container = ({ children }: { children: ReactNode }) => (
6
6
  <div style={{ maxWidth: '300px' }}>{children}</div>
@@ -47,6 +47,28 @@ export const screenshots: ComponentScreenshot = {
47
47
  />
48
48
  ),
49
49
  },
50
+ {
51
+ label: 'Disabled',
52
+ Container,
53
+ Example: ({ id, handler }) => (
54
+ <Stack space="gutter">
55
+ <MonthPicker
56
+ id={`${id}_1`}
57
+ label="With value"
58
+ disabled={true}
59
+ value={{ month: 1, year: 2019 }}
60
+ onChange={handler}
61
+ />
62
+ <MonthPicker
63
+ id={`${id}_2`}
64
+ label="No value"
65
+ disabled={true}
66
+ value={{}}
67
+ onChange={handler}
68
+ />
69
+ </Stack>
70
+ ),
71
+ },
50
72
  {
51
73
  label: 'No visual label',
52
74
  Container,
@@ -8,7 +8,7 @@ const docs: ComponentDocs = {
8
8
  migrationGuide: true,
9
9
  Example: () =>
10
10
  source(
11
- <Card>
11
+ <Card rounded>
12
12
  <Stack space="medium">
13
13
  <Notice tone="promote">
14
14
  <Text>This is a promoted message.</Text>
@@ -1,6 +1,6 @@
1
1
  import React, { ReactNode, useState } from 'react';
2
2
  import { ComponentScreenshot } from '../../../site/src/types';
3
- import { PasswordField, TextLink } from '../';
3
+ import { PasswordField, Stack, TextLink } from '../';
4
4
 
5
5
  const Container = ({ children }: { children: ReactNode }) => (
6
6
  <div style={{ maxWidth: '300px' }}>{children}</div>
@@ -140,18 +140,40 @@ export const screenshots: ComponentScreenshot = {
140
140
  {
141
141
  label: 'PasswordField disabled',
142
142
  Container,
143
- Example: ({ id }) => {
144
- const [value, setValue] = useState('qwerty');
145
- return (
143
+ Example: ({ id, handler }) => (
144
+ <Stack space="gutter">
146
145
  <PasswordField
147
- label="Password"
148
- id={id}
149
- value={value}
150
- onChange={(ev) => setValue(ev.currentTarget.value)}
146
+ label="With no value or placeholder"
147
+ id={`${id}_1`}
148
+ value=""
151
149
  disabled={true}
150
+ onChange={handler}
152
151
  />
153
- );
154
- },
152
+ <PasswordField
153
+ label="With value and no placeholder"
154
+ id={`${id}_2`}
155
+ value="Text value"
156
+ disabled={true}
157
+ onChange={handler}
158
+ />
159
+ <PasswordField
160
+ label="With no value and a placeholder"
161
+ id={`${id}_3`}
162
+ value=""
163
+ disabled={true}
164
+ placeholder="Placeholder text"
165
+ onChange={handler}
166
+ />
167
+ <PasswordField
168
+ label="With value and a placeholder"
169
+ id={`${id}_4`}
170
+ value="Text value"
171
+ disabled={true}
172
+ placeholder="Placeholder text"
173
+ onChange={handler}
174
+ />
175
+ </Stack>
176
+ ),
155
177
  },
156
178
  {
157
179
  label: 'PasswordField on Brand Background',
@@ -83,6 +83,7 @@ export const PasswordField = forwardRef<HTMLInputElement, PasswordFieldProps>(
83
83
  labelId={undefined}
84
84
  disabled={disabled}
85
85
  secondaryMessage={null}
86
+ alwaysShowSecondaryIcon={!disabled}
86
87
  secondaryIcon={
87
88
  disabled ? null : (
88
89
  <IconButton
@@ -106,7 +107,7 @@ export const PasswordField = forwardRef<HTMLInputElement, PasswordFieldProps>(
106
107
  onChange={onChange}
107
108
  onFocus={onFocus}
108
109
  onBlur={onBlur}
109
- placeholder={placeholder}
110
+ placeholder={!disabled ? placeholder : undefined}
110
111
  {...fieldProps}
111
112
  ref={inputRef}
112
113
  />
@@ -1,6 +1,6 @@
1
1
  import React, { useState } from 'react';
2
2
  import { ComponentScreenshot } from '../../../site/src/types';
3
- import { Badge, Radio, Text } from '../';
3
+ import { Badge, Radio, Text, Stack } from '../';
4
4
 
5
5
  export const screenshots: ComponentScreenshot = {
6
6
  screenshotWidths: [320],
@@ -27,15 +27,23 @@ export const screenshots: ComponentScreenshot = {
27
27
  },
28
28
  {
29
29
  label: 'Disabled Radio Button',
30
- background: 'card',
31
30
  Example: ({ id, handler }) => (
32
- <Radio
33
- id={id}
34
- disabled={true}
35
- checked={false}
36
- onChange={handler}
37
- label="Label"
38
- />
31
+ <Stack space="gutter">
32
+ <Radio
33
+ id={`${id}_1`}
34
+ disabled={true}
35
+ checked={false}
36
+ onChange={handler}
37
+ label="Disabled unchecked"
38
+ />
39
+ <Radio
40
+ id={`${id}_2`}
41
+ disabled={true}
42
+ checked={true}
43
+ onChange={handler}
44
+ label="Disabled checked"
45
+ />
46
+ </Stack>
39
47
  ),
40
48
  },
41
49
  {
@@ -84,23 +84,20 @@ export const screenshots: ComponentScreenshot = {
84
84
  },
85
85
  {
86
86
  label: 'When disabled',
87
- Example: () => {
88
- const [state, setState] = useState('');
89
- return (
90
- <RadioGroup
91
- id="radiolist5"
92
- value={state}
93
- onChange={(e) => setState(e.currentTarget.value)}
94
- label="Experience"
95
- disabled
96
- >
97
- <RadioItem label="Less than one year" value="0" />
98
- <RadioItem label="1 year" value="1" />
99
- <RadioItem label="2 years" value="2" />
100
- <RadioItem label="3+ years " value="3" />
101
- </RadioGroup>
102
- );
103
- },
87
+ Example: ({ handler }) => (
88
+ <RadioGroup
89
+ id="radiolist5"
90
+ value="2"
91
+ onChange={handler}
92
+ label="Experience"
93
+ disabled
94
+ >
95
+ <RadioItem label="Less than one year" value="0" />
96
+ <RadioItem label="1 year" value="1" />
97
+ <RadioItem label="2 years" value="2" />
98
+ <RadioItem label="3+ years " value="3" />
99
+ </RadioGroup>
100
+ ),
104
101
  },
105
102
  {
106
103
  label: 'When disabled and critical',
@@ -22,7 +22,7 @@ const docs: ComponentDocs = {
22
22
  subComponents: ['TabsProvider', 'Tab', 'TabPanels', 'TabPanel'],
23
23
  Example: ({ id }) =>
24
24
  source(
25
- <Card>
25
+ <Card rounded>
26
26
  <TabsProvider id={id}>
27
27
  <Stack space="medium">
28
28
  <Tabs label="Test tabs">
@@ -8,7 +8,7 @@ const docs: ComponentDocs = {
8
8
  migrationGuide: true,
9
9
  Example: () =>
10
10
  source(
11
- <Card>
11
+ <Card rounded>
12
12
  <Inline space="small">
13
13
  <Tag>One</Tag>
14
14
  <Tag>Two</Tag>
@@ -150,13 +150,13 @@ const docs: ComponentDocs = {
150
150
  </Text>
151
151
  ),
152
152
  background: 'card',
153
- Example: ({ id, getState, setState }) =>
153
+ Example: ({ id, setState }) =>
154
154
  source(
155
155
  <TextField
156
156
  label="Label"
157
157
  id={id}
158
158
  onChange={setState('textfield')}
159
- value={getState('textfield')}
159
+ value="Text in disabled field"
160
160
  disabled={true}
161
161
  />,
162
162
  ),
@@ -209,7 +209,7 @@ const docs: ComponentDocs = {
209
209
  label: 'Inserting an icon',
210
210
  description: (
211
211
  <Text>
212
- For decoration and help disguinishing fields an <Strong>icon</Strong>{' '}
212
+ For decoration and help distinguishing fields an <Strong>icon</Strong>{' '}
213
213
  can be provided. This will be placed in the left of the field and is
214
214
  not interactive.
215
215
  </Text>
@@ -1,6 +1,6 @@
1
1
  import React, { useState, ReactNode } from 'react';
2
2
  import { ComponentScreenshot } from '../../../site/src/types';
3
- import { IconSearch, IconPhone, TextField, TextLink } from '../';
3
+ import { IconSearch, IconPhone, TextField, TextLink, Stack } from '../';
4
4
 
5
5
  const Container = ({ children }: { children: ReactNode }) => (
6
6
  <div style={{ maxWidth: '300px' }}>{children}</div>
@@ -14,10 +14,10 @@ export const screenshots: ComponentScreenshot = {
14
14
  Container,
15
15
  Example: ({ id, handler }) => (
16
16
  <TextField
17
- label="Job Title"
17
+ label="Label"
18
18
  id={id}
19
19
  onChange={handler}
20
- value="Senior Developer"
20
+ value="Text value"
21
21
  />
22
22
  ),
23
23
  },
@@ -26,7 +26,7 @@ export const screenshots: ComponentScreenshot = {
26
26
  Container,
27
27
  Example: ({ id, handler }) => (
28
28
  <TextField
29
- label="Job Title"
29
+ label="Label"
30
30
  id={id}
31
31
  onChange={handler}
32
32
  value="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
@@ -41,7 +41,7 @@ export const screenshots: ComponentScreenshot = {
41
41
 
42
42
  return (
43
43
  <TextField
44
- label="Job Title"
44
+ label="Label"
45
45
  id={id}
46
46
  onChange={(e) => setValue(e.currentTarget.value)}
47
47
  onClear={() => setValue('')}
@@ -58,10 +58,10 @@ export const screenshots: ComponentScreenshot = {
58
58
 
59
59
  return (
60
60
  <TextField
61
- label="Job Title"
61
+ label="Label"
62
62
  id={id}
63
63
  icon={<IconSearch />}
64
- placeholder="Enter a job title"
64
+ placeholder="Placeholder text"
65
65
  onChange={(e) => setValue(e.currentTarget.value)}
66
66
  value={value}
67
67
  />
@@ -73,7 +73,7 @@ export const screenshots: ComponentScreenshot = {
73
73
  Container,
74
74
  Example: ({ id, handler }) => (
75
75
  <TextField
76
- label="Job Title"
76
+ label="Label"
77
77
  id={id}
78
78
  onChange={handler}
79
79
  onClear={handler}
@@ -86,10 +86,10 @@ export const screenshots: ComponentScreenshot = {
86
86
  Container,
87
87
  Example: ({ id, handler }) => (
88
88
  <TextField
89
- label="Job Title"
89
+ label="Label"
90
90
  id={id}
91
91
  value=""
92
- message="e.g. Senior Developer"
92
+ message="Neutral message"
93
93
  onChange={handler}
94
94
  />
95
95
  ),
@@ -99,8 +99,8 @@ export const screenshots: ComponentScreenshot = {
99
99
  Container,
100
100
  Example: ({ id, handler }) => (
101
101
  <TextField
102
- label="Title"
103
- secondaryLabel="Optional"
102
+ label="Label"
103
+ secondaryLabel="Secondary"
104
104
  id={id}
105
105
  value=""
106
106
  onChange={handler}
@@ -112,8 +112,8 @@ export const screenshots: ComponentScreenshot = {
112
112
  Container,
113
113
  Example: ({ id, handler }) => (
114
114
  <TextField
115
- label="Title"
116
- secondaryLabel="Optional"
115
+ label="Label"
116
+ secondaryLabel="Secondary"
117
117
  tertiaryLabel={<TextLink href="#">Help?</TextLink>}
118
118
  id={id}
119
119
  value=""
@@ -125,7 +125,7 @@ export const screenshots: ComponentScreenshot = {
125
125
  label: 'TextField with no visual label',
126
126
  Container,
127
127
  Example: ({ id, handler }) => (
128
- <TextField aria-label="Title" id={id} value="" onChange={handler} />
128
+ <TextField aria-label="Label" id={id} value="" onChange={handler} />
129
129
  ),
130
130
  },
131
131
  {
@@ -133,8 +133,8 @@ export const screenshots: ComponentScreenshot = {
133
133
  Container,
134
134
  Example: ({ id, handler }) => (
135
135
  <TextField
136
- label="Title"
137
- secondaryLabel="Optional"
136
+ label="Label"
137
+ secondaryLabel="Secondary"
138
138
  description="Longer description of this field"
139
139
  id={id}
140
140
  value=""
@@ -143,15 +143,15 @@ export const screenshots: ComponentScreenshot = {
143
143
  ),
144
144
  },
145
145
  {
146
- label: 'TextField with error',
146
+ label: 'TextField with critical message',
147
147
  Container,
148
148
  Example: ({ id, handler }) => (
149
149
  <TextField
150
- label="Do you like Braid?"
150
+ label="Label"
151
151
  tone="critical"
152
152
  id={id}
153
- value="No"
154
- message="Answer is incorrect"
153
+ value="Text value"
154
+ message="Critical message"
155
155
  onChange={handler}
156
156
  />
157
157
  ),
@@ -161,25 +161,63 @@ export const screenshots: ComponentScreenshot = {
161
161
  Container,
162
162
  Example: ({ id, handler }) => (
163
163
  <TextField
164
- label="Do you like Braid?"
164
+ label="Label"
165
165
  id={id}
166
- value="Yes"
167
- message="Nice one!"
166
+ value="Text value"
167
+ message="Positive message"
168
168
  tone="positive"
169
169
  onChange={handler}
170
170
  />
171
171
  ),
172
172
  },
173
+ {
174
+ label: 'TextField disabled',
175
+ Container,
176
+ Example: ({ id, handler }) => (
177
+ <Stack space="gutter">
178
+ <TextField
179
+ label="With no value or placeholder"
180
+ id={`${id}_1`}
181
+ value=""
182
+ disabled={true}
183
+ onChange={handler}
184
+ />
185
+ <TextField
186
+ label="With value and no placeholder"
187
+ id={`${id}_2`}
188
+ value="Text value"
189
+ disabled={true}
190
+ onChange={handler}
191
+ />
192
+ <TextField
193
+ label="With no value and a placeholder"
194
+ id={`${id}_3`}
195
+ value=""
196
+ disabled={true}
197
+ placeholder="Placeholder text"
198
+ onChange={handler}
199
+ />
200
+ <TextField
201
+ label="With value and a placeholder"
202
+ id={`${id}_4`}
203
+ value="Text value"
204
+ disabled={true}
205
+ placeholder="Placeholder text"
206
+ onChange={handler}
207
+ />
208
+ </Stack>
209
+ ),
210
+ },
173
211
  {
174
212
  label: 'TextField on Brand Background',
175
213
  background: 'brand',
176
214
  Container,
177
215
  Example: ({ id, handler }) => (
178
216
  <TextField
179
- label="Job Title"
217
+ label="Label"
180
218
  id={id}
181
219
  onChange={handler}
182
- value="Senior Developer"
220
+ value="Text value"
183
221
  />
184
222
  ),
185
223
  },
@@ -188,11 +226,11 @@ export const screenshots: ComponentScreenshot = {
188
226
  Container,
189
227
  Example: ({ id, handler }) => (
190
228
  <TextField
191
- label="Amount"
229
+ label="Label"
192
230
  id={id}
193
231
  onChange={handler}
194
- prefix="AUD $"
195
- value="1000"
232
+ prefix="Prefix"
233
+ value="Text value"
196
234
  />
197
235
  ),
198
236
  },
@@ -201,12 +239,12 @@ export const screenshots: ComponentScreenshot = {
201
239
  Container,
202
240
  Example: ({ id, handler }) => (
203
241
  <TextField
204
- label="Phone number"
242
+ label="Label"
205
243
  id={id}
206
244
  onChange={handler}
207
245
  icon={<IconPhone />}
208
- prefix="+61"
209
- value="411 111 111"
246
+ prefix="Prefix"
247
+ value="Text value"
210
248
  />
211
249
  ),
212
250
  },
@@ -58,6 +58,7 @@ export const TextField = forwardRef<HTMLInputElement, TextFieldProps>(
58
58
 
59
59
  const clearable = Boolean(
60
60
  typeof onClear !== 'undefined' &&
61
+ !restProps.disabled &&
61
62
  typeof value === 'string' &&
62
63
  value.length > 0,
63
64
  );
@@ -96,7 +97,7 @@ export const TextField = forwardRef<HTMLInputElement, TextFieldProps>(
96
97
  onChange={onChange}
97
98
  onFocus={onFocus}
98
99
  onBlur={onBlur}
99
- placeholder={placeholder}
100
+ placeholder={!restProps.disabled ? placeholder : undefined}
100
101
  {...fieldProps}
101
102
  ref={inputRef}
102
103
  />
@@ -23,8 +23,8 @@ const docs: ComponentDocs = {
23
23
  accessibility: (
24
24
  <>
25
25
  <Text>
26
- Even thought is looks like a{' '}
27
- <TextLink href="/component/TextLink">TextLink</TextLink>, this is
26
+ Even though it looks like a{' '}
27
+ <TextLink href="/components/TextLink">TextLink</TextLink>, this is
28
28
  actually a semantic button following the{' '}
29
29
  <TextLink href="https://www.w3.org/TR/wai-aria-practices/#button">
30
30
  WAI-ARIA Button Pattern.
@@ -27,6 +27,7 @@ export interface TextLinkButtonProps
27
27
  'aria-controls'?: NativeSpanProps['aria-controls'];
28
28
  'aria-expanded'?: NativeSpanProps['aria-expanded'];
29
29
  'aria-describedby'?: NativeSpanProps['aria-describedby'];
30
+ tabIndex?: NativeSpanProps['tabIndex'];
30
31
  }
31
32
 
32
33
  const noop = () => {};
@@ -40,6 +41,7 @@ export const TextLinkButton = ({
40
41
  'aria-controls': ariaControls,
41
42
  'aria-expanded': ariaExpanded,
42
43
  'aria-describedby': ariaDescribedBy,
44
+ tabIndex,
43
45
  }: TextLinkButtonProps) => {
44
46
  const buttonRef = useRef<HTMLSpanElement>(null);
45
47
 
@@ -59,7 +61,7 @@ export const TextLinkButton = ({
59
61
  <Box
60
62
  ref={buttonRef}
61
63
  role="button"
62
- tabIndex={0}
64
+ tabIndex={tabIndex ?? 0}
63
65
  component="span"
64
66
  onClick={onClick}
65
67
  onKeyDown={handleKeyboard}
@@ -141,13 +141,13 @@ const docs: ComponentDocs = {
141
141
  </Text>
142
142
  ),
143
143
  background: 'card',
144
- Example: ({ id, getState, setState }) =>
144
+ Example: ({ id, setState }) =>
145
145
  source(
146
146
  <Textarea
147
147
  label="Label"
148
148
  id={id}
149
149
  onChange={setState('textarea')}
150
- value={getState('textarea')}
150
+ value="Text in disabled field"
151
151
  disabled={true}
152
152
  />,
153
153
  ),