Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(docs): number-field page restructure (VIV-2118) #2037

Merged
merged 7 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions apps/docs/content/_data/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,13 @@
},
{
"title": "Number Field",
"page": "legacy",
"markdown": "./libs/components/src/lib/number-field/README.md"
"description": "The number-field component allows users to enter a number in a text field, and buttons to increment or decrement the value.",
"variations": "./libs/components/src/lib/number-field/VARIATIONS.md",
"guidelines": "./libs/components/src/lib/number-field/GUIDELINES.md",
"hideGuidelines": "true",
"code": "./libs/components/src/lib/number-field/README.md",
"accessibility": "./libs/components/src/lib/number-field/ACCESSIBILITY.md",
"useCases": "./libs/components/src/lib/number-field/USE-CASES.md"
},
{
"title": "Fab",
Expand Down
14 changes: 14 additions & 0 deletions libs/components/src/lib/number-field/ACCESSIBILITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
- If no label is set - it is highly recommended that `aria-label` will be added.
- The add / subtract buttons are automatically given a localized version of the words "Increment" and "Decrement" respectively. These can be overriden using `increment-button-aria-label` and `decrement-button-aria-label`.

```html
<vwc-number-field
aria-label="choose a number"
increment-button-aria-label="Add"
decrement-button-aria-label="Subtract"
></vwc-number-field>
```

## Resources

- [Vivid Number Field: Manual accessibility test](https://docs.google.com/spreadsheets/d/1HJuAWaADRbZqnvWJRArhBYP2G2aWSKWfWuAVovwsFjs/edit?gid=1175911860#gid=1175911860)
103 changes: 103 additions & 0 deletions libs/components/src/lib/number-field/GUIDELINES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
## Labelling

### Label

<docs-do-dont>
<docs-do slot="description" headline="Use the label attribute whenever possible" caption="It provides a description of the purpose of the Number Field to all users and it is accessibly linked to the input element.">

```html preview example
<vwc-number-field label="Wanted quantity"></vwc-number-field>
```

</docs-do>
<docs-do dont headline="Don't use the placeholder attribute as a label">

```html preview example
<vwc-number-field placeholder="Wanted quantity"></vwc-number-field>
```

It's bad for UX and accessibility.<br />[The problem with placeholders](https://www.deque.com/blog/accessible-forms-the-problem-with-placeholders/)

</docs-do>
</docs-do-dont>

### Helper Text

<docs-do-dont>
<docs-do slot="description" headline="Use helper text to provide extra information about the field" caption="It is visible to the user at all times and it is read out by screen readers when the user focuses on the input element.">

```html preview example
<vwc-number-field
label="Wanted quantity"
helper-text="set a number higher than 1 less than 10"
></vwc-number-field>
```

</docs-do>
</docs-do-dont>

## Scale

<docs-do-dont headline="Use condensed Number Fields when space is limited" reverse>

<div slot="description">

The `condensed` Text Field is useful when used inside other components (inside [data-grid-cell](/components/data-grid/#cell) or [action-group](/components/action-group/) for a [toolbar](/components/button/use-cases/#toolbars)) as they take up less space.

</div>
<docs-do>

```html preview example
<div class="container">
<vwc-data-grid>
<vwc-data-grid-row row-type="header">
<vwc-data-grid-cell cell-type="columnheader">User</vwc-data-grid-cell>
<vwc-data-grid-cell
class="controls"
cell-type="columnheader"
></vwc-data-grid-cell>
</vwc-data-grid-row>
<vwc-data-grid-row>
<vwc-data-grid-cell>
<vwc-number-field label="Wanted quantity"></vwc-number-field>
</vwc-data-grid-cell>
<vwc-data-grid-cell class="controls">
<vwc-button
appearance="outlined"
size="condensed"
icon="edit-line"
aria-label="Edit"
></vwc-button>
<vwc-button
appearance="outlined"
size="condensed"
icon="delete-line"
aria-label="Delete"
connotation="alert"
></vwc-button>
</vwc-data-grid-cell>
</vwc-data-grid-row>
</vwc-data-grid>
</div>

<style>
.conainer {
display: block;
padding: 8px 0;
}

.controls {
width: 5.75rem;
}
</style>
```

</docs-do>
</docs-do-dont>

## Related Components

- [Text Area](/components/text-area/)
- [Text Field](/components/text-field)
- [Combobox](/components/combobox/)
- [Searchable Select](/components/searchable-select/)
Loading
Loading