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.
- package/CHANGELOG.md +38 -0
- package/lib/components/Actions/Actions.docs.tsx +1 -1
- package/lib/components/Autosuggest/Autosuggest.screenshots.tsx +43 -1
- package/lib/components/Autosuggest/Autosuggest.tsx +2 -1
- package/lib/components/Badge/Badge.docs.tsx +1 -1
- package/lib/components/Button/Button.docs.tsx +1 -1
- package/lib/components/ButtonLink/ButtonLink.docs.tsx +1 -1
- package/lib/components/Card/Card.docs.tsx +1 -1
- package/lib/components/Checkbox/Checkbox.docs.tsx +17 -9
- package/lib/components/Checkbox/CheckboxStandalone.screenshots.tsx +17 -9
- package/lib/components/Divider/Divider.docs.tsx +1 -1
- package/lib/components/Dropdown/Dropdown.docs.tsx +16 -7
- package/lib/components/Dropdown/Dropdown.screenshots.tsx +51 -1
- package/lib/components/Dropdown/Dropdown.tsx +1 -1
- package/lib/components/FieldLabel/FieldLabel.docs.tsx +150 -12
- package/lib/components/FieldLabel/FieldLabel.screenshots.tsx +13 -0
- package/lib/components/FieldLabel/FieldLabel.tsx +3 -1
- package/lib/components/FieldMessage/FieldMessage.docs.tsx +4 -21
- package/lib/components/Loader/Loader.css.ts +3 -8
- package/lib/components/MonthPicker/MonthPicker.screenshots.tsx +23 -1
- package/lib/components/Notice/Notice.docs.tsx +1 -1
- package/lib/components/PasswordField/PasswordField.screenshots.tsx +32 -10
- package/lib/components/PasswordField/PasswordField.tsx +2 -1
- package/lib/components/Radio/Radio.screenshots.tsx +17 -9
- package/lib/components/RadioGroup/RadioGroup.screenshots.tsx +14 -17
- package/lib/components/Tabs/Tabs.docs.tsx +1 -1
- package/lib/components/Tag/Tag.docs.tsx +1 -1
- package/lib/components/TextField/TextField.docs.tsx +3 -3
- package/lib/components/TextField/TextField.screenshots.tsx +70 -32
- package/lib/components/TextField/TextField.tsx +2 -1
- package/lib/components/TextLinkButton/TextLinkButton.docs.tsx +2 -2
- package/lib/components/TextLinkButton/TextLinkButton.tsx +3 -1
- package/lib/components/Textarea/Textarea.docs.tsx +2 -2
- package/lib/components/Textarea/Textarea.screenshots.tsx +61 -28
- package/lib/components/Textarea/Textarea.tsx +1 -1
- package/lib/components/private/Field/ClearField.tsx +1 -0
- package/lib/components/private/Field/Field.tsx +9 -3
- package/lib/components/private/FieldGroup/FieldGroup.tsx +1 -0
- package/lib/components/private/FieldOverlay/FieldOverlay.tsx +1 -0
- package/lib/css/atoms/sprinkles.css.ts +13 -13
- package/lib/css/reset/reset.css.ts +9 -6
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# braid-design-system
|
|
2
2
|
|
|
3
|
+
## 30.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- **TextLinkButton:** Add support for `tabIndex` ([#1025](https://github.com/seek-oss/braid-design-system/pull/1025))
|
|
8
|
+
|
|
9
|
+
## 30.5.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Move `@types/react` to devDependencies ([#1023](https://github.com/seek-oss/braid-design-system/pull/1023))
|
|
14
|
+
|
|
15
|
+
Braid requires consumers to provide React, therefore they should also provide the appropriate version of `@types/react` rather than rely on the version installed in Braid.
|
|
16
|
+
|
|
17
|
+
## 30.5.0
|
|
18
|
+
|
|
19
|
+
### Minor Changes
|
|
20
|
+
|
|
21
|
+
- **FieldLabel:** Dim label when `disabled` ([#1019](https://github.com/seek-oss/braid-design-system/pull/1019))
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- **Autosuggest, Dropdown, MonthPicker, PasswordField, TextField, Textarea:** Hide `placeholder` text when field is `disabled` ([#1019](https://github.com/seek-oss/braid-design-system/pull/1019))
|
|
26
|
+
|
|
27
|
+
- **Autosuggest, Checkbox, CheckboxStandalone, Dropdown, MonthPicker, TextField, Textarea, Radio, RadioGroup:** Dim the field value and label when field is `disabled` ([#1019](https://github.com/seek-oss/braid-design-system/pull/1019))
|
|
28
|
+
|
|
29
|
+
- **Autosuggest, TextField:** Hide clear button when field is `disabled`. ([#1019](https://github.com/seek-oss/braid-design-system/pull/1019))
|
|
30
|
+
|
|
31
|
+
## 30.4.3
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- **Buttons, Fields, TextLinks, Toggle:** Use `span` for field state overlays instead of `div` ([#1006](https://github.com/seek-oss/braid-design-system/pull/1006))
|
|
36
|
+
|
|
37
|
+
Produce more valid HTML as `div` elements are not as flexible with which elements they can be inside (from a validators perspective).
|
|
38
|
+
|
|
39
|
+
- Update vanilla-extract dependencies ([#1008](https://github.com/seek-oss/braid-design-system/pull/1008))
|
|
40
|
+
|
|
3
41
|
## 30.4.2
|
|
4
42
|
|
|
5
43
|
### Patch Changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useState, ReactNode } from 'react';
|
|
2
2
|
import { ComponentScreenshot } from '../../../site/src/types';
|
|
3
|
-
import { Autosuggest, filterSuggestions, IconSearch } from '../';
|
|
3
|
+
import { Autosuggest, filterSuggestions, IconSearch, Stack } from '../';
|
|
4
4
|
|
|
5
5
|
const Container = ({ children }: { children: ReactNode }) => (
|
|
6
6
|
<div style={{ maxWidth: '300px' }}>{children}</div>
|
|
@@ -148,6 +148,48 @@ export const screenshots: ComponentScreenshot = {
|
|
|
148
148
|
);
|
|
149
149
|
},
|
|
150
150
|
},
|
|
151
|
+
{
|
|
152
|
+
label: 'Autosuggest when disabled',
|
|
153
|
+
Container,
|
|
154
|
+
Example: ({ id, handler }) => (
|
|
155
|
+
<Stack space="gutter">
|
|
156
|
+
<Autosuggest
|
|
157
|
+
label="With no value or placeholder"
|
|
158
|
+
id={`${id}_1`}
|
|
159
|
+
value={{ text: '' }}
|
|
160
|
+
disabled={true}
|
|
161
|
+
onChange={handler}
|
|
162
|
+
suggestions={[]}
|
|
163
|
+
/>
|
|
164
|
+
<Autosuggest
|
|
165
|
+
label="With value and no placeholder"
|
|
166
|
+
id={`${id}_2`}
|
|
167
|
+
value={{ text: 'Text value' }}
|
|
168
|
+
disabled={true}
|
|
169
|
+
onChange={handler}
|
|
170
|
+
suggestions={[]}
|
|
171
|
+
/>
|
|
172
|
+
<Autosuggest
|
|
173
|
+
label="With no value and a placeholder"
|
|
174
|
+
id={`${id}_3`}
|
|
175
|
+
value={{ text: '' }}
|
|
176
|
+
disabled={true}
|
|
177
|
+
placeholder="Placeholder text"
|
|
178
|
+
onChange={handler}
|
|
179
|
+
suggestions={[]}
|
|
180
|
+
/>
|
|
181
|
+
<Autosuggest
|
|
182
|
+
label="With value and a placeholder"
|
|
183
|
+
id={`${id}_4`}
|
|
184
|
+
value={{ text: 'Text value' }}
|
|
185
|
+
disabled={true}
|
|
186
|
+
placeholder="Placeholder text"
|
|
187
|
+
onChange={handler}
|
|
188
|
+
suggestions={[]}
|
|
189
|
+
/>
|
|
190
|
+
</Stack>
|
|
191
|
+
),
|
|
192
|
+
},
|
|
151
193
|
{
|
|
152
194
|
label: 'Autosuggest with no visual label',
|
|
153
195
|
Container,
|
|
@@ -499,7 +499,7 @@ export const Autosuggest = forwardRef(function <Value>(
|
|
|
499
499
|
const inputProps = {
|
|
500
500
|
value: previewValue ? previewValue.text : value.text,
|
|
501
501
|
type: type === 'search' ? type : 'text',
|
|
502
|
-
placeholder,
|
|
502
|
+
placeholder: !restProps.disabled ? placeholder : undefined,
|
|
503
503
|
onChange: (e: ChangeEvent<HTMLInputElement>) => {
|
|
504
504
|
const inputValue = e.target.value;
|
|
505
505
|
|
|
@@ -590,6 +590,7 @@ export const Autosuggest = forwardRef(function <Value>(
|
|
|
590
590
|
|
|
591
591
|
const clearable = Boolean(
|
|
592
592
|
typeof onClear !== 'undefined' &&
|
|
593
|
+
!restProps.disabled &&
|
|
593
594
|
typeof value !== 'undefined' &&
|
|
594
595
|
value.text.length > 0,
|
|
595
596
|
);
|
|
@@ -147,16 +147,24 @@ const docs: ComponentDocs = {
|
|
|
147
147
|
to the <Strong>disabled</Strong> prop.
|
|
148
148
|
</Text>
|
|
149
149
|
),
|
|
150
|
-
|
|
151
|
-
Example: ({ id, getState, toggleState }) =>
|
|
150
|
+
Example: ({ id, toggleState }) =>
|
|
152
151
|
source(
|
|
153
|
-
<
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
152
|
+
<Stack space="medium">
|
|
153
|
+
<Checkbox
|
|
154
|
+
id={id}
|
|
155
|
+
disabled={true}
|
|
156
|
+
checked={false}
|
|
157
|
+
onChange={() => toggleState('checked')}
|
|
158
|
+
label="Unchecked"
|
|
159
|
+
/>
|
|
160
|
+
<Checkbox
|
|
161
|
+
id={id}
|
|
162
|
+
disabled={true}
|
|
163
|
+
checked={true}
|
|
164
|
+
onChange={() => toggleState('checked')}
|
|
165
|
+
label="Checked"
|
|
166
|
+
/>
|
|
167
|
+
</Stack>,
|
|
160
168
|
),
|
|
161
169
|
},
|
|
162
170
|
{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import { ComponentScreenshot } from '../../../site/src/types';
|
|
3
|
-
import { CheckboxStandalone } from '../';
|
|
3
|
+
import { CheckboxStandalone, Stack } from '../';
|
|
4
4
|
|
|
5
5
|
export const screenshots: ComponentScreenshot = {
|
|
6
6
|
screenshotWidths: [320],
|
|
@@ -58,15 +58,23 @@ export const screenshots: ComponentScreenshot = {
|
|
|
58
58
|
},
|
|
59
59
|
{
|
|
60
60
|
label: 'Disabled',
|
|
61
|
-
background: 'card',
|
|
62
61
|
Example: ({ id, handler }) => (
|
|
63
|
-
<
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
62
|
+
<Stack space="gutter">
|
|
63
|
+
<CheckboxStandalone
|
|
64
|
+
id={id}
|
|
65
|
+
disabled={true}
|
|
66
|
+
checked={false}
|
|
67
|
+
onChange={handler}
|
|
68
|
+
aria-label="Disabled unchecked"
|
|
69
|
+
/>
|
|
70
|
+
<CheckboxStandalone
|
|
71
|
+
id={id}
|
|
72
|
+
disabled={true}
|
|
73
|
+
checked={true}
|
|
74
|
+
onChange={handler}
|
|
75
|
+
aria-label="Disabled checked"
|
|
76
|
+
/>
|
|
77
|
+
</Stack>
|
|
70
78
|
),
|
|
71
79
|
},
|
|
72
80
|
{
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
IconLocation,
|
|
11
11
|
Stack,
|
|
12
12
|
Heading,
|
|
13
|
+
Notice,
|
|
13
14
|
} from '../';
|
|
14
15
|
import source from '../../utils/source.macro';
|
|
15
16
|
|
|
@@ -202,13 +203,13 @@ const docs: ComponentDocs = {
|
|
|
202
203
|
</Text>
|
|
203
204
|
),
|
|
204
205
|
background: 'card',
|
|
205
|
-
Example: ({ id,
|
|
206
|
+
Example: ({ id, setState }) =>
|
|
206
207
|
source(
|
|
207
208
|
<Dropdown
|
|
208
209
|
label="Label"
|
|
209
210
|
id={id}
|
|
210
211
|
onChange={setState('dropdown')}
|
|
211
|
-
value=
|
|
212
|
+
value="Option 1"
|
|
212
213
|
disabled={true}
|
|
213
214
|
>
|
|
214
215
|
<option>Option 1</option>
|
|
@@ -219,10 +220,18 @@ const docs: ComponentDocs = {
|
|
|
219
220
|
{
|
|
220
221
|
label: 'Placeholder prompt',
|
|
221
222
|
description: (
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
223
|
+
<>
|
|
224
|
+
<Text>
|
|
225
|
+
Providing a <Strong>placeholder</Strong> will display as a prompt to
|
|
226
|
+
the user no value is selected.
|
|
227
|
+
</Text>
|
|
228
|
+
<Notice tone="info">
|
|
229
|
+
<Text>
|
|
230
|
+
A placeholder is not visible when the field is{' '}
|
|
231
|
+
<TextLink href="#disabled-field">disabled</TextLink>.
|
|
232
|
+
</Text>
|
|
233
|
+
</Notice>
|
|
234
|
+
</>
|
|
226
235
|
),
|
|
227
236
|
Example: ({ id, getState, setState }) =>
|
|
228
237
|
source(
|
|
@@ -242,7 +251,7 @@ const docs: ComponentDocs = {
|
|
|
242
251
|
label: 'Inserting an icon',
|
|
243
252
|
description: (
|
|
244
253
|
<Text>
|
|
245
|
-
For decoration and help
|
|
254
|
+
For decoration and help distinguishing fields an <Strong>icon</Strong>{' '}
|
|
246
255
|
can be provided. This will be placed in the left of the field and is
|
|
247
256
|
not interactive.
|
|
248
257
|
</Text>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
2
|
import { ComponentScreenshot } from '../../../site/src/types';
|
|
3
|
-
import { Dropdown, IconLocation } from '../';
|
|
3
|
+
import { Dropdown, IconLocation, Stack } from '../';
|
|
4
4
|
|
|
5
5
|
const Container = ({ children }: { children: ReactNode }) => (
|
|
6
6
|
<div style={{ maxWidth: '300px' }}>{children}</div>
|
|
@@ -88,6 +88,56 @@ export const screenshots: ComponentScreenshot = {
|
|
|
88
88
|
</Dropdown>
|
|
89
89
|
),
|
|
90
90
|
},
|
|
91
|
+
{
|
|
92
|
+
label: 'Dropdown in disabled state',
|
|
93
|
+
Container,
|
|
94
|
+
Example: ({ id, handler }) => (
|
|
95
|
+
<Stack space="gutter">
|
|
96
|
+
<Dropdown
|
|
97
|
+
label="With no value or placeholder"
|
|
98
|
+
id={`${id}_1`}
|
|
99
|
+
onChange={handler}
|
|
100
|
+
value=""
|
|
101
|
+
disabled={true}
|
|
102
|
+
>
|
|
103
|
+
<option value="1">Developer</option>
|
|
104
|
+
<option value="2">Designer</option>
|
|
105
|
+
</Dropdown>
|
|
106
|
+
<Dropdown
|
|
107
|
+
label="With value and no placeholder"
|
|
108
|
+
id={`${id}_2`}
|
|
109
|
+
onChange={handler}
|
|
110
|
+
value="1"
|
|
111
|
+
disabled={true}
|
|
112
|
+
>
|
|
113
|
+
<option value="1">Developer</option>
|
|
114
|
+
<option value="2">Designer</option>
|
|
115
|
+
</Dropdown>
|
|
116
|
+
<Dropdown
|
|
117
|
+
label="With no value and a placeholder"
|
|
118
|
+
id={`${id}_3`}
|
|
119
|
+
onChange={handler}
|
|
120
|
+
value=""
|
|
121
|
+
disabled={true}
|
|
122
|
+
placeholder="Placeholder text"
|
|
123
|
+
>
|
|
124
|
+
<option value="1">Developer</option>
|
|
125
|
+
<option value="2">Designer</option>
|
|
126
|
+
</Dropdown>
|
|
127
|
+
<Dropdown
|
|
128
|
+
label="With value and a placeholder"
|
|
129
|
+
id={`${id}_4`}
|
|
130
|
+
onChange={handler}
|
|
131
|
+
value="1"
|
|
132
|
+
disabled={true}
|
|
133
|
+
placeholder="Placeholder text"
|
|
134
|
+
>
|
|
135
|
+
<option value="1">Developer</option>
|
|
136
|
+
<option value="2">Designer</option>
|
|
137
|
+
</Dropdown>
|
|
138
|
+
</Stack>
|
|
139
|
+
),
|
|
140
|
+
},
|
|
91
141
|
{
|
|
92
142
|
label: 'Dropdown on Brand Background',
|
|
93
143
|
background: 'brand',
|
|
@@ -10,18 +10,23 @@ import {
|
|
|
10
10
|
Box,
|
|
11
11
|
Hidden,
|
|
12
12
|
Alert,
|
|
13
|
-
|
|
13
|
+
Notice,
|
|
14
14
|
} from '../';
|
|
15
15
|
import { Placeholder } from '../../playroom/components';
|
|
16
|
+
import { ReactNode } from 'markdown-to-jsx/node_modules/@types/react';
|
|
17
|
+
|
|
18
|
+
const Container = ({ children }: { children: ReactNode }) => (
|
|
19
|
+
<Box maxWidth="xsmall">{children}</Box>
|
|
20
|
+
);
|
|
16
21
|
|
|
17
22
|
const docs: ComponentDocs = {
|
|
18
23
|
category: 'Content',
|
|
19
24
|
Example: () =>
|
|
20
25
|
source(
|
|
21
|
-
<Box
|
|
22
|
-
<Stack space="
|
|
26
|
+
<Box maxWidth="xsmall">
|
|
27
|
+
<Stack space="xsmall">
|
|
23
28
|
<FieldLabel
|
|
24
|
-
htmlFor="
|
|
29
|
+
htmlFor="example"
|
|
25
30
|
label="Label"
|
|
26
31
|
secondaryLabel={
|
|
27
32
|
<>
|
|
@@ -34,7 +39,7 @@ const docs: ComponentDocs = {
|
|
|
34
39
|
</TextLink>
|
|
35
40
|
}
|
|
36
41
|
/>
|
|
37
|
-
<Box id="
|
|
42
|
+
<Box id="example">
|
|
38
43
|
<Placeholder height={40} />
|
|
39
44
|
</Box>
|
|
40
45
|
</Stack>
|
|
@@ -55,18 +60,151 @@ const docs: ComponentDocs = {
|
|
|
55
60
|
associate the label with its associated field.
|
|
56
61
|
</Text>
|
|
57
62
|
),
|
|
58
|
-
alternatives: [
|
|
63
|
+
alternatives: [
|
|
64
|
+
{
|
|
65
|
+
name: 'FieldMessage',
|
|
66
|
+
description: 'For displaying messages below a custom field.',
|
|
67
|
+
},
|
|
68
|
+
],
|
|
59
69
|
additional: [
|
|
60
70
|
{
|
|
61
|
-
label: '
|
|
71
|
+
label: 'Label',
|
|
72
|
+
Container,
|
|
73
|
+
description: <Text>Sets the primary label of field.</Text>,
|
|
74
|
+
Example: () =>
|
|
75
|
+
source(
|
|
76
|
+
<Stack space="xsmall">
|
|
77
|
+
<FieldLabel htmlFor="labelExample" label="Label" />
|
|
78
|
+
<Box id="labelExample">
|
|
79
|
+
<Placeholder height={40} />
|
|
80
|
+
</Box>
|
|
81
|
+
</Stack>,
|
|
82
|
+
),
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
label: 'Secondary label',
|
|
86
|
+
Container,
|
|
87
|
+
description: (
|
|
88
|
+
<>
|
|
89
|
+
<Text>
|
|
90
|
+
Provide additional context, typically used to indicate optionality
|
|
91
|
+
of a field.
|
|
92
|
+
</Text>
|
|
93
|
+
<Notice tone="info">
|
|
94
|
+
<Text>
|
|
95
|
+
Only displayed when provided in addition to a{' '}
|
|
96
|
+
<TextLink href="#label">label</TextLink>.
|
|
97
|
+
</Text>
|
|
98
|
+
</Notice>
|
|
99
|
+
</>
|
|
100
|
+
),
|
|
101
|
+
Example: () =>
|
|
102
|
+
source(
|
|
103
|
+
<Stack space="xsmall">
|
|
104
|
+
<FieldLabel
|
|
105
|
+
htmlFor="secondaryExample"
|
|
106
|
+
label="Label"
|
|
107
|
+
secondaryLabel="Secondary label"
|
|
108
|
+
/>
|
|
109
|
+
<Box id="secondaryExample">
|
|
110
|
+
<Placeholder height={40} />
|
|
111
|
+
</Box>
|
|
112
|
+
</Stack>,
|
|
113
|
+
),
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
label: 'Tertiary label',
|
|
117
|
+
Container,
|
|
118
|
+
description: (
|
|
119
|
+
<>
|
|
120
|
+
<Text>
|
|
121
|
+
Provide further context, typically used for providing assistance
|
|
122
|
+
with a field.
|
|
123
|
+
</Text>
|
|
124
|
+
<Notice tone="info">
|
|
125
|
+
<Text>
|
|
126
|
+
Only displayed when provided in addition to a{' '}
|
|
127
|
+
<TextLink href="#label">label</TextLink>.
|
|
128
|
+
</Text>
|
|
129
|
+
</Notice>
|
|
130
|
+
</>
|
|
131
|
+
),
|
|
132
|
+
Example: () =>
|
|
133
|
+
source(
|
|
134
|
+
<Stack space="xsmall">
|
|
135
|
+
<FieldLabel
|
|
136
|
+
htmlFor="tertiaryExample"
|
|
137
|
+
label="Label"
|
|
138
|
+
tertiaryLabel={
|
|
139
|
+
<TextLink href="#">
|
|
140
|
+
Tertiary<Hidden below="tablet"> label</Hidden>
|
|
141
|
+
</TextLink>
|
|
142
|
+
}
|
|
143
|
+
/>
|
|
144
|
+
<Box id="tertiaryExample">
|
|
145
|
+
<Placeholder height={40} />
|
|
146
|
+
</Box>
|
|
147
|
+
</Stack>,
|
|
148
|
+
),
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
label: 'Additional description',
|
|
152
|
+
Container,
|
|
62
153
|
description: (
|
|
63
|
-
|
|
64
|
-
<Text
|
|
65
|
-
|
|
66
|
-
|
|
154
|
+
<>
|
|
155
|
+
<Text>
|
|
156
|
+
Additional context can be provided with a{' '}
|
|
157
|
+
<Strong>description</Strong>. This will display below the field
|
|
158
|
+
label.
|
|
67
159
|
</Text>
|
|
68
|
-
|
|
160
|
+
<Alert tone="info">
|
|
161
|
+
<Text>
|
|
162
|
+
It is strongly recommended that a <Strong>descriptionId</Strong>{' '}
|
|
163
|
+
is also passed in, allowing the description to be associated with
|
|
164
|
+
your custom field via <Strong>aria-describedby</Strong> prop. This
|
|
165
|
+
will allow a screen reader to provide this additional context upon
|
|
166
|
+
focusing the field.
|
|
167
|
+
</Text>
|
|
168
|
+
</Alert>
|
|
169
|
+
</>
|
|
170
|
+
),
|
|
171
|
+
Example: () =>
|
|
172
|
+
source(
|
|
173
|
+
<Stack space="xsmall">
|
|
174
|
+
<FieldLabel
|
|
175
|
+
htmlFor="descriptionExample"
|
|
176
|
+
label="Label"
|
|
177
|
+
description="Extra information about the field"
|
|
178
|
+
descriptionId="fieldDescription"
|
|
179
|
+
/>
|
|
180
|
+
<Box id="descriptionExample" aria-describedby="fieldDescription">
|
|
181
|
+
<Placeholder height={40} />
|
|
182
|
+
</Box>
|
|
183
|
+
</Stack>,
|
|
184
|
+
),
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
label: 'Disabled field',
|
|
188
|
+
Container,
|
|
189
|
+
description: (
|
|
190
|
+
<Text>
|
|
191
|
+
Setting the <Strong>disabled</Strong> prop to <Strong>true</Strong>{' '}
|
|
192
|
+
dims the field label.
|
|
193
|
+
</Text>
|
|
69
194
|
),
|
|
195
|
+
Example: () =>
|
|
196
|
+
source(
|
|
197
|
+
<Stack space="xsmall">
|
|
198
|
+
<FieldLabel
|
|
199
|
+
htmlFor="disabledExample"
|
|
200
|
+
label="Label"
|
|
201
|
+
disabled={true}
|
|
202
|
+
/>
|
|
203
|
+
<Box id="disabledExample">
|
|
204
|
+
<Placeholder height={40} />
|
|
205
|
+
</Box>
|
|
206
|
+
</Stack>,
|
|
207
|
+
),
|
|
70
208
|
},
|
|
71
209
|
],
|
|
72
210
|
};
|
|
@@ -50,5 +50,18 @@ export const screenshots: ComponentScreenshot = {
|
|
|
50
50
|
/>
|
|
51
51
|
),
|
|
52
52
|
},
|
|
53
|
+
{
|
|
54
|
+
label: 'Field Label when disabled',
|
|
55
|
+
Container,
|
|
56
|
+
Example: ({ id }) => (
|
|
57
|
+
<FieldLabel
|
|
58
|
+
htmlFor={id}
|
|
59
|
+
label="Title"
|
|
60
|
+
disabled={true}
|
|
61
|
+
secondaryLabel="Optional"
|
|
62
|
+
tertiaryLabel={<TextLink href="#">Help?</TextLink>}
|
|
63
|
+
/>
|
|
64
|
+
),
|
|
65
|
+
},
|
|
53
66
|
],
|
|
54
67
|
};
|
|
@@ -10,6 +10,7 @@ export interface FieldLabelProps {
|
|
|
10
10
|
id?: string;
|
|
11
11
|
htmlFor: string | false;
|
|
12
12
|
label?: ReactNode;
|
|
13
|
+
disabled?: boolean;
|
|
13
14
|
secondaryLabel?: ReactNode;
|
|
14
15
|
tertiaryLabel?: ReactNode;
|
|
15
16
|
description?: ReactNode;
|
|
@@ -21,6 +22,7 @@ export const FieldLabel = ({
|
|
|
21
22
|
id,
|
|
22
23
|
htmlFor,
|
|
23
24
|
label,
|
|
25
|
+
disabled,
|
|
24
26
|
secondaryLabel,
|
|
25
27
|
tertiaryLabel,
|
|
26
28
|
description,
|
|
@@ -32,7 +34,7 @@ export const FieldLabel = ({
|
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
const labelEl = (
|
|
35
|
-
<Text>
|
|
37
|
+
<Text tone={disabled ? 'secondary' : undefined}>
|
|
36
38
|
<Strong>{label}</Strong>
|
|
37
39
|
{secondaryLabel ? <Secondary> ({secondaryLabel})</Secondary> : null}
|
|
38
40
|
</Text>
|
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import source from '../../utils/source.macro';
|
|
3
3
|
import { ComponentDocs } from '../../../site/src/types';
|
|
4
|
-
import {
|
|
5
|
-
FieldMessage,
|
|
6
|
-
Alert,
|
|
7
|
-
Text,
|
|
8
|
-
Strong,
|
|
9
|
-
List,
|
|
10
|
-
TextLink,
|
|
11
|
-
Stack,
|
|
12
|
-
Box,
|
|
13
|
-
} from '../';
|
|
4
|
+
import { FieldMessage, Alert, Text, Strong, Stack, Box } from '../';
|
|
14
5
|
import { Placeholder } from '../../playroom/components';
|
|
15
6
|
|
|
16
7
|
const docs: ComponentDocs = {
|
|
@@ -59,18 +50,10 @@ const docs: ComponentDocs = {
|
|
|
59
50
|
prop.
|
|
60
51
|
</Text>
|
|
61
52
|
),
|
|
62
|
-
alternatives: [
|
|
63
|
-
additional: [
|
|
53
|
+
alternatives: [
|
|
64
54
|
{
|
|
65
|
-
|
|
66
|
-
description:
|
|
67
|
-
<List space="large">
|
|
68
|
-
<Text tone="secondary">
|
|
69
|
-
<TextLink href="/components/FieldLabel">FieldLabel</TextLink>{' '}
|
|
70
|
-
— For displaying labels above a custom field.
|
|
71
|
-
</Text>
|
|
72
|
-
</List>
|
|
73
|
-
),
|
|
55
|
+
name: 'FieldLabel',
|
|
56
|
+
description: 'For displaying labels above a custom field',
|
|
74
57
|
},
|
|
75
58
|
],
|
|
76
59
|
};
|