-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(input): add story descriptions to the input component
- Loading branch information
Dan Büschlen
committed
Nov 9, 2023
1 parent
b97ebd1
commit fda3cc3
Showing
2 changed files
with
80 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ import { ICON_NAMES } from "../../icon/icon.js" | |
export default { | ||
title: "Input", | ||
component: "leu-input", | ||
tags: ["autodocs"], | ||
argTypes: { | ||
size: { | ||
control: { | ||
|
@@ -69,28 +70,59 @@ export const Regular = Template.bind({}) | |
Regular.args = { | ||
label: "Vorname", | ||
} | ||
Regular.parameters = { | ||
docs: { | ||
description: { | ||
story: | ||
"To render a basic input field only the `label` attribute is required. The `label` is necessary for accessibility reasons.", | ||
}, | ||
}, | ||
} | ||
|
||
export const Filled = Template.bind({}) | ||
Filled.args = { | ||
label: "Name", | ||
value: "Andrea Hugentobler", | ||
} | ||
Filled.parameters = { | ||
docs: { | ||
description: { | ||
story: "To supply a value to the input field, use the `value` attribute.", | ||
}, | ||
}, | ||
} | ||
|
||
export const PrefixedNumber = Template.bind({}) | ||
PrefixedNumber.args = { | ||
label: "Preis", | ||
label: "Preis, in CHF", | ||
prefix: "CHF", | ||
type: "number", | ||
} | ||
PrefixedNumber.parameters = { | ||
docs: { | ||
description: { | ||
story: | ||
'With the `prefix` attribute you can add a string that is prepended to the input field. This is useful for defining a unit of the input value. Be aware that the prefix is not included in the value of the input field. It is also hidden from screen readers. You have to add the prefix to the `label` attribute like "Preis, in CHF".', | ||
}, | ||
}, | ||
} | ||
|
||
export const SuffixedNumber = Template.bind({}) | ||
SuffixedNumber.args = { | ||
label: "Länge", | ||
label: "Länge, in cm", | ||
suffix: "cm", | ||
type: "number", | ||
min: 90, | ||
max: 120, | ||
} | ||
SuffixedNumber.parameters = { | ||
docs: { | ||
description: { | ||
story: | ||
'With the `suffix` attribute you can add a string that is appended to the input field. This is useful for defining a unit of the input value. Be aware that the prefix is not included in the value of the input field. It is also hidden from screen readers. You have to add the suffix to the `label` attribute like "Länge, in cm".', | ||
}, | ||
}, | ||
} | ||
|
||
export const Disabled = Template.bind({}) | ||
Disabled.args = { | ||
|
@@ -110,13 +142,30 @@ Clearable.args = { | |
label: "Vorname", | ||
clearable: true, | ||
} | ||
Clearable.parameters = { | ||
docs: { | ||
description: { | ||
story: | ||
"The `clearable` attribute adds a button to the input field that clears the value. This is useful for search fields. The button is only visible if the input field has a value. The button will also not visible if the input is invalid.", | ||
}, | ||
}, | ||
} | ||
|
||
export const Search = Template.bind({}) | ||
Search.args = { | ||
label: "Suchen", | ||
clearable: true, | ||
size: SIZE_TYPES.SMALL, | ||
icon: "search", | ||
novalidate: true, | ||
} | ||
Search.parameters = { | ||
docs: { | ||
description: { | ||
story: | ||
"The input field can also be displayed in a smaller size. Search fields or input fields inside other components (e.g. Select or Pagination) usually use this option. To display the search icon, use the `icon` attribute. With `novalidate` the validation can be disabled.", | ||
}, | ||
}, | ||
} | ||
|
||
export const CustomError = Template.bind({}) | ||
|
@@ -126,3 +175,11 @@ CustomError.args = { | |
value: "[email protected]", | ||
error: "Diese E-Mail Adresse wird bereits verwendet.", | ||
} | ||
Search.parameters = { | ||
docs: { | ||
description: { | ||
story: | ||
"The input component uses the browsers native validation. If the data is sent to a server, then there it will be validated again. To display those errors, use the `error` attribute. It won't interfere with the native validation also wont be removed.", | ||
}, | ||
}, | ||
} |