@jobber/components-native 0.101.5 → 0.101.6
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/dist/docs/ActionItem/ActionItem.md +65 -0
- package/dist/docs/ActionItemGroup/ActionItemGroup.md +33 -0
- package/dist/docs/ActionLabel/ActionLabel.md +43 -0
- package/dist/docs/ActivityIndicator/ActivityIndicator.md +116 -0
- package/dist/docs/Animation/Animation.md +71 -0
- package/dist/docs/AtlantisThemeContext/AtlantisThemeContext.md +256 -0
- package/dist/docs/AutoLink/AutoLink.md +47 -0
- package/dist/docs/Banner/Banner.md +390 -0
- package/dist/docs/Borders/Borders.md +45 -0
- package/dist/docs/BottomSheet/BottomSheet.md +67 -0
- package/dist/docs/Button/Button.md +918 -0
- package/dist/docs/ButtonGroup/ButtonGroup.md +89 -0
- package/dist/docs/Card/Card.md +270 -0
- package/dist/docs/Checkbox/Checkbox.md +69 -0
- package/dist/docs/Chip/Chip.md +371 -0
- package/dist/docs/Colors/Colors.md +217 -0
- package/dist/docs/Content/Content.md +67 -0
- package/dist/docs/ContentOverlay/ContentOverlay.md +64 -0
- package/dist/docs/Disclosure/Disclosure.md +161 -0
- package/dist/docs/Divider/Divider.md +84 -0
- package/dist/docs/Elevations/Elevations.md +76 -0
- package/dist/docs/EmptyState/EmptyState.md +72 -0
- package/dist/docs/Flex/Flex.md +37 -0
- package/dist/docs/Form/Form.md +126 -0
- package/dist/docs/FormField/FormField.md +57 -0
- package/dist/docs/FormatFile/FormatFile.md +56 -0
- package/dist/docs/Glimmer/Glimmer.md +143 -0
- package/dist/docs/Heading/Heading.md +132 -0
- package/dist/docs/Icon/Icon.md +585 -0
- package/dist/docs/IconButton/IconButton.md +25 -0
- package/dist/docs/InputCurrency/InputCurrency.md +61 -0
- package/dist/docs/InputDate/InputDate.md +133 -0
- package/dist/docs/InputEmail/InputEmail.md +69 -0
- package/dist/docs/InputFieldWrapper/InputFieldWrapper.md +70 -0
- package/dist/docs/InputNumber/InputNumber.md +72 -0
- package/dist/docs/InputPassword/InputPassword.md +61 -0
- package/dist/docs/InputPressable/InputPressable.md +64 -0
- package/dist/docs/InputSearch/InputSearch.md +49 -0
- package/dist/docs/InputText/InputText.md +324 -0
- package/dist/docs/InputTime/InputTime.md +54 -0
- package/dist/docs/Opacity/Opacity.md +12 -0
- package/dist/docs/ProgressBar/ProgressBar.md +39 -0
- package/dist/docs/Radii/Radii.md +23 -0
- package/dist/docs/ResponsiveBreakpoint/ResponsiveBreakpoint.md +74 -0
- package/dist/docs/Select/Select.md +213 -0
- package/dist/docs/Spacing/Spacing.md +103 -0
- package/dist/docs/StatusLabel/StatusLabel.md +119 -0
- package/dist/docs/Switch/Switch.md +54 -0
- package/dist/docs/Text/Text.md +368 -0
- package/dist/docs/TextList/TextList.md +29 -0
- package/dist/docs/ThumbnailList/ThumbnailList.md +16 -0
- package/dist/docs/Toast/Toast.md +71 -0
- package/dist/docs/Typography/Typography.md +170 -0
- package/dist/docs/choosing-components/choosing-components.md +76 -0
- package/dist/docs/customizing-components/customizing-components.md +167 -0
- package/dist/docs/disabled-states/disabled-states.md +86 -0
- package/dist/docs/empty-states/empty-states.md +126 -0
- package/dist/docs/errors/errors.md +114 -0
- package/dist/docs/index.md +64 -0
- package/dist/docs/interaction/interaction.md +109 -0
- package/dist/docs/page-layouts/page-layouts.md +323 -0
- package/dist/docs/scaffolding/scaffolding.md +109 -0
- package/dist/docs/settings/settings.md +58 -0
- package/dist/docs/usage-guidelines/usage-guidelines.md +177 -0
- package/dist/package.json +8 -4
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +8 -4
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
# Select
|
|
2
|
+
|
|
3
|
+
A Select is used to present a defined list of options to choose from.
|
|
4
|
+
|
|
5
|
+
## Design & usage guidelines
|
|
6
|
+
|
|
7
|
+
Nested within the Select component, Option defines the options that can be
|
|
8
|
+
selected. For grouping options with section headers, use Select.OptionGroup.
|
|
9
|
+
|
|
10
|
+
#### Custom grouped menu and browser support
|
|
11
|
+
|
|
12
|
+
V2 remains a native `<select>` by default. To enable the enhanced grouped menu
|
|
13
|
+
styling (bold section headers, edge‑to‑edge dividers and hover backgrounds), set
|
|
14
|
+
the `UNSAFE_experimentalStyles` prop on `Select`.
|
|
15
|
+
|
|
16
|
+
* When `UNSAFE_experimentalStyles` is true and the browser supports
|
|
17
|
+
`appearance: base-select` (Chromium 123+), the select renders with the
|
|
18
|
+
customizable grouped menu.
|
|
19
|
+
* In unsupported browsers, or when `UNSAFE_experimentalStyles` is not provided,
|
|
20
|
+
the select remains native while still rendering the same `OptionGroup`
|
|
21
|
+
structure.
|
|
22
|
+
|
|
23
|
+
#### Option Props
|
|
24
|
+
|
|
25
|
+
#### OptionGroup Props
|
|
26
|
+
|
|
27
|
+
## States
|
|
28
|
+
|
|
29
|
+
### Invalid
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
import React from "react";
|
|
33
|
+
import { Option, Select } from "@jobber/components/Select";
|
|
34
|
+
|
|
35
|
+
export function SelectInvalidExample() {
|
|
36
|
+
return (
|
|
37
|
+
<Select invalid={true}>
|
|
38
|
+
<Option value="sad">Tony</Option>
|
|
39
|
+
<Option value="old">Steve</Option>
|
|
40
|
+
</Select>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Disabled
|
|
46
|
+
|
|
47
|
+
```tsx
|
|
48
|
+
import React from "react";
|
|
49
|
+
import { Option, Select } from "@jobber/components/Select";
|
|
50
|
+
|
|
51
|
+
export function SelectDisabledExample() {
|
|
52
|
+
return (
|
|
53
|
+
<Select disabled={true}>
|
|
54
|
+
<Option value="sad">Tony</Option>
|
|
55
|
+
<Option value="old">Steve</Option>
|
|
56
|
+
</Select>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Option Grouping
|
|
62
|
+
|
|
63
|
+
Use `Select.OptionGroup` to organize options with section headers for better
|
|
64
|
+
user experience and visual hierarchy. The `label` prop is required as it
|
|
65
|
+
provides the section header text.
|
|
66
|
+
|
|
67
|
+
### Basic Option Groups
|
|
68
|
+
|
|
69
|
+
```tsx
|
|
70
|
+
import React from "react";
|
|
71
|
+
import { Select } from "@jobber/components/Select";
|
|
72
|
+
|
|
73
|
+
export function SelectCustomOptionGroupsExample() {
|
|
74
|
+
return (
|
|
75
|
+
<Select
|
|
76
|
+
placeholder="Select an option"
|
|
77
|
+
version={2}
|
|
78
|
+
UNSAFE_experimentalStyles={true}
|
|
79
|
+
>
|
|
80
|
+
<Select.OptionGroup label="Team A">
|
|
81
|
+
<Select.Option value="alice">Alice</Select.Option>
|
|
82
|
+
<Select.Option value="bob">Bob</Select.Option>
|
|
83
|
+
<Select.Option value="charlie">Charlie</Select.Option>
|
|
84
|
+
</Select.OptionGroup>
|
|
85
|
+
<Select.OptionGroup label="Team B">
|
|
86
|
+
<Select.Option value="diana">Diana</Select.Option>
|
|
87
|
+
<Select.Option value="evan">Evan</Select.Option>
|
|
88
|
+
<Select.Option value="frank">Frank</Select.Option>
|
|
89
|
+
</Select.OptionGroup>
|
|
90
|
+
<Select.OptionGroup label="Team C">
|
|
91
|
+
<Select.Option value="grace">Grace</Select.Option>
|
|
92
|
+
<Select.Option value="hector">Hector</Select.Option>
|
|
93
|
+
<Select.Option value="isabel">Isabel</Select.Option>
|
|
94
|
+
</Select.OptionGroup>
|
|
95
|
+
</Select>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Disabled Option Groups
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
import React from "react";
|
|
104
|
+
import { Select } from "@jobber/components/Select";
|
|
105
|
+
|
|
106
|
+
export function SelectCustomOptionGroupDisabledExample() {
|
|
107
|
+
return (
|
|
108
|
+
<Select
|
|
109
|
+
version={2}
|
|
110
|
+
UNSAFE_experimentalStyles
|
|
111
|
+
placeholder="Select an option"
|
|
112
|
+
>
|
|
113
|
+
<Select.OptionGroup label="Available Items">
|
|
114
|
+
<Select.Option value="option1">Option 1</Select.Option>
|
|
115
|
+
<Select.Option value="option2">Option 2</Select.Option>
|
|
116
|
+
</Select.OptionGroup>
|
|
117
|
+
<Select.OptionGroup label="Unavailable Items" disabled>
|
|
118
|
+
<Select.Option value="option3">Option 3</Select.Option>
|
|
119
|
+
<Select.Option value="option4">Option 4</Select.Option>
|
|
120
|
+
</Select.OptionGroup>
|
|
121
|
+
<Select.OptionGroup label="More Items">
|
|
122
|
+
<Select.Option value="option5">Option 5</Select.Option>
|
|
123
|
+
<Select.Option value="option6">Option 6</Select.Option>
|
|
124
|
+
</Select.OptionGroup>
|
|
125
|
+
</Select>
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
## Configuration
|
|
132
|
+
|
|
133
|
+
### Custom (Chromium) vs native
|
|
134
|
+
|
|
135
|
+
Select (V2) is native by default. Opt into the customizable Chrome UI with
|
|
136
|
+
`UNSAFE_experimentalStyles`. This enhances grouped menus in Chromium 123+ when
|
|
137
|
+
the browser supports `appearance: base-select`.
|
|
138
|
+
|
|
139
|
+
#### Alignment limitation (custom UI)
|
|
140
|
+
|
|
141
|
+
When using `UNSAFE_experimentalStyles`, the closed control (what you see as the
|
|
142
|
+
displayed value) is still rendered by the browser's picker. As a result,
|
|
143
|
+
right/center alignment of the displayed value is not configurable in Chromium's
|
|
144
|
+
customizable select.
|
|
145
|
+
|
|
146
|
+
* Need right/center alignment? Use the native Select (omit
|
|
147
|
+
`UNSAFE_experimentalStyles`).
|
|
148
|
+
* You can still style the grouped dropdown (optgroup/option) in the custom UI,
|
|
149
|
+
but the closed value alignment will remain default.
|
|
150
|
+
|
|
151
|
+
## Component customization
|
|
152
|
+
|
|
153
|
+
### Composable usage
|
|
154
|
+
|
|
155
|
+
Select supports composition via subcomponents:
|
|
156
|
+
|
|
157
|
+
* `Select.Option`: item in the list. Provide `value` and children as the label.
|
|
158
|
+
* `Select.OptionGroup`: group options under a `label`. Use with
|
|
159
|
+
`UNSAFE_experimentalStyles` to opt into the customizable grouped menu in
|
|
160
|
+
Chromium.
|
|
161
|
+
|
|
162
|
+
#### Customization links
|
|
163
|
+
|
|
164
|
+
* See
|
|
165
|
+
["A customizable select"](https://developer.chrome.com/blog/a-customizable-select)
|
|
166
|
+
article for what the Chrome UI exposes: `::picker(select)`, option/optgroup
|
|
167
|
+
styling, and transitions.
|
|
168
|
+
|
|
169
|
+
## UNSAFE\_ props (advanced usage)
|
|
170
|
+
|
|
171
|
+
General guidance on `UNSAFE_` props can be found in
|
|
172
|
+
[Customizing components](../customizing-components/customizing-components.md).
|
|
173
|
+
|
|
174
|
+
Select subcomponents allow `UNSAFE_className` and `UNSAFE_style` to target the
|
|
175
|
+
native elements:
|
|
176
|
+
|
|
177
|
+
* `Select.OptionGroup` maps to `<optgroup>`
|
|
178
|
+
* `Select.Option` maps to `<option>`
|
|
179
|
+
|
|
180
|
+
Note that native `<select>` UX differs per browser. Use `UNSAFE_` props with
|
|
181
|
+
caution and test across environments. In the custom UI (Chromium), only the
|
|
182
|
+
dropdown content is stylable; the closed value alignment is not.
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
## Props
|
|
186
|
+
|
|
187
|
+
### Mobile
|
|
188
|
+
|
|
189
|
+
#### Select
|
|
190
|
+
|
|
191
|
+
| Prop | Type | Required | Default | Description |
|
|
192
|
+
|------|------|----------|---------|-------------|
|
|
193
|
+
| `children` | `ReactElement<SelectOption, string | JSXElementConstructor<any>>[]` | Yes | — | The options to select from |
|
|
194
|
+
| `accessibilityHint` | `string` | No | — | Helps users understand what will happen when they perform an action |
|
|
195
|
+
| `accessibilityLabel` | `string` | No | — | VoiceOver will read this string when a user selects the element |
|
|
196
|
+
| `assistiveText` | `string` | No | — | Help text shown below the control. |
|
|
197
|
+
| `defaultValue` | `string` | No | — | Default value for when the component is uncontrolled |
|
|
198
|
+
| `disabled` | `boolean` | No | — | Disables input selection |
|
|
199
|
+
| `invalid` | `boolean` | No | — | Indicates the current selection is invalid |
|
|
200
|
+
| `label` | `string` | No | — | Label text shown above the selection. |
|
|
201
|
+
| `name` | `string` | No | — | Name of the input. |
|
|
202
|
+
| `onChange` | `(newValue?: string) => void` | No | — | Callback that provides the new value when the selection changes |
|
|
203
|
+
| `placeholder` | `string` | No | — | Adds a first option to let users select a "no value". Placeholder item selected by default until a selection is made. |
|
|
204
|
+
| `testID` | `string` | No | — | Used to locate this view in end-to-end tests. |
|
|
205
|
+
| `validations` | `RegisterOptions` | No | — | The validations that will mark this component as invalid |
|
|
206
|
+
| `value` | `string` | No | — | Current value of the component |
|
|
207
|
+
|
|
208
|
+
#### Option
|
|
209
|
+
|
|
210
|
+
| Prop | Type | Required | Default | Description |
|
|
211
|
+
|------|------|----------|---------|-------------|
|
|
212
|
+
| `children` | `string` | Yes | — | Text that shows up as the option |
|
|
213
|
+
| `value` | `string` | Yes | — | The value that gets returned when an option is selected |
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# Spacing
|
|
2
|
+
|
|
3
|
+
Our spacing system exists to support the foundational visual design principle of
|
|
4
|
+
[proximity-based grouping:](https://www.nngroup.com/articles/gestalt-proximity/)
|
|
5
|
+
|
|
6
|
+
> Using varying amounts of whitespace to either unite or separate elements is
|
|
7
|
+
> key to communicating meaningful groupings.
|
|
8
|
+
|
|
9
|
+
In the shortest, simplest terms: the closer two elements are related, the
|
|
10
|
+
tighter the spacing between them should be.
|
|
11
|
+
|
|
12
|
+
With this in mind, let's start small and work our way up.
|
|
13
|
+
|
|
14
|
+
## Design & usage guidelines
|
|
15
|
+
|
|
16
|
+
### Minuscule and Smallest
|
|
17
|
+
|
|
18
|
+
At their respective sizes (`1px` and `2px` equivalent), these values should
|
|
19
|
+
mostly be used to provide optical adjustments where an element is visually
|
|
20
|
+
misaligned.
|
|
21
|
+
|
|
22
|
+
### Smaller
|
|
23
|
+
|
|
24
|
+
The `smaller` spacing value can be used between contents of a single component.
|
|
25
|
+
For example, see the spacing between an Icon and the label inside of a
|
|
26
|
+
[Button.](../Button/Button.md)
|
|
27
|
+
|
|
28
|
+
### Small
|
|
29
|
+
|
|
30
|
+
Sibling items within a container can be separated by the `small` value to
|
|
31
|
+
reflect their relation to each other. An example would be the spacing between
|
|
32
|
+
[Chips in a selection group.](/components/Chips)
|
|
33
|
+
|
|
34
|
+
### Slim
|
|
35
|
+
|
|
36
|
+
Use `slim` spacing when you don't quite need a `small` space, but `base` is just
|
|
37
|
+
too much. This is often useful for optically balancing the internal padding of a
|
|
38
|
+
UI element.
|
|
39
|
+
|
|
40
|
+
### Base
|
|
41
|
+
|
|
42
|
+
Use `base` as the default spacing in larger content containers with multiple
|
|
43
|
+
children of their own, such as [Card.](../Card/Card.md)
|
|
44
|
+
|
|
45
|
+
`Base` should also be used as the default starting point for spacing
|
|
46
|
+
form elements.
|
|
47
|
+
|
|
48
|
+
### Large
|
|
49
|
+
|
|
50
|
+
Use `large` spacing for higher-level "parent" containers.
|
|
51
|
+
[Modal](/components/Modal) uses `large` spacing in its header and around the
|
|
52
|
+
edges to give itself a bit more prominence as a standalone view, in a similar
|
|
53
|
+
manner to [Page](/components/Page).
|
|
54
|
+
|
|
55
|
+
`Large` can also be used to help give a "floating" element some clear separation
|
|
56
|
+
from the edge of the viewport, as seen in [Toast](../Toast/Toast.md).
|
|
57
|
+
|
|
58
|
+
### Larger
|
|
59
|
+
|
|
60
|
+
`Larger` doubles the value of `base` to very clearly delineate two groups of
|
|
61
|
+
content. It can be useful if you have a long list of mixed content types that
|
|
62
|
+
need to be broken up.
|
|
63
|
+
|
|
64
|
+
### Largest
|
|
65
|
+
|
|
66
|
+
`Largest` is useful for giving content-rich containers ample breathing room to
|
|
67
|
+
create hierarchy. When the parent has such generous spacing, it allows for the
|
|
68
|
+
children to leverage a broader range of techniques for grouping amongst
|
|
69
|
+
themselves.
|
|
70
|
+
|
|
71
|
+
### Extravagant
|
|
72
|
+
|
|
73
|
+
`Extravagant` is used infrequently in Jobber’s web and mobile applications, but
|
|
74
|
+
can be useful for lower-density consumer applications like websites.
|
|
75
|
+
|
|
76
|
+
***
|
|
77
|
+
|
|
78
|
+
## Implementation
|
|
79
|
+
|
|
80
|
+
### Content
|
|
81
|
+
|
|
82
|
+
Use the [Content component](../Content/Content.md) for any instances where you
|
|
83
|
+
need uniform spacing between elements.
|
|
84
|
+
|
|
85
|
+
Content can set its spacing to any of the spacing token values; follow the
|
|
86
|
+
guidelines above as needed.
|
|
87
|
+
|
|
88
|
+
### Values
|
|
89
|
+
|
|
90
|
+
You can use spacing tokens directly in your stylesheets using the values below.
|
|
91
|
+
|
|
92
|
+
| Name | Visual | Value |
|
|
93
|
+
| :-------------------- | :----- | :---- |
|
|
94
|
+
| `--space-minuscule` | | |
|
|
95
|
+
| `--space-smallest` | | |
|
|
96
|
+
| `--space-smaller` | | |
|
|
97
|
+
| `--space-small` | | |
|
|
98
|
+
| `--space-slim` | | |
|
|
99
|
+
| `--space-base` | | |
|
|
100
|
+
| `--space-large` | | |
|
|
101
|
+
| `--space-larger` | | |
|
|
102
|
+
| `--space-largest` | | |
|
|
103
|
+
| `--space-extravagant` | | |
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# Status Label
|
|
2
|
+
|
|
3
|
+
The StatusLabel component is a visual component that allows users to quickly
|
|
4
|
+
determine the status of an item (e.g., "Active", "Overdue").
|
|
5
|
+
|
|
6
|
+
## Design & usage guidelines
|
|
7
|
+
|
|
8
|
+
StatusLabel is a more opinionated version of
|
|
9
|
+
[InlineLabel](/components/InlineLabel) and offers only 5 possible status
|
|
10
|
+
representations:
|
|
11
|
+
|
|
12
|
+
### Success
|
|
13
|
+
|
|
14
|
+
Convey that an item is in a successful state, such as approved or paid.
|
|
15
|
+
|
|
16
|
+
### Critical
|
|
17
|
+
|
|
18
|
+
Alert the user to a critically important issue such as a late appointment or an
|
|
19
|
+
overdue payment.
|
|
20
|
+
|
|
21
|
+
### Warning
|
|
22
|
+
|
|
23
|
+
Warn the user of a potential forthcoming issue like an upcoming deadline or an
|
|
24
|
+
item awaiting response.
|
|
25
|
+
|
|
26
|
+
### Informative
|
|
27
|
+
|
|
28
|
+
Inform the user about something that may not require action, such as a quote
|
|
29
|
+
that has already been converted into a job.
|
|
30
|
+
|
|
31
|
+
### Inactive
|
|
32
|
+
|
|
33
|
+
Signify that an item has been archived, closed, or otherwise removed from an
|
|
34
|
+
active workflow.
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import React from "react";
|
|
38
|
+
import { Content } from "@jobber/components/Content";
|
|
39
|
+
import { StatusLabel } from "@jobber/components/StatusLabel";
|
|
40
|
+
|
|
41
|
+
export function StatusLabelAllStatusesExample() {
|
|
42
|
+
return (
|
|
43
|
+
<Content>
|
|
44
|
+
<StatusLabel label="Success" status="success" alignment="start" />
|
|
45
|
+
<StatusLabel label="Critical" status="critical" alignment="start" />
|
|
46
|
+
<StatusLabel label="Informative" status="informative" alignment="start" />
|
|
47
|
+
<StatusLabel label="Warning" status="warning" alignment="start" />
|
|
48
|
+
<StatusLabel label="Inactive" status="inactive" alignment="start" />
|
|
49
|
+
</Content>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Alignment
|
|
55
|
+
|
|
56
|
+
Align the color indicator with the start or end of a layout as needed.
|
|
57
|
+
|
|
58
|
+
For example, in a [List](/components/List) where the StatusLabel is on the
|
|
59
|
+
right, use the `end` alignment.
|
|
60
|
+
|
|
61
|
+
```tsx
|
|
62
|
+
import React from "react";
|
|
63
|
+
import { StatusLabel } from "@jobber/components/StatusLabel";
|
|
64
|
+
|
|
65
|
+
export function StatusLabelAlignmentExample() {
|
|
66
|
+
return (
|
|
67
|
+
<div style={{ display: "flex", justifyContent: "space-between" }}>
|
|
68
|
+
<StatusLabel label="Start" status="inactive" alignment="start" />
|
|
69
|
+
<StatusLabel label="End" status="inactive" alignment="end" />
|
|
70
|
+
</div>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Related components
|
|
76
|
+
|
|
77
|
+
[InlineLabel](/components/InlineLabel) is a more generic badging element that
|
|
78
|
+
can be used in non-"status"-y ways
|
|
79
|
+
|
|
80
|
+
* counts
|
|
81
|
+
* trends
|
|
82
|
+
* tags
|
|
83
|
+
* labels that need to be distinguished from other typographic content
|
|
84
|
+
|
|
85
|
+
## Content guidelines
|
|
86
|
+
|
|
87
|
+
StatusLabel does not accept any child content. It presents only a text-based
|
|
88
|
+
label describing the status, and a visual color indicator to reinforce the
|
|
89
|
+
status.
|
|
90
|
+
|
|
91
|
+
The label should be short, ideally no longer than two words.
|
|
92
|
+
|
|
93
|
+
## Accessibility
|
|
94
|
+
|
|
95
|
+
The StatusLabel has a `role` of `status` which is communicated to assistive
|
|
96
|
+
technology. It does not pull focus to itself but informs the user of its'
|
|
97
|
+
purpose.
|
|
98
|
+
|
|
99
|
+
The label portion of StatusLabel should be readable by assistive technology.
|
|
100
|
+
|
|
101
|
+
The color indicator is always used with a text label so that color is not the
|
|
102
|
+
only method of communicating status.
|
|
103
|
+
|
|
104
|
+
## Responsiveness
|
|
105
|
+
|
|
106
|
+
StatusLabel should "hug" it's contents, but otherwise grow as long as needed in
|
|
107
|
+
the available space. If StatusLabel's label is longer than the space available,
|
|
108
|
+
the label should wrap.
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
## Props
|
|
112
|
+
|
|
113
|
+
### Mobile
|
|
114
|
+
|
|
115
|
+
| Prop | Type | Required | Default | Description |
|
|
116
|
+
|------|------|----------|---------|-------------|
|
|
117
|
+
| `text` | `string` | Yes | — | Text to display. |
|
|
118
|
+
| `alignment` | `"start" | "end"` | No | `end` | Alignment of text |
|
|
119
|
+
| `status` | `StatusType` | No | `success` | Status color of the square beside text |
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Switch
|
|
2
|
+
|
|
3
|
+
A Switch toggles the state of a single setting to on or off.
|
|
4
|
+
|
|
5
|
+
## Design & usage guidelines
|
|
6
|
+
|
|
7
|
+
The Switch is a useful component for manipulating settings with binary
|
|
8
|
+
(true/false, yes/no, on/off) conditions. For this reason its' label is limited
|
|
9
|
+
to ON/OFF.
|
|
10
|
+
|
|
11
|
+
### Disabled
|
|
12
|
+
|
|
13
|
+
A disabled switch cannot be operated by the user. If presenting a disabled "On"
|
|
14
|
+
switch to the user, provide a clear description for the user on how to enable
|
|
15
|
+
the switch to avoid creating a sense that the user has lost control of the
|
|
16
|
+
interface.
|
|
17
|
+
|
|
18
|
+
```tsx
|
|
19
|
+
import React from "react";
|
|
20
|
+
import { Switch } from "@jobber/components/Switch";
|
|
21
|
+
|
|
22
|
+
export function SwitchDisabledExample() {
|
|
23
|
+
return (
|
|
24
|
+
<Switch value={false} ariaLabel="Visible to clients" disabled={true} />
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Related components
|
|
30
|
+
|
|
31
|
+
A Switch, a [Checkbox](../Checkbox/Checkbox.md), and a pair of
|
|
32
|
+
[RadioButton](/components/RadioGroup) can seem similar in theory, as all can
|
|
33
|
+
represent an `either/or decision` for the user.
|
|
34
|
+
|
|
35
|
+
Use a Switch when the user must make a decision to turn something on or off, and
|
|
36
|
+
a single Checkbox when a user is opting in to a choice. A pair of RadioButtons
|
|
37
|
+
can be used to help the user decide between two discrete options, such as "fixed
|
|
38
|
+
price" and "per visit" invoicing options.
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
## Props
|
|
42
|
+
|
|
43
|
+
### Mobile
|
|
44
|
+
|
|
45
|
+
| Prop | Type | Required | Default | Description |
|
|
46
|
+
|------|------|----------|---------|-------------|
|
|
47
|
+
| `accessibilityLabel` | `string` | No | — | Accessibility label for this switch |
|
|
48
|
+
| `defaultValue` | `boolean` | No | — | Default value of the switch when uncontrolled |
|
|
49
|
+
| `description` | `string` | No | — | Optional descriptive text to display under the switch |
|
|
50
|
+
| `disabled` | `boolean` | No | — | When true, the switch cannot be toggled |
|
|
51
|
+
| `label` | `string` | No | — | Optional label to display in front of the switch |
|
|
52
|
+
| `name` | `string` | No | — | Name of the input. |
|
|
53
|
+
| `onValueChange` | `(val: boolean) => void` | No | — | Callback to handle value changes |
|
|
54
|
+
| `value` | `boolean` | No | — | Value of the switch |
|