@atom-learning/components 1.3.1 → 1.6.0
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/components/accordion/Accordion.js +1 -1
- package/dist/components/accordion/AccordionContent.js +1 -1
- package/dist/components/accordion/AccordionItem.js +1 -1
- package/dist/components/accordion/AccordionTrigger.js +1 -1
- package/dist/components/action-icon/ActionIcon.d.ts +1 -1
- package/dist/components/action-icon/ActionIcon.js +1 -1
- package/dist/components/alert-dialog/AlertDialog.js +1 -1
- package/dist/components/alert-dialog/AlertDialogContent.js +1 -1
- package/dist/components/alert-dialog/alert-context/AlertContext.js +1 -1
- package/dist/components/alert-dialog/alert-context/AlertDialog.js +1 -1
- package/dist/components/alert-dialog/alert-context/reducer.js +1 -1
- package/dist/components/box/Box.js +1 -1
- package/dist/components/button/Button.d.ts +1 -1
- package/dist/components/button/Button.js +1 -1
- package/dist/components/calendar/Calendar.d.ts +19 -0
- package/dist/components/calendar/Calendar.js +1 -0
- package/dist/components/calendar/Day.d.ts +269 -0
- package/dist/components/calendar/Day.js +1 -0
- package/dist/components/calendar/constants.d.ts +2 -0
- package/dist/components/calendar/constants.js +1 -0
- package/dist/components/carousel/Carousel.js +1 -1
- package/dist/components/carousel/CarouselArrows.js +1 -1
- package/dist/components/carousel/CarouselPagination.js +1 -1
- package/dist/components/carousel/CarouselSlide.js +1 -1
- package/dist/components/carousel/CarouselSlider.js +1 -1
- package/dist/components/checkbox/Checkbox.js +1 -1
- package/dist/components/checkbox-field/CheckboxField.js +1 -1
- package/dist/components/combobox/Combobox.js +1 -1
- package/dist/components/combobox/ComboboxInput.js +1 -1
- package/dist/components/combobox/ComboboxPopover.js +1 -1
- package/dist/components/date-field/DateField.d.ts +17 -0
- package/dist/components/date-field/DateField.js +1 -0
- package/dist/components/date-field/index.d.ts +1 -0
- package/dist/components/date-input/DateInput.d.ts +19 -0
- package/dist/components/date-input/DateInput.js +1 -0
- package/dist/components/date-input/constants.d.ts +1 -0
- package/dist/components/date-input/constants.js +1 -0
- package/dist/components/date-input/index.d.ts +1 -0
- package/dist/components/date-input/use-date.d.ts +5 -0
- package/dist/components/date-input/use-date.js +1 -0
- package/dist/components/dialog/Dialog.js +1 -1
- package/dist/components/dialog/DialogContent.d.ts +1 -0
- package/dist/components/dialog/DialogContent.js +1 -1
- package/dist/components/divider/Divider.js +1 -1
- package/dist/components/dropdown-menu/DropdownMenu.js +1 -1
- package/dist/components/dropdown-menu/DropdownMenuContent.js +1 -1
- package/dist/components/dropdown-menu/DropdownMenuItem.js +1 -1
- package/dist/components/dropdown-menu/DropdownMenuLinkItem.js +1 -1
- package/dist/components/dropdown-menu/DropdownMenuTrigger.js +1 -1
- package/dist/components/field-wrapper/FieldDescription.js +1 -1
- package/dist/components/field-wrapper/FieldWrapper.js +1 -1
- package/dist/components/field-wrapper/InlineFieldWrapper.js +1 -1
- package/dist/components/flex/Flex.js +1 -1
- package/dist/components/form/Form.js +1 -1
- package/dist/components/form/Form.types.d.ts +2 -2
- package/dist/components/form/Form.types.js +1 -1
- package/dist/components/form/useFieldError.js +1 -1
- package/dist/components/grid/Grid.js +1 -1
- package/dist/components/heading/Heading.js +1 -1
- package/dist/components/icon/Icon.js +1 -1
- package/dist/components/image/Image.js +1 -1
- package/dist/components/index.d.ts +7 -1
- package/dist/components/input/Input.js +1 -1
- package/dist/components/input-field/InputField.js +1 -1
- package/dist/components/label/Label.js +1 -1
- package/dist/components/link/Link.js +1 -1
- package/dist/components/list/List.js +1 -1
- package/dist/components/loader/Loader.js +1 -1
- package/dist/components/markdown-content/MarkdownContent.js +1 -1
- package/dist/components/markdown-content/components/MarkdownCode.js +1 -1
- package/dist/components/markdown-content/components/MarkdownEmphasis.js +1 -1
- package/dist/components/markdown-content/components/MarkdownHeading.js +1 -1
- package/dist/components/markdown-content/components/MarkdownImage.js +1 -1
- package/dist/components/markdown-content/components/MarkdownInlineCode.js +1 -1
- package/dist/components/markdown-content/components/MarkdownLink.js +1 -1
- package/dist/components/markdown-content/components/MarkdownList.js +1 -1
- package/dist/components/markdown-content/components/MarkdownListItem.js +1 -1
- package/dist/components/markdown-content/components/MarkdownParagraph.js +1 -1
- package/dist/components/markdown-content/components/MarkdownStrong.js +1 -1
- package/dist/components/markdown-content/components/MarkdownText.js +1 -1
- package/dist/components/markdown-content/components/MarkdownThematicBreak.js +1 -1
- package/dist/components/notification-badge/NotificationBadge.d.ts +535 -0
- package/dist/components/notification-badge/NotificationBadge.js +1 -0
- package/dist/components/notification-badge/index.d.ts +1 -0
- package/dist/components/password-field/PasswordField.js +1 -1
- package/dist/components/password-input/PasswordInput.js +1 -1
- package/dist/components/popover/Popover.js +1 -1
- package/dist/components/popover/PopoverContent.d.ts +1 -0
- package/dist/components/popover/PopoverContent.js +1 -1
- package/dist/components/progress-bar/ProgressBar.js +1 -1
- package/dist/components/radio-button/RadioButton.js +1 -1
- package/dist/components/radio-button/RadioButtonGroup.js +1 -1
- package/dist/components/radio-button-field/RadioButtonField.js +1 -1
- package/dist/components/radio-button-field/RadioField.js +1 -1
- package/dist/components/radio-card/RadioCard.js +1 -1
- package/dist/components/radio-card/RadioCardGroup.js +1 -1
- package/dist/components/search-input/SearchInput.d.ts +4 -1
- package/dist/components/search-input/SearchInput.js +1 -1
- package/dist/components/select/Select.js +1 -1
- package/dist/components/select-field/SelectField.js +1 -1
- package/dist/components/slider/Slider.d.ts +276 -0
- package/dist/components/slider/Slider.js +1 -0
- package/dist/components/slider/SliderSteps.d.ts +13 -0
- package/dist/components/slider/SliderSteps.js +1 -0
- package/dist/components/slider/SliderValue.d.ts +9 -0
- package/dist/components/slider/SliderValue.js +1 -0
- package/dist/components/slider/index.d.ts +1 -0
- package/dist/components/slider-field/SliderField.d.ts +13 -0
- package/dist/components/slider-field/SliderField.js +1 -0
- package/dist/components/slider-field/index.d.ts +1 -0
- package/dist/components/stack/Stack.js +1 -1
- package/dist/components/stack-content/StackContent.js +1 -1
- package/dist/components/stepper/Stepper.d.ts +10 -0
- package/dist/components/stepper/Stepper.js +1 -0
- package/dist/components/stepper/StepperStepBack.d.ts +4 -0
- package/dist/components/stepper/StepperStepBack.js +1 -0
- package/dist/components/stepper/StepperStepForward.d.ts +4 -0
- package/dist/components/stepper/StepperStepForward.js +1 -0
- package/dist/components/stepper/StepperSteps.d.ts +2 -0
- package/dist/components/stepper/StepperSteps.js +1 -0
- package/dist/components/stepper/index.d.ts +1 -0
- package/dist/components/stepper/stepper-context/StepperContext.d.ts +4 -0
- package/dist/components/stepper/stepper-context/StepperContext.js +1 -0
- package/dist/components/stepper/types.d.ts +24 -0
- package/dist/components/switch/Switch.js +1 -1
- package/dist/components/table/Table.js +1 -1
- package/dist/components/table/TableBody.js +1 -1
- package/dist/components/table/TableCell.js +1 -1
- package/dist/components/table/TableFooter.js +1 -1
- package/dist/components/table/TableHeader.js +1 -1
- package/dist/components/table/TableHeaderCell.js +1 -1
- package/dist/components/table/TableRow.js +1 -1
- package/dist/components/tabs/TabTrigger.js +1 -1
- package/dist/components/tabs/Tabs.js +1 -1
- package/dist/components/tabs/TabsTriggerList.d.ts +2 -0
- package/dist/components/tabs/TabsTriggerList.js +1 -1
- package/dist/components/tabs/utils.js +1 -1
- package/dist/components/text/Text.js +1 -1
- package/dist/components/textarea/Textarea.js +1 -1
- package/dist/components/textarea-field/TextareaField.js +1 -1
- package/dist/components/toast/Toast.js +1 -1
- package/dist/components/toast/ToastProvider.js +1 -1
- package/dist/components/tooltip/Tooltip.js +1 -1
- package/dist/components/tooltip/TooltipContent.js +1 -1
- package/dist/components/validation-error/ValidationError.js +1 -1
- package/dist/components/video/Video.js +1 -1
- package/dist/docgen.json +1 -1
- package/dist/docs/Button.mdx +3 -2
- package/dist/docs/DateField.mdx +20 -0
- package/dist/docs/DateInput.mdx +87 -0
- package/dist/docs/Dialog.mdx +16 -1
- package/dist/docs/NotificationBadge.mdx +33 -0
- package/dist/docs/RadioButton.mdx +1 -1
- package/dist/docs/SearchInput.mdx +2 -1
- package/dist/docs/Slider.mdx +117 -0
- package/dist/docs/SliderField.mdx +35 -0
- package/dist/docs/Stepper.mdx +45 -0
- package/dist/docs/Tabs.mdx +17 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.js +1 -1
- package/dist/stitches.js +1 -1
- package/dist/utilities/css-wrapper/CSSWrapper.js +1 -1
- package/dist/utilities/style/capsize.js +1 -1
- package/dist/utilities/style/encode-background-icon.js +1 -1
- package/dist/utilities/style/keyframe-animations.js +1 -1
- package/dist/utilities/use-is-mounted-ref/index.js +1 -1
- package/package.json +27 -18
package/dist/docs/Button.mdx
CHANGED
|
@@ -13,7 +13,7 @@ It adds default styling and the `css` prop. By default `primary` theme is displa
|
|
|
13
13
|
|
|
14
14
|
## Themes
|
|
15
15
|
|
|
16
|
-
These are the available `themes` for the `Button` component: `primary` (default), `success`, `warning`, `danger`
|
|
16
|
+
These are the available `themes` for the `Button` component: `primary` (default), `success`, `warning`, `danger`, and `neutral`.
|
|
17
17
|
|
|
18
18
|
```tsx preview
|
|
19
19
|
<>
|
|
@@ -21,12 +21,13 @@ These are the available `themes` for the `Button` component: `primary` (default)
|
|
|
21
21
|
<Button theme="success">Success</Button>
|
|
22
22
|
<Button theme="warning">Warning</Button>
|
|
23
23
|
<Button theme="danger">Danger</Button>
|
|
24
|
+
<Button theme="neutral">Danger</Button>
|
|
24
25
|
</>
|
|
25
26
|
```
|
|
26
27
|
|
|
27
28
|
## Appearance
|
|
28
29
|
|
|
29
|
-
There two options for the `appearance` property: `solid` and `outline`.
|
|
30
|
+
There two options for the `appearance` property: `solid` and `outline`. There are the available `outline` variations for the `primary` and `neutral` themes.
|
|
30
31
|
|
|
31
32
|
```tsx preview
|
|
32
33
|
<Button appearance="outline">Primary</Button>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Date Field
|
|
3
|
+
component: DateField
|
|
4
|
+
description: DateField renders a field composed of an DateInput, a Label and a ValidationError
|
|
5
|
+
category: Form fields
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
`DateField` is the preferred way to render a form field for dates.
|
|
9
|
+
|
|
10
|
+
In addition to text `Label` (required) and a validation error (optional), `DateField` accepts all the same props as `DateInput` and will pass them on to the `DateInput` it renders. However, as with all our composed components,
|
|
11
|
+
`DateField`’s `css` prop will be applied to a containing `Box`—the styling of the individual components inside `DateField` cannot be altered.
|
|
12
|
+
|
|
13
|
+
Err on the side of using consistent form fields, but if you really need something with different styling then consider composing your own field from the
|
|
14
|
+
`DateInput`, `Label` and `ValidationError` components.
|
|
15
|
+
|
|
16
|
+
```tsx preview
|
|
17
|
+
<Form>
|
|
18
|
+
<DateField name="exam-date" label="Exam date" initialDate={new Date()} />
|
|
19
|
+
</Form>
|
|
20
|
+
```
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Date Input
|
|
3
|
+
component: DateInput
|
|
4
|
+
description: A form component that provides a styled date selector without a label
|
|
5
|
+
category: Form primitives
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
Date Inputs should be accompanied by labels, so rather than using `DateInput` directly in a UI,
|
|
9
|
+
it’s normally best to the `DateField` component, which combines a `DateInput` with a `Label` and
|
|
10
|
+
displays validation errors. Alternatively, use this `DateInput` component to compose other field components
|
|
11
|
+
with more specific requirements.
|
|
12
|
+
|
|
13
|
+
`DateInput` is composed from [Dayzed](https://github.com/deseretdigital/dayzed), so further reading on the API can be found there. Some options from Dayzed are set by default in order to provide a uniform experience. For example, the prop `showOutsideDays`, which shows days outside the current calendar month that would appear on the grid, defaults to true in order to avoid extra whitespace.
|
|
14
|
+
|
|
15
|
+
```tsx preview
|
|
16
|
+
<DateInput />
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Initial Date
|
|
20
|
+
|
|
21
|
+
The `DateInput` component allows passing of an initial date, which will be selected by default. If you wish this to be the current date, you can use `new Date()` as per the preview below. Strings are also accepted and default to the `DD/MM/YYYY` format. It is recommended to use standard constructors for the date object as per MDN specifications.
|
|
22
|
+
|
|
23
|
+
```tsx preview
|
|
24
|
+
<DateInput initialDate={new Date()} />
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Date Format
|
|
28
|
+
|
|
29
|
+
Any combination of date formats can be passed in as a string, such as `DD/MM/YY` or `YYYY/MM/DD`. The default is `DD/MM/YYYY`. A full list of possible formats can be found [here](https://day.js.org/docs/en/parse/string-format#list-of-all-available-parsing-tokens).
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
<DateInput dateFormat="YYYY/MM/DD" />
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Dayzed customisation
|
|
36
|
+
|
|
37
|
+
### First Day of Week
|
|
38
|
+
|
|
39
|
+
The calendar that is rendered by this component can have its first day of the week customised for different locales. The default is 1 (Monday), but for locales such as the US, pass in `firstDayOfWeek={0}` to set it to Sunday.
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
<DateInput firstDayOfWeek={0} />
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Translations
|
|
46
|
+
|
|
47
|
+
The weekday and month names can be changed to anything you wish by passing in an array of strings to `weekdayNames` and `monthNames`.
|
|
48
|
+
|
|
49
|
+
> NOTE: It is very important that you keep these labels in the right order. Weekdays must be `Sun -> Sat` and months must be `Jan -> Dec`.
|
|
50
|
+
|
|
51
|
+
```tsx preview
|
|
52
|
+
<DateInput
|
|
53
|
+
weekdayNames={['D', 'L', 'M', 'X', 'J', 'V', 'S']}
|
|
54
|
+
monthNames={[
|
|
55
|
+
'Enero',
|
|
56
|
+
'Febrero',
|
|
57
|
+
'Marzo',
|
|
58
|
+
'Abril',
|
|
59
|
+
'Mayo',
|
|
60
|
+
'Junio',
|
|
61
|
+
'Julio',
|
|
62
|
+
'Agosto',
|
|
63
|
+
'Septiembre',
|
|
64
|
+
'Octubre',
|
|
65
|
+
'Noviembre',
|
|
66
|
+
'Diciembre'
|
|
67
|
+
]}
|
|
68
|
+
/>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
You can also translate the internal labels for accessibility purposes. The `labels` prop accepts an object containing three keys, `open`, `next`, and `previous`. These should all be strings.
|
|
72
|
+
|
|
73
|
+
```tsx
|
|
74
|
+
<DateInput
|
|
75
|
+
labels={{
|
|
76
|
+
open: 'Open label',
|
|
77
|
+
next: 'Next month label',
|
|
78
|
+
previous: 'Previous month label'
|
|
79
|
+
}}
|
|
80
|
+
/>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
If you need even finer control over what happens with the selected date, you can pass `onChange`, which takes a `Date` type as input.
|
|
84
|
+
|
|
85
|
+
```tsx
|
|
86
|
+
<DateInput onChange={(date) => doSomethingWith(date)} />
|
|
87
|
+
```
|
package/dist/docs/Dialog.mdx
CHANGED
|
@@ -14,7 +14,7 @@ Read more about the underlying UI component on the [Radix UI documentation site]
|
|
|
14
14
|
```tsx preview
|
|
15
15
|
<Dialog>
|
|
16
16
|
<Dialog.Trigger asChild>
|
|
17
|
-
<Button>
|
|
17
|
+
<Button>Open Dialog</Button>
|
|
18
18
|
</Dialog.Trigger>
|
|
19
19
|
<Dialog.Content>
|
|
20
20
|
<Heading size="sm" css={{ mb: '$3' }}>
|
|
@@ -31,4 +31,19 @@ Read more about the underlying UI component on the [Radix UI documentation site]
|
|
|
31
31
|
</Dialog>
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
+
`Dialog` may be rendered without a close button. It's important to note that in case the default close button is hidden, one would need to provide an action button explicitly, to close the dialog.
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
<Dialog>
|
|
38
|
+
<Dialog.Trigger>Open Dialog</Dialog.Trigger>
|
|
39
|
+
<Dialog.Content showCloseButton={false}>
|
|
40
|
+
<Text>
|
|
41
|
+
Dialog.Close is used below to retain the correct accessible roles and
|
|
42
|
+
related logic
|
|
43
|
+
</Text>
|
|
44
|
+
<Button as={Dialog.Close}>Close</Button>
|
|
45
|
+
</Dialog.Content>
|
|
46
|
+
</Dialog>
|
|
47
|
+
```
|
|
48
|
+
|
|
34
49
|
For any modifications of the default `Dialog` visuals, for example bypassing the panel design entirely, we recommend utilising the Radix UI Dialog component directly. You will need to wrap each exported component within a `styled()` function to enable `css` and `as`, and compose together `Dialog.Overlay` and `Dialog.Close` within `Dialog.Content` to mimic the behaviour of this modal.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Notification Badge
|
|
3
|
+
component: NotificationBadge
|
|
4
|
+
description: A badge that wraps content and displays a notification
|
|
5
|
+
category: Feedback
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
The NotificationBadge component is a lightweight wrapper for content such as ActionIcons, but can be wrapped around any block-level element.
|
|
9
|
+
|
|
10
|
+
It displays a badge in top right of the content it is wrapping, which displays a `value` passed in as a prop. This could be, for example, the number of filters selected on a select filters badge.
|
|
11
|
+
|
|
12
|
+
```tsx preview
|
|
13
|
+
<NotificationBadge value={3}>
|
|
14
|
+
<ActionIcon appearance="outline" size="lg" isRounded>
|
|
15
|
+
<Icon is={Controls} />
|
|
16
|
+
</ActionIcon>
|
|
17
|
+
</NotificationBadge>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Value
|
|
21
|
+
|
|
22
|
+
Whilst you would normally want to display a number, the `value` prop also supports strings. Here are some usage examples:
|
|
23
|
+
|
|
24
|
+
```tsx preview
|
|
25
|
+
<NotificationBadge value={88}>
|
|
26
|
+
<ActionIcon appearance="outline" size="lg">
|
|
27
|
+
<Icon is={Controls} />
|
|
28
|
+
</ActionIcon>
|
|
29
|
+
</NotificationBadge>
|
|
30
|
+
<NotificationBadge value="hi">
|
|
31
|
+
<Button theme="warning">I'm a button!</Button>
|
|
32
|
+
</NotificationBadge>
|
|
33
|
+
```
|
|
@@ -5,7 +5,8 @@ description: A search input with matching search icon
|
|
|
5
5
|
category: Form primitives
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
`SearchInput` wraps `Input` and adds an icon to visualise the specific input type, it's recommended to use this component when the user is performing a search query.
|
|
8
|
+
`SearchInput` wraps `Input` and adds an icon to visualise the specific input type, it's recommended to use this component when the user is performing a search query.
|
|
9
|
+
When the user types into the `SearchInput` the component renders a clear button that clears the typed value.
|
|
9
10
|
|
|
10
11
|
```tsx preview
|
|
11
12
|
<SearchInput name="search" css={{ width: 320 }} placeholder="Search" />
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Slider
|
|
3
|
+
component: Slider, Slider.Value, Slider.Steps
|
|
4
|
+
description: The slider component implements the Slider component from Radix, with default styling and the CSS prop.
|
|
5
|
+
category: Form primitives
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
The `Slider` is a simple component that renders a form slider.
|
|
9
|
+
|
|
10
|
+
The `Slider` component should be rendered with a label for accesibility reasons. Rather than using the `Slider` component directly, it is best to use the `SliderField` component, which provides a field label, a value label, and easily integrates with the `Form` component.
|
|
11
|
+
|
|
12
|
+
Should you wish to create a more complex UI with `Field` components, you should use this base component.
|
|
13
|
+
|
|
14
|
+
Please note: the `value` or `defaultValue` passed in should always be an array.
|
|
15
|
+
|
|
16
|
+
```tsx preview
|
|
17
|
+
<Slider defaultValue={[50]} css={{ width: '320px' }} />
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Multiple Values
|
|
21
|
+
|
|
22
|
+
Should you wish to have more than one control on the slider, you can pass those values in the array.
|
|
23
|
+
|
|
24
|
+
```tsx preview
|
|
25
|
+
<Slider defaultValue={[25, 75]} css={{ width: '320px' }} />
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Slider.Steps
|
|
29
|
+
|
|
30
|
+
A separate component exists to output an array of labels which appear at given value points along the slider. These are passed in to the `steps` property using an array objects that contain a label and a value.
|
|
31
|
+
|
|
32
|
+
This is most commonly used within the `SliderField`, but is here in case you need to compose your own complex component.
|
|
33
|
+
|
|
34
|
+
Note: it is likely better to create steps as a constant and pass in with `steps={steps}` or similar, but this preview code cannot see values outside of JSX.
|
|
35
|
+
|
|
36
|
+
```tsx preview
|
|
37
|
+
<Slider defaultValue={[50]} css={{ width: '320px' }}>
|
|
38
|
+
<Slider.Steps
|
|
39
|
+
min={0}
|
|
40
|
+
max={100}
|
|
41
|
+
steps={[
|
|
42
|
+
{ value: 0, label: 'min' },
|
|
43
|
+
{ value: 50, label: 'mid' },
|
|
44
|
+
{ value: 100, label: 'max' }
|
|
45
|
+
]}
|
|
46
|
+
/>
|
|
47
|
+
</Slider>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
The component requires min and max values, these should be the same as the optional values that are passed to the Slider component.
|
|
51
|
+
|
|
52
|
+
`Slider.Steps` work well with the built in `step` property, which defaults to 1 and changes the size of each movement. For example, this would limit the slider to three values only.
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
<Slider defaultValue={[50]} min={10} max={20} step={5}>
|
|
56
|
+
<Slider.Steps
|
|
57
|
+
min={10}
|
|
58
|
+
max={20}
|
|
59
|
+
steps={[
|
|
60
|
+
{ value: 10, label: 'min' },
|
|
61
|
+
{ value: 15, label: 'mid' },
|
|
62
|
+
{ value: 20, label: 'max' }
|
|
63
|
+
]}
|
|
64
|
+
/>
|
|
65
|
+
</Slider>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Slider.Value
|
|
69
|
+
|
|
70
|
+
A separate component exists to output the value from a slider. This is most commonly used within the `SliderField`, but is here in case you need to compose your own complex component.
|
|
71
|
+
|
|
72
|
+
```tsx preview
|
|
73
|
+
<Slider defaultValue={[50]} css={{ width: '320px' }}>
|
|
74
|
+
{/**
|
|
75
|
+
* The Slider.Value value must be manually controlled using onValueChange
|
|
76
|
+
* from Slider. This is a visual example of how would render Slider.Value
|
|
77
|
+
* and will not update when changed.
|
|
78
|
+
*/}
|
|
79
|
+
<Slider.Value value={[50]} />
|
|
80
|
+
</Slider>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
By default this simply outputs the value, however, this can be customised in a number of ways. The property `outputLabel` accepts a function that passes the value selected in the slider and expects a string returned for the label.
|
|
84
|
+
|
|
85
|
+
You can also use this is in more complex ways, for example to set empty states and pluralisation, like below.
|
|
86
|
+
|
|
87
|
+
```tsx
|
|
88
|
+
<Slider defaultValue={[50]} css={{ width: '320px' }}>
|
|
89
|
+
<Slider.Value
|
|
90
|
+
value={[50]}
|
|
91
|
+
outputLabel={(value) =>
|
|
92
|
+
value === 0
|
|
93
|
+
? 'You have no geese'
|
|
94
|
+
: `You have ${value} ${value === 1 ? 'goose' : 'geese'}`
|
|
95
|
+
}
|
|
96
|
+
/>
|
|
97
|
+
</Slider>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Should you wish to use the label with multiple values, you can use `Array.join()` like below.
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
<Slider.Value
|
|
104
|
+
value={[25, 75]}
|
|
105
|
+
outputLabel={(value) => `You have between ${value.join(' and ')} geese`}
|
|
106
|
+
/>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Styling
|
|
110
|
+
|
|
111
|
+
Depending on the background of your page, you can change the theme of the track to be either light or tonal using `theme="light"`. Default is `theme="tonal"`.
|
|
112
|
+
|
|
113
|
+
```tsx preview
|
|
114
|
+
<Box css={{ p: '$5', bg: '$tonal100' }}>
|
|
115
|
+
<Slider theme="light" defaultValue={[50]} css={{ width: '320px' }} />
|
|
116
|
+
</Box>
|
|
117
|
+
```
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Slider Field
|
|
3
|
+
component: SliderField
|
|
4
|
+
description: Combines a Slider with a label and form integration.
|
|
5
|
+
category: Form fields
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
`SliderField` renders a `Slider` with a label, and easy implementation with `Form`. It also renders a `Slider.Value` label underneath the slider, and a `Slider.Steps` component should steps be passed in.
|
|
9
|
+
|
|
10
|
+
In it's most simple form, a slider allows one value to be set between two given values (default 0 and 100).
|
|
11
|
+
|
|
12
|
+
Please note: the `value` or `defaultValue` passed in should always be an array.
|
|
13
|
+
|
|
14
|
+
```tsx preview
|
|
15
|
+
<Form>
|
|
16
|
+
<SliderField name="slider" label="Select a value" defaultValue={[50]} />
|
|
17
|
+
</Form>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
With optional `Slider.Steps`:
|
|
21
|
+
|
|
22
|
+
```tsx preview
|
|
23
|
+
<Form>
|
|
24
|
+
<SliderField
|
|
25
|
+
name="slider"
|
|
26
|
+
label="Select a value (now with steps)"
|
|
27
|
+
defaultValue={[50]}
|
|
28
|
+
steps={[
|
|
29
|
+
{ value: 0, label: 'min' },
|
|
30
|
+
{ value: 50, label: 'mid' },
|
|
31
|
+
{ value: 100, label: 'max' }
|
|
32
|
+
]}
|
|
33
|
+
/>
|
|
34
|
+
</Form>
|
|
35
|
+
```
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Stepper
|
|
3
|
+
component: Stepper, Stepper.StepBack, Stepper.StepForward
|
|
4
|
+
description: Stepper provides a bullet list of steps and forward/backwards navigation buttons.
|
|
5
|
+
category: Navigation
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
`Stepper` exports multiple components that combine to create a stepped progress view.
|
|
9
|
+
|
|
10
|
+
`Stepper.StepBack` represents the backwards navigation element. It can receive either a child text node or a `label` prop as a function that receives `activeStep` as an argument in order to possibly render different labels based on the current step the user is on. It is automatically disabled while the user is viewing the first step.
|
|
11
|
+
|
|
12
|
+
`Stepper.StepForward` represents the forward navigation element. It can receive either a child text node or a `label` prop as a function that receives `activeStep` as an argument in order to possibly render different labels based on the current step the user is on.
|
|
13
|
+
|
|
14
|
+
`Stepper.Steps` holds the actual bullet list.
|
|
15
|
+
|
|
16
|
+
The root `Stepper` component must be passed `stepCount` as a number in order to display the desired number of bullet steps. It also takes `onStepChange` as a function that takes `activeStep` as an argument. This can be used to determine what content to display, based on the current step. It can also take `onComplete` as a function that gets called when the user clicks the `StepForward` button while on the last step.
|
|
17
|
+
|
|
18
|
+
```tsx preview
|
|
19
|
+
<Stepper stepCount={3}>
|
|
20
|
+
<Stepper.StepBack>Back</Stepper.StepBack>
|
|
21
|
+
<Stepper.Steps />
|
|
22
|
+
<Stepper.StepForward>Next</Stepper.StepForward>
|
|
23
|
+
</Stepper>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
The root `Stepper` component can also take an `allowSkip` prop that allows the user to navigate by clicking the actual bullets.
|
|
27
|
+
|
|
28
|
+
Below is a more complex example that shows how to dynamically render the button labels, get the activeStep in order to potentially use it to determine what content to render based on the current position, and use an `onComplete` function to trigger custom behaviour when the user reaches the final step.
|
|
29
|
+
|
|
30
|
+
```tsx preview
|
|
31
|
+
<Stepper
|
|
32
|
+
stepCount={3}
|
|
33
|
+
allowSkip
|
|
34
|
+
onComplete={() => console.log('Finished')}
|
|
35
|
+
onStepChange={(activeStep) =>
|
|
36
|
+
console.log('Do something with the active step')
|
|
37
|
+
}
|
|
38
|
+
>
|
|
39
|
+
<Stepper.StepBack label={(activeStep) => 'Back'} />
|
|
40
|
+
<Stepper.Steps />
|
|
41
|
+
<Stepper.StepForward
|
|
42
|
+
label={(activeStep) => (activeStep === 2 ? 'Finish' : 'Next')}
|
|
43
|
+
/>
|
|
44
|
+
</Stepper>
|
|
45
|
+
```
|
package/dist/docs/Tabs.mdx
CHANGED
|
@@ -45,6 +45,8 @@ It also takes a `theme` prop that should either be "light" or "dark".
|
|
|
45
45
|
The `Tabs.TriggerList` component simply holds the individual `Tabs.Trigger` components. It can also get custom styling via the `css` prop.
|
|
46
46
|
`Tabs.TriggerList` will automatically show `<` & `>` buttons in case the content is overshooting the available space.
|
|
47
47
|
|
|
48
|
+
The default scroll amount for the scroll buttons on the `Tabs.TriggerList` is 10% of the content width. You can set this to any percentage by setting, for example, `scrollPercentage={25}`.
|
|
49
|
+
|
|
48
50
|
## Tabs.Trigger
|
|
49
51
|
|
|
50
52
|
The `Tabs.Trigger` component holds the content that will be displayed inside the button that the user would click in order to switch tabs. In can hold either a string, or some other component. It needs to be passed a `value` prop, that would be identical to the `value` prop passed to its corresponding `Tabs.Content` component.
|
|
@@ -70,6 +72,21 @@ A `Tabs.Trigger` component can take a `disabled` prop, which would make it unsel
|
|
|
70
72
|
</Tabs>
|
|
71
73
|
```
|
|
72
74
|
|
|
75
|
+
## Styling the `Tabs.TriggerList`
|
|
76
|
+
|
|
77
|
+
The trigger list accepts an appearance property to apply uppercase to all tabs. Simply pass `appearance='uppercase'`.
|
|
78
|
+
|
|
79
|
+
```tsx preview
|
|
80
|
+
<Tabs>
|
|
81
|
+
<Tabs.TriggerList appearance="uppercase">
|
|
82
|
+
<Tabs.Trigger value="tab1">Tab 1</Tabs.Trigger>
|
|
83
|
+
<Tabs.Trigger value="tab2">Tab 2</Tabs.Trigger>
|
|
84
|
+
</Tabs.TriggerList>
|
|
85
|
+
<Tabs.Content value="tab1">Content for tab 1</Tabs.Content>
|
|
86
|
+
<Tabs.Content value="tab2">Content for the second tab.</Tabs.Content>
|
|
87
|
+
</Tabs>
|
|
88
|
+
```
|
|
89
|
+
|
|
73
90
|
## Styling the `Tabs.Trigger`
|
|
74
91
|
|
|
75
92
|
In order to style the different states of a trigger, the following CSS selectors need to be used when passed to the `css` prop:
|