diff --git a/src/components/FieldNote/FieldNote-v2.module.css b/src/components/FieldNote/FieldNote-v2.module.css index a1d646fb1..7b93228b4 100755 --- a/src/components/FieldNote/FieldNote-v2.module.css +++ b/src/components/FieldNote/FieldNote-v2.module.css @@ -11,6 +11,9 @@ * Fieldnote */ .field-note { + display: flex; + align-items: center; + font: var(--eds-theme-typography-body-sm); color: var(--eds-theme-color-text-utility-default-secondary); diff --git a/src/components/InputField/InputField-v2.stories.tsx b/src/components/InputField/InputField-v2.stories.tsx index 8dd8aaac9..55e9f1287 100644 --- a/src/components/InputField/InputField-v2.stories.tsx +++ b/src/components/InputField/InputField-v2.stories.tsx @@ -28,12 +28,29 @@ export const Default: Story = { }, }; +/** + * Fields, when containing text, have a theme matching the rest of the interface. + */ +export const WithText: Story = { + args: { + label: 'Default input field', + fieldNote: 'This is a fieldnote.', + defaultValue: 'Text value', + }, +}; + +/** + * Fields do not required a `fieldNote`. + */ export const NoFieldnote: Story = { args: { label: 'Default input field', }, }; +/** + * Fields can have an error state. + */ export const Error: Story = { args: { label: 'Error input field', @@ -42,6 +59,9 @@ export const Error: Story = { }, }; +/** + * Fields can have a warning state. + */ export const Warning: Story = { args: { label: 'Warning input field', @@ -51,6 +71,9 @@ export const Warning: Story = { }, }; +/** + * Read-only fields can have a value and are not editable, but are different from disabled fields. + */ export const ReadOnly: Story = { args: { label: 'Read-only field', @@ -60,6 +83,9 @@ export const ReadOnly: Story = { }, }; +/** + * Fields can be marked as disabled (and contain a value in such cases). + */ export const Disabled: Story = { args: { label: 'Disabled input field', @@ -75,6 +101,9 @@ export const Disabled: Story = { }, }; +/** + * Fields can have a leading icon, indicating what kind of content can go into the field. + */ export const LeadingIcon: Story = { args: { leadingIcon: 'search', @@ -83,6 +112,9 @@ export const LeadingIcon: Story = { }, }; +/** + * Fields can be marked as required. + */ export const Required: Story = { args: { label: 'Input field with fieldNote', @@ -92,6 +124,9 @@ export const Required: Story = { }, }; +/** + * When not using a visible label with `InputField`, you must apply some time of ARIA label to the component, like `aria-label`. + */ export const NoVisibleLabel: Story = { args: { 'aria-label': 'Input for no visible label', @@ -100,6 +135,9 @@ export const NoVisibleLabel: Story = { }, }; +/** + * Password fields show dots instead of characters, to help with security. + */ export const Password: Story = { args: { label: 'Password', @@ -107,6 +145,9 @@ export const Password: Story = { }, }; +/** + * Fields can have an optional field hint added, for extra clarity. + */ export const ShowHint: Story = { args: { label: 'Field with Optional Hint', diff --git a/src/components/InputField/__snapshots__/InputField-v2.test.tsx.snap b/src/components/InputField/__snapshots__/InputField-v2.test.tsx.snap index 59edc9ff8..d22c9020b 100644 --- a/src/components/InputField/__snapshots__/InputField-v2.test.tsx.snap +++ b/src/components/InputField/__snapshots__/InputField-v2.test.tsx.snap @@ -46,7 +46,7 @@ exports[` Disabled story renders snapshot 1`] = ` > @@ -55,18 +55,18 @@ exports[` Disabled story renders snapshot 1`] = ` class="input-field__body input-field--has-fieldNote" >
This InputField is disabled
@@ -84,7 +84,7 @@ exports[` Error story renders snapshot 1`] = ` > @@ -93,16 +93,16 @@ exports[` Error story renders snapshot 1`] = ` class="input-field__body input-field--has-fieldNote" >
InputWithin story renders snapshot 1`] = ` > @@ -148,7 +148,7 @@ exports[` InputWithin story renders snapshot 1`] = `
LeadingIcon story renders snapshot 1`] = ` aria-invalid="false" aria-label="search field" class="input input-field__input--leading-icon" - id=":rc:" + id=":re:" placeholder="Search..." type="text" /> @@ -219,7 +219,7 @@ exports[` NoFieldnote story renders snapshot 1`] = ` > @@ -230,7 +230,7 @@ exports[` NoFieldnote story renders snapshot 1`] = `
@@ -250,18 +250,18 @@ exports[` NoVisibleLabel story renders snapshot 1`] = ` class="input-field__body input-field--has-fieldNote" >
This input field has no visible label
@@ -279,7 +279,7 @@ exports[` Password story renders snapshot 1`] = ` > @@ -290,7 +290,7 @@ exports[` Password story renders snapshot 1`] = ` @@ -308,7 +308,7 @@ exports[` ReadOnly story renders snapshot 1`] = ` > @@ -317,10 +317,10 @@ exports[` ReadOnly story renders snapshot 1`] = ` class="input-field__body input-field--has-fieldNote" > ReadOnly story renders snapshot 1`] = `
This will show up like text, but not be interactive
@@ -346,7 +346,7 @@ exports[` Required story renders snapshot 1`] = ` > @@ -360,17 +360,17 @@ exports[` Required story renders snapshot 1`] = ` class="input-field__body input-field--has-fieldNote" >
This is a fieldnote for a required input field.
@@ -388,7 +388,7 @@ exports[` ShowHint story renders snapshot 1`] = ` > @@ -404,7 +404,7 @@ exports[` ShowHint story renders snapshot 1`] = ` @@ -486,7 +486,7 @@ exports[` Warning story renders snapshot 1`] = ` > @@ -495,16 +495,16 @@ exports[` Warning story renders snapshot 1`] = ` class="input-field__body input-field--has-fieldNote" >
WithAMaxLength story renders snapshot 1`] = ` > @@ -562,7 +562,7 @@ exports[` WithAMaxLength story renders snapshot 1`] = ` WithARecommendedLength story renders snapshot 1`] = ` > @@ -609,7 +609,7 @@ exports[` WithARecommendedLength story renders snapshot 1`] = ` WithBothMaxAndRecommendedLength story renders snapshot 1 > @@ -653,10 +653,10 @@ exports[` WithBothMaxAndRecommendedLength story renders snapshot 1 class="input-field__body input-field--has-fieldNote" > WithBothMaxAndRecommendedLength story renders snapshot 1 >
WithBothMaxAndRecommendedLength story renders snapshot 1
`; + +exports[` WithText story renders snapshot 1`] = ` +
+
+
+ +
+
+ +
+
+ This is a fieldnote. +
+
+
+`;