@atom-learning/components 2.29.0-beta.2 → 2.29.0-beta.3
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.d.ts +266 -1
- package/dist/components/accordion/AccordionContent.d.ts +266 -1
- package/dist/components/accordion/AccordionItem.d.ts +266 -1
- package/dist/components/accordion/AccordionTrigger.d.ts +268 -1
- package/dist/components/action-icon/ActionIcon.d.ts +281 -1
- package/dist/components/alert-dialog/AlertDialog.d.ts +266 -1
- package/dist/components/alert-dialog/AlertDialogContent.d.ts +268 -1
- package/dist/components/alert-dialog/alert-context/AlertDialog.d.ts +1 -1
- package/dist/components/avatar/Avatar.d.ts +536 -2
- package/dist/components/badge/Badge.d.ts +534 -1
- package/dist/components/box/Box.d.ts +266 -1
- package/dist/components/button/Button.d.ts +283 -2
- package/dist/components/calendar/Calendar.d.ts +1 -1
- package/dist/components/calendar/Day.d.ts +270 -1
- package/dist/components/carousel/Carousel.d.ts +1 -1
- package/dist/components/carousel/CarouselArrows.d.ts +1 -1
- package/dist/components/carousel/CarouselPagination.d.ts +267 -1
- package/dist/components/carousel/CarouselSlide.d.ts +266 -1
- package/dist/components/carousel/CarouselSlider.d.ts +269 -1
- package/dist/components/checkbox/Checkbox.d.ts +269 -1
- package/dist/components/checkbox-field/CheckboxField.d.ts +2 -2
- package/dist/components/chip/Chip.d.ts +1879 -5
- package/dist/components/chip/ChipGroup.d.ts +1 -1
- package/dist/components/chip-dismissible-group/ChipDismissibleGroupItem.d.ts +547 -2
- package/dist/components/chip-dismissible-group/ChipDismissibleGroupRoot.d.ts +5 -1
- package/dist/components/chip-toggle-group/ChipToggleGroupItem.d.ts +546 -1
- package/dist/components/chip-toggle-group/ChipToggleGroupRoot.d.ts +562 -1
- package/dist/components/combobox/Combobox.d.ts +266 -1
- package/dist/components/combobox/ComboboxInput.d.ts +268 -1
- package/dist/components/combobox/ComboboxList.d.ts +266 -1
- package/dist/components/combobox/ComboboxOption.d.ts +266 -1
- package/dist/components/combobox/ComboboxPopover.d.ts +266 -1
- package/dist/components/data-table/DataTableLoading.d.ts +270 -1
- package/dist/components/data-table/drag-and-drop/Handle.d.ts +559 -1
- package/dist/components/data-table/pagination/Pagination.d.ts +266 -1
- package/dist/components/data-table/pagination/PaginationButtons.d.ts +1 -1
- package/dist/components/date-field/DateField.d.ts +2 -2
- package/dist/components/dialog/Dialog.d.ts +266 -1
- package/dist/components/dialog/DialogBackground.d.ts +531 -1
- package/dist/components/dialog/DialogClose.d.ts +267 -1
- package/dist/components/dialog/DialogContent.d.ts +268 -1
- package/dist/components/dismissible-group/DismissibleGroupItem.d.ts +1 -1
- package/dist/components/dismissible-group/index.d.ts +1 -1
- package/dist/components/divider/Divider.d.ts +268 -1
- package/dist/components/dropdown-menu/DropdownMenu.d.ts +266 -1
- package/dist/components/dropdown-menu/DropdownMenuContent.d.ts +267 -1
- package/dist/components/dropdown-menu/DropdownMenuItem.d.ts +267 -1
- package/dist/components/dropdown-menu/DropdownMenuSeparator.d.ts +267 -1
- package/dist/components/dropdown-menu/DropdownMenuTrigger.d.ts +267 -1
- package/dist/components/empty-state/EmptyState.d.ts +533 -1
- package/dist/components/empty-state/EmptyStateBody.d.ts +543 -1
- package/dist/components/empty-state/EmptyStateImage.d.ts +542 -2
- package/dist/components/empty-state/EmptyStateTitle.d.ts +268 -1
- package/dist/components/field-wrapper/FieldDescription.d.ts +1 -1
- package/dist/components/field-wrapper/FieldWrapper.d.ts +2 -2
- package/dist/components/field-wrapper/InlineFieldWrapper.d.ts +1 -1
- package/dist/components/flex/Flex.d.ts +266 -1
- package/dist/components/form/Form.d.ts +266 -1
- package/dist/components/grid/Grid.d.ts +268 -1
- package/dist/components/heading/Heading.d.ts +270 -2
- package/dist/components/icon/Icon.d.ts +269 -2
- package/dist/components/image/Image.d.ts +269 -2
- package/dist/components/inline-message/InlineMessage.config.d.ts +1 -1
- package/dist/components/inline-message/InlineMessage.d.ts +534 -1
- package/dist/components/input/Input.d.ts +270 -2
- package/dist/components/input-field/InputField.d.ts +2 -2
- package/dist/components/label/Label.d.ts +272 -2
- package/dist/components/link/Link.d.ts +271 -3
- package/dist/components/list/List.d.ts +537 -2
- package/dist/components/loader/Loader.d.ts +1 -1
- package/dist/components/markdown-content/MarkdownContent.d.ts +1 -1
- package/dist/components/markdown-content/components/MarkdownEmphasis.d.ts +266 -1
- package/dist/components/markdown-content/components/MarkdownImage.d.ts +1 -1
- package/dist/components/markdown-content/components/MarkdownList.d.ts +1 -1
- package/dist/components/markdown-content/components/MarkdownThematicBreak.d.ts +1 -1
- package/dist/components/navigation/NavigationMenu.d.ts +1 -1
- package/dist/components/navigation/NavigationMenuDropdown.d.ts +1 -1
- package/dist/components/navigation/NavigationMenuDropdownItem.d.ts +543 -4
- package/dist/components/navigation/NavigationMenuLink.d.ts +1 -1
- package/dist/components/notification-badge/NotificationBadge.d.ts +531 -1
- package/dist/components/number-input/NumberInput.d.ts +1 -1
- package/dist/components/number-input-field/NumberInputField.d.ts +2 -2
- package/dist/components/password-field/PasswordField.d.ts +2 -2
- package/dist/components/password-input/PasswordInput.d.ts +1 -1
- package/dist/components/popover/Popover.d.ts +266 -1
- package/dist/components/popover/PopoverContent.d.ts +268 -1
- package/dist/components/progress-bar/ProgressBar.d.ts +269 -1
- package/dist/components/radio-button/RadioButton.d.ts +268 -2
- package/dist/components/radio-button/RadioButtonGroup.d.ts +270 -1
- package/dist/components/radio-button-field/RadioButtonField.d.ts +2 -2
- package/dist/components/radio-button-field/RadioField.d.ts +3 -3
- package/dist/components/radio-card/RadioCard.d.ts +271 -1
- package/dist/components/radio-card/RadioCardGroup.d.ts +1 -1
- package/dist/components/search-field/SearchField.d.ts +2 -2
- package/dist/components/search-input/SearchInput.d.ts +2 -2
- package/dist/components/select/Select.d.ts +270 -2
- package/dist/components/select-field/SelectField.d.ts +2 -2
- package/dist/components/sidedrawer/SidedrawerAccordion/SidedrawerAccordionContent.d.ts +266 -1
- package/dist/components/sidedrawer/SidedrawerAccordion/SidedrawerAccordionItem.d.ts +267 -1
- package/dist/components/sidedrawer/SidedrawerAccordion/SidedrawerAccordionRoot.d.ts +267 -1
- package/dist/components/sidedrawer/SidedrawerAccordion/SidedrawerAccordionTrigger.d.ts +268 -1
- package/dist/components/sidedrawer/SidedrawerContent.d.ts +266 -1
- package/dist/components/sidedrawer/SidedrawerFooter.d.ts +266 -1
- package/dist/components/sidedrawer/SidedrawerHeader.d.ts +266 -1
- package/dist/components/sidedrawer/SidedrawerOverlay.d.ts +267 -1
- package/dist/components/sidedrawer/SidedrawerTrigger.d.ts +267 -1
- package/dist/components/slider/Slider.d.ts +268 -1
- package/dist/components/slider-field/SliderField.d.ts +3 -3
- package/dist/components/stack/Stack.d.ts +273 -2
- package/dist/components/stack-content/StackContent.d.ts +267 -2
- package/dist/components/stepper/StepperStepBullet.d.ts +533 -1
- package/dist/components/stepper/StepperStepContainer.d.ts +536 -1
- package/dist/components/stepper/StepperStepLabel.d.ts +544 -1
- package/dist/components/stepper/types.d.ts +1 -1
- package/dist/components/switch/Switch.d.ts +267 -1
- package/dist/components/table/Table.d.ts +269 -1
- package/dist/components/table/TableBody.d.ts +268 -1
- package/dist/components/table/TableCell.d.ts +266 -1
- package/dist/components/table/TableFooter.d.ts +266 -1
- package/dist/components/table/TableFooterCell.d.ts +266 -1
- package/dist/components/table/TableHeader.d.ts +268 -1
- package/dist/components/table/TableHeaderCell.d.ts +266 -1
- package/dist/components/table/TableRow.d.ts +536 -2
- package/dist/components/tabs/TabTrigger.d.ts +268 -1
- package/dist/components/tabs/Tabs.d.ts +536 -2
- package/dist/components/tabs/TabsTriggerList.d.ts +269 -1
- package/dist/components/text/Text.d.ts +271 -3
- package/dist/components/textarea/Textarea.d.ts +268 -1
- package/dist/components/textarea-field/TextareaField.d.ts +2 -2
- package/dist/components/toast/Toast.d.ts +268 -1
- package/dist/components/toggle-group/ToggleGroupButton.d.ts +534 -1
- package/dist/components/toggle-group/ToggleGroupItem.d.ts +534 -2
- package/dist/components/toggle-group/ToggleGroupRoot.d.ts +271 -1
- package/dist/components/toggle-group/index.d.ts +1352 -3
- package/dist/components/tooltip/TooltipContent.d.ts +268 -1
- package/dist/components/top-bar/TopBar.d.ts +270 -2
- package/dist/components/top-bar/TopBarBrand.d.ts +808 -4
- package/dist/components/video/Video.d.ts +535 -4
- package/dist/docgen.json +1 -0
- package/dist/docs/Accordion.mdx +45 -0
- package/dist/docs/ActionIcon.mdx +87 -0
- package/dist/docs/AlertDialog.mdx +40 -0
- package/dist/docs/Avatar.mdx +129 -0
- package/dist/docs/Badge.mdx +55 -0
- package/dist/docs/Box.mdx +52 -0
- package/dist/docs/Button.mdx +76 -0
- package/dist/docs/CONTRIBUTING.md +224 -0
- package/dist/docs/CSSWrapper.mdx +10 -0
- package/dist/docs/Carousel.mdx +88 -0
- package/dist/docs/Checkbox.mdx +19 -0
- package/dist/docs/CheckboxField.mdx +14 -0
- package/dist/docs/Chip.mdx +118 -0
- package/dist/docs/ChipDismissibleGroup.mdx +33 -0
- package/dist/docs/ChipToggleGroup.mdx +27 -0
- package/dist/docs/Combobox.mdx +44 -0
- package/dist/docs/DataTable.mdx +279 -0
- package/dist/docs/DateField.mdx +20 -0
- package/dist/docs/DateInput.mdx +87 -0
- package/dist/docs/Dialog.mdx +68 -0
- package/dist/docs/Dismissible.mdx +48 -0
- package/dist/docs/DismissibleGroup.mdx +29 -0
- package/dist/docs/Divider.mdx +16 -0
- package/dist/docs/DropdownMenu.mdx +30 -0
- package/dist/docs/EmptyState.mdx +23 -0
- package/dist/docs/FieldWrapper.mdx +30 -0
- package/dist/docs/FileInput.mdx +45 -0
- package/dist/docs/Flex.mdx +16 -0
- package/dist/docs/Form.mdx +411 -0
- package/dist/docs/Grid.mdx +28 -0
- package/dist/docs/Heading.mdx +30 -0
- package/dist/docs/Icon.mdx +30 -0
- package/dist/docs/Image.mdx +14 -0
- package/dist/docs/InlineMessage.mdx +52 -0
- package/dist/docs/Input.mdx +24 -0
- package/dist/docs/InputField.mdx +26 -0
- package/dist/docs/Label.mdx +32 -0
- package/dist/docs/Link.mdx +53 -0
- package/dist/docs/List.mdx +38 -0
- package/dist/docs/Loader.mdx +16 -0
- package/dist/docs/MarkdownContent.mdx +77 -0
- package/dist/docs/NavigationMenu.mdx +144 -0
- package/dist/docs/NotificationBadge.mdx +35 -0
- package/dist/docs/NumberInput.mdx +37 -0
- package/dist/docs/NumberInputField.mdx +26 -0
- package/dist/docs/PasswordField.mdx +23 -0
- package/dist/docs/PasswordInput.mdx +15 -0
- package/dist/docs/Popover.mdx +29 -0
- package/dist/docs/ProgressBar.mdx +56 -0
- package/dist/docs/RadioButton.mdx +10 -0
- package/dist/docs/RadioButtonField.mdx +25 -0
- package/dist/docs/RadioCard.mdx +62 -0
- package/dist/docs/SearchField.mdx +26 -0
- package/dist/docs/SearchInput.mdx +13 -0
- package/dist/docs/Select.mdx +56 -0
- package/dist/docs/SelectField.mdx +17 -0
- package/dist/docs/Sidedrawer.mdx +155 -0
- package/dist/docs/Slider.mdx +117 -0
- package/dist/docs/SliderField.mdx +35 -0
- package/dist/docs/Stack.mdx +24 -0
- package/dist/docs/StackContent.mdx +32 -0
- package/dist/docs/Stepper.mdx +154 -0
- package/dist/docs/Styling.mdx +85 -0
- package/dist/docs/Switch.mdx +28 -0
- package/dist/docs/Table.mdx +146 -0
- package/dist/docs/Tabs.mdx +102 -0
- package/dist/docs/Text.mdx +24 -0
- package/dist/docs/Textarea.mdx +12 -0
- package/dist/docs/TextareaField.mdx +21 -0
- package/dist/docs/Toast.mdx +20 -0
- package/dist/docs/ToggleGroup.mdx +88 -0
- package/dist/docs/Tooltip.mdx +25 -0
- package/dist/docs/TopBar.mdx +95 -0
- package/dist/docs/Video.mdx +12 -0
- package/dist/docs/accessibility.mdx +67 -0
- package/dist/docs/coreconcepts.mdx +77 -0
- package/dist/docs/introduction.mdx +33 -0
- package/dist/docs/versioning.mdx +40 -0
- package/dist/index.d.ts +1 -1
- package/dist/stitches.d.ts +1949 -2
- package/dist/utilities/create-theme-variants/createThemeVariants.d.ts +109 -1
- package/dist/utilities/css-wrapper/CSSWrapper.d.ts +1 -1
- package/dist/utilities/style/capsize.d.ts +1 -1
- package/dist/utilities/style/keyframe-animations.d.ts +32 -8
- package/package.json +2 -3
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Accordion
|
|
3
|
+
component: Accordion,Accordion.Item,Accordion.Trigger,Accordion.Content
|
|
4
|
+
description: A vertically stacked group of interactive headings that reveal an associated section of content when clicked
|
|
5
|
+
category: Layout
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
The Accordion exports 4 components that combine to make the `Accordion`. The parent Accordion contains `Accordion.Item` components, which themselves must contain `Accordion.Trigger` and `Accordion.Content`.
|
|
9
|
+
|
|
10
|
+
The `Accordion.Trigger` has been simplified to include a chevron icon. Generally, you would only want to render text inside the rest.
|
|
11
|
+
|
|
12
|
+
Default styling has been applied to `Accordion.Trigger`, but `Accordion.Content` is an empty container without styling. Should only text be placed inside, it is highly advisable to apply spacing to align with the styling of the rest of the Accordion. This can be done with either the `css` property, or by placing any other components inside the `Accordion.Content`.
|
|
13
|
+
|
|
14
|
+
You can Read more about the underlying UI component on the [Radix UI documentation site](https://radix-ui.com/primitives/docs/components/accordion).
|
|
15
|
+
|
|
16
|
+
```tsx preview
|
|
17
|
+
<Accordion type="single" defaultValue="1">
|
|
18
|
+
<Accordion.Item value="1">
|
|
19
|
+
<Accordion.Trigger theme="light">Accordion Header 1</Accordion.Trigger>
|
|
20
|
+
<Accordion.Content css={{ p: '$4' }}>Accordion content 1</Accordion.Content>
|
|
21
|
+
</Accordion.Item>
|
|
22
|
+
<Accordion.Item value="2">
|
|
23
|
+
<Accordion.Trigger>Accordion Header 2</Accordion.Trigger>
|
|
24
|
+
<Accordion.Content css={{ p: '$4' }}>Accordion content 2</Accordion.Content>
|
|
25
|
+
</Accordion.Item>
|
|
26
|
+
</Accordion>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Values
|
|
30
|
+
|
|
31
|
+
Each `Accordion.Item` must have a value, which can either be used as a `defaultValue` on the Accordion, or by setting the `value` of the Accordion so it is a controlled component. If value is set, it must also contain an `onValueChange` function that sets the value to a new value.
|
|
32
|
+
|
|
33
|
+
## Collapsible
|
|
34
|
+
|
|
35
|
+
Accordions can be given the property `collapsible`, which allows all items to be collapsed. Without passing this at least one item must be open.
|
|
36
|
+
|
|
37
|
+
## Type
|
|
38
|
+
|
|
39
|
+
Accordions can have `type` as either `single` or `multiple`. This changes how many items can be expanded at once. The default is `single`.
|
|
40
|
+
|
|
41
|
+
Note: if `multiple`, `value` and `defaultValue` must be in an array. Even if you want just one item to be visible initially, you must pass something like `defaultValue={['name']}`
|
|
42
|
+
|
|
43
|
+
## Themes
|
|
44
|
+
|
|
45
|
+
`Accordion.Trigger` can have a `theme` property. Possible values are `primaryDark` and `light`. The default is `primaryDark`.
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Action Icon
|
|
3
|
+
component: ActionIcon
|
|
4
|
+
description: An accessible interactive wrapper around Icon
|
|
5
|
+
category: Navigation
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
`ActionIcon` should be used alongside `Icon` when you require a user interaction.
|
|
9
|
+
|
|
10
|
+
```tsx preview
|
|
11
|
+
<>
|
|
12
|
+
<ActionIcon label="Attach a file" appearance="simple">
|
|
13
|
+
<Icon is={Clip} />
|
|
14
|
+
</ActionIcon>
|
|
15
|
+
<ActionIcon label="Attach a file" appearance="outline">
|
|
16
|
+
<Icon is={Clip} />
|
|
17
|
+
</ActionIcon>
|
|
18
|
+
<ActionIcon label="Attach a file" appearance="solid">
|
|
19
|
+
<Icon is={Clip} />
|
|
20
|
+
</ActionIcon>
|
|
21
|
+
</>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Rounded Variant
|
|
25
|
+
|
|
26
|
+
Setting `isRounded` makes the Action circular when paired with the options "outline" and "solid" for the `appearance` prop
|
|
27
|
+
|
|
28
|
+
```tsx preview
|
|
29
|
+
<>
|
|
30
|
+
<ActionIcon label="Attach a file" appearance="outline" isRounded>
|
|
31
|
+
<Icon is={Bell} />
|
|
32
|
+
</ActionIcon>
|
|
33
|
+
<ActionIcon label="Attach a file" appearance="solid" isRounded>
|
|
34
|
+
<Icon is={Bell} />
|
|
35
|
+
</ActionIcon>
|
|
36
|
+
</>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Disabled state
|
|
40
|
+
|
|
41
|
+
Passing `disabled` makes the Action Icon take a disabled appearance, where any cursor interaction with the component will not render any changes in its UI.
|
|
42
|
+
|
|
43
|
+
```tsx preview
|
|
44
|
+
<>
|
|
45
|
+
<ActionIcon label="Attach a file" appearance="simple" disabled>
|
|
46
|
+
<Icon is={Bell} />
|
|
47
|
+
</ActionIcon>
|
|
48
|
+
<ActionIcon label="Attach a file" appearance="outline" disabled>
|
|
49
|
+
<Icon is={Bell} />
|
|
50
|
+
</ActionIcon>
|
|
51
|
+
<ActionIcon label="Attach a file" appearance="solid" disabled>
|
|
52
|
+
<Icon is={Bell} />
|
|
53
|
+
</ActionIcon>
|
|
54
|
+
</>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
It is recommended to pair `ActionIcon` with `Tooltip` to provide a clear visual description of the action the user is about to perform.
|
|
58
|
+
|
|
59
|
+
```tsx preview
|
|
60
|
+
// `Tooltip.Provider` is included here to enable the example `Tooltip`, but you should generally place it at the root of your application
|
|
61
|
+
<Tooltip.Provider>
|
|
62
|
+
<Tooltip>
|
|
63
|
+
<Tooltip.Trigger asChild>
|
|
64
|
+
<ActionIcon size="lg" label="Add to basket">
|
|
65
|
+
<Icon is={Basket} size="md" />
|
|
66
|
+
</ActionIcon>
|
|
67
|
+
</Tooltip.Trigger>
|
|
68
|
+
<Tooltip.Content>Add to basket</Tooltip.Content>
|
|
69
|
+
</Tooltip>
|
|
70
|
+
</Tooltip.Provider>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Polymorphism
|
|
74
|
+
|
|
75
|
+
The `ActionIcon` component supports polymorphism, therefore depending on whether it receives an `onClick`/`href` as a prop, it will produce a `button` or `link` respectively
|
|
76
|
+
|
|
77
|
+
```tsx preview
|
|
78
|
+
<ActionIcon label="Shuffle selection" onClick={() => console.log('clicked')}>
|
|
79
|
+
<Icon is={Shuffle} />
|
|
80
|
+
</ActionIcon>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
```tsx preview
|
|
84
|
+
<ActionIcon label="Add a new folder" href="/directory/add">
|
|
85
|
+
<Icon is={FolderAdd} />
|
|
86
|
+
</ActionIcon>
|
|
87
|
+
```
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Alert Dialog
|
|
3
|
+
component: AlertDialog,AlertDialog.Trigger,AlertDialog.Content
|
|
4
|
+
description: A modal dialog that interrupts the user with important content and expects a response
|
|
5
|
+
category: Feedback
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
`AlertDialog` exports a number of components that can be composed together to create a modal pop up that expects a response from the user. `AlertDialog` also exports a custom hook that can be used to dynamically render an alert based on some content and a callback; you can see an example of this below.
|
|
9
|
+
|
|
10
|
+
```tsx
|
|
11
|
+
import { AlertProvider, Button, useAlert } from '@atom-learning/components'
|
|
12
|
+
|
|
13
|
+
const Component = () => {
|
|
14
|
+
const { showAlert } = useAlert()
|
|
15
|
+
|
|
16
|
+
const handleClick = () => {
|
|
17
|
+
showAlert({
|
|
18
|
+
title: 'Are you sure you want to delete this school?',
|
|
19
|
+
description: 'This will remove all restrictions from your school',
|
|
20
|
+
confirmActionText: 'Delete school',
|
|
21
|
+
cancelActionText: 'Cancel',
|
|
22
|
+
onAction: (result) => {
|
|
23
|
+
if (result) console.log('Confirmation')
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return <Button onClick={handleClick}>Delete school</Button>
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const App = () => (
|
|
32
|
+
<AlertProvider>
|
|
33
|
+
<Component />
|
|
34
|
+
</AlertProvider>
|
|
35
|
+
)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Accessibility
|
|
39
|
+
|
|
40
|
+
Consider pairing the `onAction` function with a method that can announce a message to the user. In the above example a message of "School has been deleted" would be appropriate for screen reader users. [Radix UI Announce](https://radix-ui.com/primitives/docs/utilities/announce) would be a good candidate for this.
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Avatar
|
|
3
|
+
component: Avatar,Avatar.Image,Avatar.Initial,Avatar.Placeholder,Avatar.Icon
|
|
4
|
+
description: Show a thumbnail representation of an individual or entity.
|
|
5
|
+
category: Media
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
The `Avatar` component can be used to show a visual representation of a user or entity. It helps to quickly identify users or objects.
|
|
9
|
+
|
|
10
|
+
```jsx preview
|
|
11
|
+
<Avatar name="Alice Smith">
|
|
12
|
+
<Avatar.Image
|
|
13
|
+
alt="Alice Smith's avatar"
|
|
14
|
+
src="https://thispersondoesnotexist.com/image"
|
|
15
|
+
/>
|
|
16
|
+
</Avatar>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Instead of an image, the initial of the name or a placeholder icon can be used
|
|
20
|
+
|
|
21
|
+
```jsx preview
|
|
22
|
+
<>
|
|
23
|
+
<Avatar name="Alice Smith">
|
|
24
|
+
<Avatar.Initial />
|
|
25
|
+
</Avatar>
|
|
26
|
+
<Avatar>
|
|
27
|
+
<Avatar.Placeholder />
|
|
28
|
+
</Avatar>
|
|
29
|
+
</>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
When an image src is missing it will fallback to the initial of the name.
|
|
33
|
+
|
|
34
|
+
```jsx preview
|
|
35
|
+
<Avatar name="Alice Smith">
|
|
36
|
+
<Avatar.Image alt="" src="" />
|
|
37
|
+
</Avatar>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
When the name is also missing it will fallback to the placeholder icon.
|
|
41
|
+
|
|
42
|
+
```jsx preview
|
|
43
|
+
<Avatar name="">
|
|
44
|
+
<Avatar.Image alt="Alice Smith's avatar" src="" />
|
|
45
|
+
</Avatar>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
When `<Avatar.Initial />` is used but the name is missing, it will fallback to the placeholder icon.
|
|
49
|
+
|
|
50
|
+
```jsx preview
|
|
51
|
+
<Avatar name="">
|
|
52
|
+
<Avatar.Initial />
|
|
53
|
+
</Avatar>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
An `onClick` prop can be used, this will make the component focusable using the keyboard, as it uses a `<button>` under the hood.
|
|
57
|
+
|
|
58
|
+
```jsx preview
|
|
59
|
+
<Avatar name="Alice Smith" onClick={() => alert('Thanks for clicking')}>
|
|
60
|
+
<Avatar.Initial />
|
|
61
|
+
</Avatar>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
When disabled, the onClick won't work.
|
|
65
|
+
|
|
66
|
+
```jsx preview
|
|
67
|
+
<Avatar
|
|
68
|
+
name="Alice Smith"
|
|
69
|
+
disabled
|
|
70
|
+
onClick={() => alert('This message will not appear')}
|
|
71
|
+
>
|
|
72
|
+
<Avatar.Initial />
|
|
73
|
+
</Avatar>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Instead of an image, an icon can be passed.
|
|
77
|
+
|
|
78
|
+
```jsx preview
|
|
79
|
+
<>
|
|
80
|
+
<Avatar>
|
|
81
|
+
<Avatar.Icon is={BatteryMedium} />
|
|
82
|
+
</Avatar>
|
|
83
|
+
</>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Size
|
|
87
|
+
|
|
88
|
+
The available `size`s for this component are: `xs`, `sm`, `md`, `lg`, `xl` and `xxl`. The default is `lg`.
|
|
89
|
+
|
|
90
|
+
```jsx live
|
|
91
|
+
<>
|
|
92
|
+
<Avatar size="xs" name="Alice Smith">
|
|
93
|
+
<Avatar.Image
|
|
94
|
+
alt="Alice Smith's avatar"
|
|
95
|
+
src="https://thispersondoesnotexist.com/image"
|
|
96
|
+
/>
|
|
97
|
+
</Avatar>
|
|
98
|
+
<Avatar size="sm" name="Alice Smith">
|
|
99
|
+
<Avatar.Image
|
|
100
|
+
alt="Alice Smith's avatar"
|
|
101
|
+
src="https://thispersondoesnotexist.com/image"
|
|
102
|
+
/>
|
|
103
|
+
</Avatar>
|
|
104
|
+
<Avatar size="md" name="Alice Smith">
|
|
105
|
+
<Avatar.Image
|
|
106
|
+
alt="Alice Smith's avatar"
|
|
107
|
+
src="https://thispersondoesnotexist.com/image"
|
|
108
|
+
/>
|
|
109
|
+
</Avatar>
|
|
110
|
+
<Avatar size="lg" name="Alice Smith">
|
|
111
|
+
<Avatar.Image
|
|
112
|
+
alt="Alice Smith's avatar"
|
|
113
|
+
src="https://thispersondoesnotexist.com/image"
|
|
114
|
+
/>
|
|
115
|
+
</Avatar>
|
|
116
|
+
<Avatar size="xl" name="Alice Smith">
|
|
117
|
+
<Avatar.Image
|
|
118
|
+
alt="Alice Smith's avatar"
|
|
119
|
+
src="https://thispersondoesnotexist.com/image"
|
|
120
|
+
/>
|
|
121
|
+
</Avatar>
|
|
122
|
+
<Avatar size="xxl" name="Alice Smith">
|
|
123
|
+
<Avatar.Image
|
|
124
|
+
alt="Alice Smith's avatar"
|
|
125
|
+
src="https://thispersondoesnotexist.com/image"
|
|
126
|
+
/>
|
|
127
|
+
</Avatar>
|
|
128
|
+
</>
|
|
129
|
+
```
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Badge
|
|
3
|
+
component: Badge
|
|
4
|
+
description: Highlights a small piece of information
|
|
5
|
+
category: Feedback
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
The `Badge` component can be used to highlight a short piece of information, like a status.
|
|
9
|
+
|
|
10
|
+
```tsx preview
|
|
11
|
+
<Badge>New Data</Badge>
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Theme
|
|
15
|
+
|
|
16
|
+
These are the available `theme`s for this component: `success`, `warning`, `danger`, `neutral` and `info`. The default is `info`
|
|
17
|
+
|
|
18
|
+
```tsx preview
|
|
19
|
+
<>
|
|
20
|
+
<Badge>Info</Badge>
|
|
21
|
+
<Badge theme="neutral">Neutral</Badge>
|
|
22
|
+
<Badge theme="success">Success</Badge>
|
|
23
|
+
<Badge theme="warning">Warning</Badge>
|
|
24
|
+
<Badge theme="danger">Danger</Badge>
|
|
25
|
+
</>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Size
|
|
29
|
+
|
|
30
|
+
These are the available `size`s for this component: `xs`, `sm` and `md`. The default is `sm`
|
|
31
|
+
|
|
32
|
+
```tsx preview
|
|
33
|
+
<>
|
|
34
|
+
<Badge size="xs">extra small</Badge>
|
|
35
|
+
<Badge size="sm">small</Badge>
|
|
36
|
+
<Badge size="md">medium</Badge>
|
|
37
|
+
</>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## With icons
|
|
41
|
+
|
|
42
|
+
An `<Icon />` can be passed as a child to show alongside text.
|
|
43
|
+
|
|
44
|
+
```tsx preview
|
|
45
|
+
<>
|
|
46
|
+
<Badge>
|
|
47
|
+
<Icon is={Wifi} />
|
|
48
|
+
Info with icon
|
|
49
|
+
</Badge>
|
|
50
|
+
<Badge theme="neutral">
|
|
51
|
+
Info with icon
|
|
52
|
+
<Icon is={Wifi} />
|
|
53
|
+
</Badge>
|
|
54
|
+
</>
|
|
55
|
+
```
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Box
|
|
3
|
+
component: Box
|
|
4
|
+
description: Box is our most fundamental layout component
|
|
5
|
+
category: Layout
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
`Box` can largely be seen as an abstraction over the `div` element. It is most useful when used as a generic containing component, and when paired with `as` and `css` allows a high degree of composition and flexibility.
|
|
9
|
+
|
|
10
|
+
`Box` falls back to rendering a `div`, but we should use it to render more sematically relevant container elements e.g. `<Box as="section">`. As an example, a card component could use `Box` to render a `section`, `header` and `footer`.
|
|
11
|
+
|
|
12
|
+
Avoid rendering any of these elements directly in our components — `Box` has all the same flexibility, but with the addition of the powerful `css` prop and various styling utilities based on our themes.
|
|
13
|
+
|
|
14
|
+
## Example
|
|
15
|
+
|
|
16
|
+
To show an example of the benefits of using `Box`, the card below is composed together using `Box` alongside other relevant components:
|
|
17
|
+
|
|
18
|
+
```tsx live
|
|
19
|
+
<Box
|
|
20
|
+
as="article"
|
|
21
|
+
css={{
|
|
22
|
+
border: '1px solid $tonal100',
|
|
23
|
+
borderRadius: '$1',
|
|
24
|
+
overflow: 'hidden',
|
|
25
|
+
width: '320px'
|
|
26
|
+
}}
|
|
27
|
+
>
|
|
28
|
+
<Box as="figure" css={{ m: 0, position: 'relative' }}>
|
|
29
|
+
<Image src="http://placekitten.com/320/200" alt="Cats having a nice time" />
|
|
30
|
+
<Text
|
|
31
|
+
as="figcaption"
|
|
32
|
+
size="sm"
|
|
33
|
+
css={{
|
|
34
|
+
bottom: '$3',
|
|
35
|
+
color: 'white',
|
|
36
|
+
position: 'absolute',
|
|
37
|
+
right: '$3'
|
|
38
|
+
}}
|
|
39
|
+
>
|
|
40
|
+
Here is a cute cat
|
|
41
|
+
</Text>
|
|
42
|
+
</Box>
|
|
43
|
+
<Stack gap="4" css={{ px: '$3', py: '$4' }}>
|
|
44
|
+
<Heading as="h2" size="sm">
|
|
45
|
+
Cat
|
|
46
|
+
</Heading>
|
|
47
|
+
<Text>
|
|
48
|
+
The cat (Felis catus) is a domestic species of small carnivorous mammal.
|
|
49
|
+
</Text>
|
|
50
|
+
</Stack>
|
|
51
|
+
</Box>
|
|
52
|
+
```
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Button
|
|
3
|
+
component: Button
|
|
4
|
+
description: The Button component is a light wrapper around an HTML button element
|
|
5
|
+
category: Navigation
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
It adds default styling and the `css` prop. By default `primary` theme is displayed with a `solid` appearance.
|
|
9
|
+
|
|
10
|
+
```tsx live
|
|
11
|
+
<Button>Hello world</Button>
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Themes
|
|
15
|
+
|
|
16
|
+
These are the available `themes` for the `Button` component: `primary` (default), `secondary`, `success`, `warning`, `danger`, and `neutral`.
|
|
17
|
+
|
|
18
|
+
```tsx preview
|
|
19
|
+
<>
|
|
20
|
+
<Button>Primary</Button>
|
|
21
|
+
<Button theme="secondary">Secondary</Button>
|
|
22
|
+
<Button theme="success">Success</Button>
|
|
23
|
+
<Button theme="warning">Warning</Button>
|
|
24
|
+
<Button theme="danger">Danger</Button>
|
|
25
|
+
<Button theme="neutral">Neutral</Button>
|
|
26
|
+
</>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Appearance
|
|
30
|
+
|
|
31
|
+
There are two options for the `appearance` property: `solid` and `outline`. There are the available `outline` variations for the `primary`, `secondary` and `neutral` themes.
|
|
32
|
+
|
|
33
|
+
```tsx preview
|
|
34
|
+
<Button appearance="outline">Primary</Button>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Disabled state
|
|
38
|
+
|
|
39
|
+
Each variation has an `disabled` stated, by setting the `disabled` property.
|
|
40
|
+
|
|
41
|
+
```tsx preview
|
|
42
|
+
<>
|
|
43
|
+
<Button disabled>Disabled button</Button>
|
|
44
|
+
<Button theme="success" disabled>
|
|
45
|
+
Disabled button
|
|
46
|
+
</Button>
|
|
47
|
+
</>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Loading state
|
|
51
|
+
|
|
52
|
+
When using a button to request data or fire an action that has a potential delay, including a loading state to the button can be a useful indicator that stuff is happening. The `isLoading` prop must be a boolean value to activate the loading state.
|
|
53
|
+
|
|
54
|
+
```tsx live
|
|
55
|
+
<Button isLoading> Hello world</Button>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Rounded Variant
|
|
59
|
+
|
|
60
|
+
Setting `isRounded` creates a rounded button
|
|
61
|
+
|
|
62
|
+
```tsx live
|
|
63
|
+
<Button isRounded>Rounded Button</Button>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Polymorphism
|
|
67
|
+
|
|
68
|
+
The `Button` component supports polymorphism, therefore depending on whether it receives an `onClick`/`href` as a prop, it will produce a `button` or `link` respectively
|
|
69
|
+
|
|
70
|
+
```tsx preview
|
|
71
|
+
<Button href="http://example.com/">I'm a link</Button>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
```tsx preview
|
|
75
|
+
<Button onClick={() => console.log('clicked')}>I'm a button</Button>
|
|
76
|
+
```
|