Skip to content

Commit 6c3319c

Browse files
marissahuysentruytcastastrophe
authored andcommitted
chore(fieldlabel,form): pr edits
- added documentation around the "necessity indicator" being text - included a required state for the wrapping/truncation test changes - set default args for form items
1 parent d6da6ff commit 6c3319c

File tree

3 files changed

+64
-63
lines changed

3 files changed

+64
-63
lines changed

components/fieldlabel/stories/fieldlabel.stories.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ RightAligned.storyName = "Right-aligned";
9494

9595
/**
9696
* Field labels for required inputs can be marked with an asterisk at the end of the label. Optional inputs would then be understood to not have the asterisk. If using the asterisk icon, do not leave any space between the label text and the start of the `<svg>` element in the markup. Extra space should not be added in addition to the inline margin.
97+
*
98+
* The field label for a required field can display either the text “(required)”, or an asterisk.
9799
*/
98100
export const Required = Template.bind({});
99101
Required.args = {

components/fieldlabel/stories/fieldlabel.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ export const FieldLabelGroup = Variants({
1515
},
1616
{
1717
testHeading: "Wrapped",
18-
withStates: false,
1918
label: "Label example with longer text that will wrap to the next line. Sometimes there is an asterisk that marks it as required.",
2019
customStyles: { width: "200px" },
2120
},
2221
],
2322
stateData: [
2423
{
2524
testHeading: "Disabled",
25+
ignore: ["Wrapped"],
2626
isDisabled: true,
2727
customStyles: { width: "200px" },
2828
},

components/fieldlabel/stories/form.stories.js

Lines changed: 61 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,66 @@ export default {
4242
args: {
4343
rootClass: "spectrum-Form",
4444
labelPosition: "top",
45+
items: [
46+
{
47+
label: "Company title",
48+
id: "form-example-company",
49+
content: [
50+
(passthroughs, context) => TextField({
51+
...passthroughs,
52+
multiline: true,
53+
name: "field",
54+
}, context),
55+
],
56+
}, {
57+
label: "Email address",
58+
id: "form-example-email",
59+
content: [
60+
(passthroughs, context) => TextField({
61+
...passthroughs,
62+
type: "email",
63+
name: "email",
64+
}, context),
65+
],
66+
}, {
67+
label: "Country",
68+
id: "form-example-country",
69+
content: [
70+
(passthroughs, context) => Picker({
71+
...passthroughs,
72+
placeholder: "Select a country",
73+
name: "country",
74+
}, context),
75+
],
76+
}, {
77+
label: "Interest",
78+
id: "form-example-interests",
79+
content: [
80+
(passthroughs, context) => Fieldgroup({
81+
layout: "horizontal",
82+
items: [
83+
Checkbox({
84+
...passthroughs,
85+
label: "Kittens",
86+
customClasses: ["spectrum-FieldGroup-item"],
87+
}, context),
88+
Checkbox({
89+
...passthroughs,
90+
label: "Puppies",
91+
customClasses: ["spectrum-FieldGroup-item"],
92+
}, context),]
93+
}),
94+
],
95+
},{
96+
label: "Age",
97+
id: "form-example-amount",
98+
content: [
99+
(passthroughs, context) => Stepper({
100+
...passthroughs,
101+
}, context),
102+
]
103+
}
104+
],
45105
},
46106
parameters: {
47107
packageJson: pkgJson,
@@ -52,68 +112,7 @@ export default {
52112
* A stacked layout with the labels above the form fields. The class `.spectrum-Form--labelPosition` is applied to the form itself. You do not need to apply a specific class to the field label because `.spectrum-FieldLabel--left` is applied to each to each [field label](/docs/components-field-label--docs) by default.
53113
*/
54114
export const Default = FormGroup.bind({});
55-
Default.args = {
56-
items: [
57-
{
58-
label: "Company title",
59-
id: "form-example-company",
60-
content: [
61-
(passthroughs, context) => TextField({
62-
...passthroughs,
63-
multiline: true,
64-
name: "field",
65-
}, context),
66-
],
67-
}, {
68-
label: "Email address",
69-
id: "form-example-email",
70-
content: [
71-
(passthroughs, context) => TextField({
72-
...passthroughs,
73-
type: "email",
74-
name: "email",
75-
}, context),
76-
],
77-
}, {
78-
label: "Country",
79-
id: "form-example-country",
80-
content: [
81-
(passthroughs, context) => Picker({
82-
...passthroughs,
83-
placeholder: "Select a country",
84-
name: "country",
85-
}, context),
86-
],
87-
}, {
88-
label: "Interest",
89-
id: "form-example-interests",
90-
content: [
91-
(passthroughs, context) => Fieldgroup({
92-
layout: "horizontal",
93-
items: [
94-
Checkbox({
95-
...passthroughs,
96-
label: "Kittens",
97-
customClasses: ["spectrum-FieldGroup-item"],
98-
}, context),
99-
Checkbox({
100-
...passthroughs,
101-
label: "Puppies",
102-
customClasses: ["spectrum-FieldGroup-item"],
103-
}, context),]
104-
}),
105-
],
106-
},{
107-
label: "Age",
108-
id: "form-example-amount",
109-
content: [
110-
(passthroughs, context) => Stepper({
111-
...passthroughs,
112-
}, context),
113-
]
114-
}
115-
],
116-
};
115+
Default.args = {};
117116

118117
/**
119118
* A two column layout with left-aligned label text.

0 commit comments

Comments
 (0)