@utilitywarehouse/hearth-react 0.28.6 → 0.29.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/README.md +34 -20
- package/SKILL.md +355 -0
- package/dist/{chunk-O7RBVBMN.cjs → chunk-LWHIBSW2.cjs} +2 -2
- package/dist/{chunk-O7RBVBMN.cjs.map → chunk-LWHIBSW2.cjs.map} +1 -1
- package/dist/{chunk-JRVYOIXR.js → chunk-MIVYZGEV.js} +2 -2
- package/dist/components/CardAccordion/CardAccordion.context.d.ts.map +1 -1
- package/dist/components/Combobox/Combobox.cjs +1 -1
- package/dist/components/Combobox/Combobox.js +1 -1
- package/dist/components/ExpandableCard/ExpandableCard.cjs +1 -1
- package/dist/components/ExpandableCard/ExpandableCard.js +1 -1
- package/dist/helpers/get-classname-styles.d.ts.map +1 -1
- package/dist/helpers/logger.d.ts.map +1 -1
- package/dist/helpers/merge-ids.d.ts.map +1 -1
- package/dist/hooks/use-ids.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +18 -12
- package/public/llms/components/accordion.md +321 -0
- package/public/llms/components/alert.md +217 -0
- package/public/llms/components/avatar.md +112 -0
- package/public/llms/components/badge.md +158 -0
- package/public/llms/components/body-text.md +200 -0
- package/public/llms/components/box.md +148 -0
- package/public/llms/components/breadcrumbs.md +97 -0
- package/public/llms/components/button.md +595 -0
- package/public/llms/components/card-accordion.md +277 -0
- package/public/llms/components/card.md +985 -0
- package/public/llms/components/checkbox-group.md +193 -0
- package/public/llms/components/checkbox-tile.md +116 -0
- package/public/llms/components/checkbox.md +108 -0
- package/public/llms/components/combobox.md +360 -0
- package/public/llms/components/container.md +162 -0
- package/public/llms/components/currency-input.md +85 -0
- package/public/llms/components/date-input.md +90 -0
- package/public/llms/components/date-picker.md +159 -0
- package/public/llms/components/description-list.md +149 -0
- package/public/llms/components/detail-text.md +89 -0
- package/public/llms/components/divider.md +88 -0
- package/public/llms/components/em.md +43 -0
- package/public/llms/components/expandable-card.md +231 -0
- package/public/llms/components/flex.md +197 -0
- package/public/llms/components/grid.md +244 -0
- package/public/llms/components/heading.md +65 -0
- package/public/llms/components/helper-text.md +27 -0
- package/public/llms/components/highlight-banner.md +94 -0
- package/public/llms/components/icon-button.md +516 -0
- package/public/llms/components/icon-container.md +247 -0
- package/public/llms/components/inline-link.md +190 -0
- package/public/llms/components/label.md +28 -0
- package/public/llms/components/link.md +236 -0
- package/public/llms/components/list.md +715 -0
- package/public/llms/components/menu.md +270 -0
- package/public/llms/components/modal.md +328 -0
- package/public/llms/components/pagination.md +138 -0
- package/public/llms/components/password-input.md +93 -0
- package/public/llms/components/progress-bar.md +139 -0
- package/public/llms/components/progress-stepper.md +147 -0
- package/public/llms/components/radio-group.md +487 -0
- package/public/llms/components/search-input.md +132 -0
- package/public/llms/components/section-header.md +82 -0
- package/public/llms/components/select.md +148 -0
- package/public/llms/components/skeleton.md +282 -0
- package/public/llms/components/spinner.md +59 -0
- package/public/llms/components/strong.md +49 -0
- package/public/llms/components/switch.md +106 -0
- package/public/llms/components/table.md +230 -0
- package/public/llms/components/tabs.md +320 -0
- package/public/llms/components/text-area.md +141 -0
- package/public/llms/components/text-input.md +228 -0
- package/public/llms/components/toast.md +323 -0
- package/public/llms/components/toggle-button-card.md +513 -0
- package/public/llms/components/tooltip.md +188 -0
- package/public/llms/components/unstyled-icon-button.md +175 -0
- package/public/llms/components/validation-text.md +29 -0
- package/public/llms/components/verification-input.md +96 -0
- package/public/llms/docs/changelog.md +1430 -0
- package/public/llms/docs/common-props/align-self.md +90 -0
- package/public/llms/docs/common-props/border.md +308 -0
- package/public/llms/docs/common-props/colour.md +221 -0
- package/public/llms/docs/common-props/flex-items.md +91 -0
- package/public/llms/docs/common-props/gap.md +111 -0
- package/public/llms/docs/common-props/grid-items.md +96 -0
- package/public/llms/docs/common-props/margin.md +105 -0
- package/public/llms/docs/common-props/opacity.md +100 -0
- package/public/llms/docs/common-props/order.md +90 -0
- package/public/llms/docs/common-props/overflow.md +89 -0
- package/public/llms/docs/common-props/padding.md +102 -0
- package/public/llms/docs/common-props/position.md +92 -0
- package/public/llms/docs/common-props/size.md +93 -0
- package/public/llms/docs/common-props/spacing.md +97 -0
- package/public/llms/docs/common-props/text.md +35 -0
- package/public/llms/docs/common-props/z-index.md +88 -0
- package/public/llms/docs/design-tokens.md +72 -0
- package/public/llms/docs/getting-started.md +117 -0
- package/public/llms/docs/layout.md +135 -0
- package/public/llms/docs/migrating.md +302 -0
- package/public/llms/docs/responsive-design/breakpoints.md +119 -0
- package/public/llms/docs/responsive-design/media-queries.md +89 -0
- package/public/llms/docs/responsive-design/responsive-props.md +37 -0
- package/public/llms.txt +97 -0
- package/scripts/init-ai.js +142 -0
- package/styles.css +2 -2
- /package/dist/{chunk-JRVYOIXR.js.map → chunk-MIVYZGEV.js.map} +0 -0
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
# Alert
|
|
2
|
+
|
|
3
|
+
The `Alert` component displays a short, important message in a way that
|
|
4
|
+
attracts the user's attention without interrupting the user's task. This
|
|
5
|
+
component should be used to flag information of high importance, whether it be
|
|
6
|
+
an error, warning, success or information.
|
|
7
|
+
|
|
8
|
+
```tsx
|
|
9
|
+
<Alert
|
|
10
|
+
colorScheme="info"
|
|
11
|
+
title="Alert Title"
|
|
12
|
+
text="This is an example of alert text which can wrap"
|
|
13
|
+
/>
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Color schemes
|
|
17
|
+
|
|
18
|
+
The `colorScheme` prop controls the visual appearance and semantic meaning of the Alert.
|
|
19
|
+
|
|
20
|
+
```tsx
|
|
21
|
+
<Flex direction="column" gap="400">
|
|
22
|
+
<Alert colorScheme="info" title="Information" text="Learn more about our rates." />
|
|
23
|
+
<Alert colorScheme="positive" title="Success" text="Mobile number updated." />
|
|
24
|
+
<Alert colorScheme="danger" title="Error" text="Email address already exists." />
|
|
25
|
+
<Alert colorScheme="warning" title="Warning" text="Payment details needed." />
|
|
26
|
+
</Flex>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## With `AlertIconButton`
|
|
30
|
+
|
|
31
|
+
Alerts can be made interactive by using the `AlertIconButton` component. This adds a clickable button to the alert with appropriate keyboard navigation.
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
<Alert colorScheme="blue" title="Clickable Alert" text="This alert has an interactive button.">
|
|
35
|
+
<AlertIconButton label="Click me" onClick={() => alert('Alert button clicked!')} />
|
|
36
|
+
</Alert>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
<Flex direction="column" gap="400" alignItems="start">
|
|
41
|
+
<Alert
|
|
42
|
+
colorScheme="info"
|
|
43
|
+
title="Clickable Alert"
|
|
44
|
+
text="This entire alert is clickable because it contains an AlertButton."
|
|
45
|
+
>
|
|
46
|
+
<AlertIconButton label="Click me" onClick={() => alert('Alert button clicked!')} />
|
|
47
|
+
</Alert>
|
|
48
|
+
<Alert
|
|
49
|
+
colorScheme="positive"
|
|
50
|
+
title="Custom Button Text"
|
|
51
|
+
text="This alert has a button and a close button."
|
|
52
|
+
onClose={() => alert('Closed')}
|
|
53
|
+
>
|
|
54
|
+
<AlertIconButton label="Click me" onClick={() => alert('Alert button clicked!')} />
|
|
55
|
+
</Alert>
|
|
56
|
+
</Flex>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## With `AlertLink`
|
|
60
|
+
|
|
61
|
+
You can add a link to your alert using the `AlertLink` component. This is useful for directing users to relevant pages or actions.
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
<Alert
|
|
65
|
+
colorScheme="info"
|
|
66
|
+
title="Information"
|
|
67
|
+
text="This alert contains additional information that might be helpful."
|
|
68
|
+
>
|
|
69
|
+
<AlertLink href="#example">Learn more</AlertLink>
|
|
70
|
+
</Alert>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
If you need to you can also render the `AlertLink` as a `button` element using the `asChild` pattern:
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
<AlertLink asChild>
|
|
77
|
+
<button onClick={() => alert('Custom action')}>Custom action as button</button>
|
|
78
|
+
</AlertLink>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
```tsx
|
|
82
|
+
<Flex direction="column" gap="400" alignItems="start">
|
|
83
|
+
<Alert
|
|
84
|
+
colorScheme="info"
|
|
85
|
+
title="Information"
|
|
86
|
+
text="This alert contains additional information that might be helpful."
|
|
87
|
+
>
|
|
88
|
+
<AlertLink href="#example">Learn more</AlertLink>
|
|
89
|
+
</Alert>
|
|
90
|
+
<Alert
|
|
91
|
+
colorScheme="warning"
|
|
92
|
+
title="Warning"
|
|
93
|
+
text="This is a warning message with just an icon link."
|
|
94
|
+
>
|
|
95
|
+
<AlertLink href="#action" />
|
|
96
|
+
</Alert>
|
|
97
|
+
<Alert
|
|
98
|
+
colorScheme="danger"
|
|
99
|
+
title="Sorry, something went wrong"
|
|
100
|
+
text={
|
|
101
|
+
<>
|
|
102
|
+
If the problem persists, please contact Partner Support on{' '}
|
|
103
|
+
<InlineLink href="tel:+443337778777" style={{ color: 'inherit' }}>
|
|
104
|
+
<Strong>0333 7778777</Strong>
|
|
105
|
+
</InlineLink>{' '}
|
|
106
|
+
(Monday to Friday 09:00-17:30, Saturdays 10:00-13:00).
|
|
107
|
+
</>
|
|
108
|
+
}
|
|
109
|
+
>
|
|
110
|
+
<AlertLink asChild>
|
|
111
|
+
<button onClick={() => alert('Custom action')}>Custom action as button</button>
|
|
112
|
+
</AlertLink>
|
|
113
|
+
</Alert>
|
|
114
|
+
</Flex>
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Title and Text
|
|
118
|
+
|
|
119
|
+
`Alert` supports a `title` and `text` prop to provide a clear and concise
|
|
120
|
+
message to users. The `title` is typically used for a brief headline, while the
|
|
121
|
+
`text` provides additional details.
|
|
122
|
+
|
|
123
|
+
These props are optional as they can be used together or separately, depending
|
|
124
|
+
on the context of the alert. While it is technically possible to provide a
|
|
125
|
+
custom title via the `children` prop, it is generally not recommended as it may
|
|
126
|
+
lead to a broken UI and a poor user experience.
|
|
127
|
+
|
|
128
|
+
## Dismissable
|
|
129
|
+
|
|
130
|
+
Alerts can be made dismissable by providing an `onClose` handler. This adds a
|
|
131
|
+
close button that users can click to dismiss the alert.
|
|
132
|
+
The `onClose` handler will be called when the alert is dismissed, allowing you
|
|
133
|
+
to perform any necessary cleanup or state updates. It will not handle the
|
|
134
|
+
actual hiding of the alert, so you will need to manage the visibility state of
|
|
135
|
+
the alert in your component.
|
|
136
|
+
|
|
137
|
+
```tsx
|
|
138
|
+
<Alert
|
|
139
|
+
colorScheme="positive"
|
|
140
|
+
title="Success"
|
|
141
|
+
text="Your action was completed successfully."
|
|
142
|
+
onClose={() => console.log('Alert dismissed')}
|
|
143
|
+
/>
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
```tsx
|
|
147
|
+
<Alert
|
|
148
|
+
colorScheme="positive"
|
|
149
|
+
title="Success"
|
|
150
|
+
text="Your email address has been verified successfully."
|
|
151
|
+
onClose={() => {}}
|
|
152
|
+
/>
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Accessibility
|
|
156
|
+
|
|
157
|
+
- Alerts use the `alert` role by default for screen readers
|
|
158
|
+
- `AlertIconButton` components support keyboard navigation
|
|
159
|
+
- Icons are marked as `aria-hidden="true"` to avoid redundant announcements
|
|
160
|
+
- Proper ARIA attributes are applied for live regions
|
|
161
|
+
|
|
162
|
+
### AlertLink
|
|
163
|
+
|
|
164
|
+
Use `AlertLink` to add navigational links within alerts.
|
|
165
|
+
|
|
166
|
+
```tsx
|
|
167
|
+
<Alert title="Information">
|
|
168
|
+
<BodyText>This alert provides important information.</BodyText>
|
|
169
|
+
<BodyText>The guide is helpful, you can read it below.</BodyText>
|
|
170
|
+
<AlertLink href="/guide">Read Guide</AlertLink>
|
|
171
|
+
</Alert>
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### AlertIconButton
|
|
175
|
+
|
|
176
|
+
Use `AlertIconButton` to add interactive buttons to alerts.
|
|
177
|
+
|
|
178
|
+
```tsx
|
|
179
|
+
<Alert title="Action Required" text="Click the button to continue.">
|
|
180
|
+
<AlertIconButton label="Continue" onClick={() => handleAction()} />
|
|
181
|
+
</Alert>
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## API
|
|
185
|
+
|
|
186
|
+
This component supports the following common props:
|
|
187
|
+
|
|
188
|
+
- AlignSelf
|
|
189
|
+
- Margin
|
|
190
|
+
- Flex item
|
|
191
|
+
- Grid item
|
|
192
|
+
|
|
193
|
+
| Prop | Type | Default | Description |
|
|
194
|
+
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | -------------------------------------- |
|
|
195
|
+
| `title` | `string` | — | Sets the title of the alert. |
|
|
196
|
+
| `text` | `ReactNode` | — | Sets the text of the alert. |
|
|
197
|
+
| `colorScheme` | `"info" \| "positive" \| "danger" \| "warning"` | `info` | Sets the colour scheme. |
|
|
198
|
+
| `onClose` | `(() => void)` | — | Sets the onClose handler of the alert. |
|
|
199
|
+
| `margin` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
200
|
+
| `marginTop` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
201
|
+
| `marginRight` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
202
|
+
| `marginBottom` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
203
|
+
| `marginLeft` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
204
|
+
| `marginX` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
205
|
+
| `marginY` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
206
|
+
| `flex` | `Responsive<string>` | — | |
|
|
207
|
+
| `flexBasis` | `Responsive<string>` | — | |
|
|
208
|
+
| `flexShrink` | `Responsive<string>` | — | |
|
|
209
|
+
| `flexGrow` | `Responsive<string>` | — | |
|
|
210
|
+
| `gridColumnSpan` | `Responsive<Union<string, "1" \| "2" \| "3" \| "4" \| "5" \| "6" \| "7" \| "8" \| "9" \| "10" \| "11" \| "12">>` | — | |
|
|
211
|
+
| `gridArea` | `Responsive<string>` | — | |
|
|
212
|
+
| `gridColumn` | `Responsive<string>` | — | |
|
|
213
|
+
| `gridColumnStart` | `Responsive<string>` | — | |
|
|
214
|
+
| `gridColumnEnd` | `Responsive<string>` | — | |
|
|
215
|
+
| `gridRow` | `Responsive<string>` | — | |
|
|
216
|
+
| `gridRowStart` | `Responsive<string>` | — | |
|
|
217
|
+
| `gridRowEnd` | `Responsive<string>` | — | |
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Avatar
|
|
2
|
+
|
|
3
|
+
Use `Avatar` to help humanise the product experience by connecting users with the product and to each other.
|
|
4
|
+
|
|
5
|
+
```tsx
|
|
6
|
+
<Flex direction="row" gap="400">
|
|
7
|
+
<Flex direction="row" gap="200">
|
|
8
|
+
<Avatar size="md" />
|
|
9
|
+
<Avatar size="sm" />
|
|
10
|
+
</Flex>
|
|
11
|
+
<Flex direction="row" gap="200">
|
|
12
|
+
<Avatar size="md" name="Rob Phoenix" />
|
|
13
|
+
<Avatar size="sm" name="Rob Phoenix" />
|
|
14
|
+
</Flex>
|
|
15
|
+
<Flex direction="row" gap="200">
|
|
16
|
+
<Avatar
|
|
17
|
+
size="md"
|
|
18
|
+
src="https://ca.slack-edge.com/T0HR00WDA-UN6U78K0R-afda0a8a2fa7-512"
|
|
19
|
+
name="Rob Phoenix"
|
|
20
|
+
/>
|
|
21
|
+
<Avatar
|
|
22
|
+
size="sm"
|
|
23
|
+
src="https://ca.slack-edge.com/T0HR00WDA-UN6U78K0R-afda0a8a2fa7-512"
|
|
24
|
+
name="Rob Phoenix"
|
|
25
|
+
/>
|
|
26
|
+
</Flex>
|
|
27
|
+
</Flex>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
<Avatar />
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Usage
|
|
35
|
+
|
|
36
|
+
By default `Avatar` will display an icon.
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
<Avatar />
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
If a name is passed then `Avatar` will display initials.
|
|
43
|
+
|
|
44
|
+
```tsx
|
|
45
|
+
<Avatar name="Rob Phoenix" />
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
If a valid image is passed to the `src` prop, then this will be displayed. When
|
|
49
|
+
doing this you also need to pass the name of the user in the image, to be used
|
|
50
|
+
as an accessible description for the image.
|
|
51
|
+
|
|
52
|
+
```tsx
|
|
53
|
+
<Avatar src="https://ca.slack-edge.com/T0HR00WDA-UN6U78K0R-afda0a8a2fa7-512" name="Rob Phoenix" />
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Accessibility
|
|
57
|
+
|
|
58
|
+
When passing a user image to the `src` prop, you must also pass their name to
|
|
59
|
+
the `name` prop so it can be used as an accessible description for the image.
|
|
60
|
+
|
|
61
|
+
## Image
|
|
62
|
+
|
|
63
|
+
By default the image will only render when it has loaded. While the image is
|
|
64
|
+
loading, or if there has been an error, the user's initials will be rendered.
|
|
65
|
+
there was an error. If you notice a flash during loading, you can provide a
|
|
66
|
+
`delayMs` prop to delay its rendering so it only renders for those with slower
|
|
67
|
+
connections.
|
|
68
|
+
|
|
69
|
+
## Name
|
|
70
|
+
|
|
71
|
+
The `name` prop will be used to generate initials used in the `Avatar`, it will
|
|
72
|
+
also be used for the `alt` text when an image is provided.
|
|
73
|
+
|
|
74
|
+
## Sizes
|
|
75
|
+
|
|
76
|
+
The size prop controls the size of the Avatar. This prop is responsive.
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
<Avatar size={{ mobile: 'sm', desktop: 'md' }} />
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
```tsx
|
|
83
|
+
<Flex direction="row" gap="200" alignItems="center">
|
|
84
|
+
<Avatar
|
|
85
|
+
size={{ mobile: 'sm', desktop: 'md' }}
|
|
86
|
+
src="https://ca.slack-edge.com/T0HR00WDA-UN6U78K0R-afda0a8a2fa7-512"
|
|
87
|
+
name="Rob Phoenix"
|
|
88
|
+
/>
|
|
89
|
+
<Avatar size={{ mobile: 'sm', desktop: 'md' }} name="Rob Phoenix" />
|
|
90
|
+
<Avatar size={{ mobile: 'sm', desktop: 'md' }} />
|
|
91
|
+
</Flex>
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## API
|
|
95
|
+
|
|
96
|
+
This component is based on the `img` & `span` elements and supports the following common props:
|
|
97
|
+
|
|
98
|
+
- Margin
|
|
99
|
+
|
|
100
|
+
| Prop | Type | Default | Description |
|
|
101
|
+
| ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | --------------------------------------------------------------------------------------------------- |
|
|
102
|
+
| `onLoadingStatusChange` | `((status: ImageLoadingStatus) => void)` | — | |
|
|
103
|
+
| `delayMs` | `number` | — | |
|
|
104
|
+
| `name` | `string` | — | Set the name associated with the avatar, used for creating initials, and an accessible description. |
|
|
105
|
+
| `size` | `Responsive<"sm" \| "md">` | `md` | Sets the avatar size. |
|
|
106
|
+
| `margin` | `Responsive<"0" \| "auto" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
107
|
+
| `marginTop` | `Responsive<"0" \| "auto" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
108
|
+
| `marginRight` | `Responsive<"0" \| "auto" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
109
|
+
| `marginBottom` | `Responsive<"0" \| "auto" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
110
|
+
| `marginLeft` | `Responsive<"0" \| "auto" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
111
|
+
| `marginX` | `Responsive<"0" \| "auto" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
112
|
+
| `marginY` | `Responsive<"0" \| "auto" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# Badge
|
|
2
|
+
|
|
3
|
+
A `Badge` is a visual label or indicator used to convey status or highlight content. Badges are read-only status indicators or labels and are not interactive.
|
|
4
|
+
|
|
5
|
+
```tsx
|
|
6
|
+
<Flex direction="column" gap="500">
|
|
7
|
+
{sizes.map(size => (
|
|
8
|
+
<Flex key={size} direction="column" gap="200" alignItems="start">
|
|
9
|
+
{variants.map(variant => (
|
|
10
|
+
<Flex key={variant} gap="200" justifyContent="center" direction="row">
|
|
11
|
+
{allVariantColorSchemes.map(colorScheme => (
|
|
12
|
+
<Badge
|
|
13
|
+
key={`${size}${variant}${colorScheme}`}
|
|
14
|
+
variant={variant}
|
|
15
|
+
colorScheme={colorScheme}
|
|
16
|
+
size={size}
|
|
17
|
+
>
|
|
18
|
+
Badge
|
|
19
|
+
</Badge>
|
|
20
|
+
))}
|
|
21
|
+
{variant !== 'outline'
|
|
22
|
+
? nonOutlineColorSchemes.map(colorScheme => (
|
|
23
|
+
<Badge
|
|
24
|
+
key={`${size}${variant}${colorScheme}`}
|
|
25
|
+
variant={variant}
|
|
26
|
+
colorScheme={colorScheme}
|
|
27
|
+
size={size}
|
|
28
|
+
>
|
|
29
|
+
Badge
|
|
30
|
+
</Badge>
|
|
31
|
+
))
|
|
32
|
+
: null}
|
|
33
|
+
{variant === 'subtle'
|
|
34
|
+
? subtleOnlyColorSchemes.map(colorScheme => (
|
|
35
|
+
<Badge
|
|
36
|
+
key={`${size}${variant}${colorScheme}`}
|
|
37
|
+
variant={variant}
|
|
38
|
+
colorScheme={colorScheme}
|
|
39
|
+
size={size}
|
|
40
|
+
>
|
|
41
|
+
Badge
|
|
42
|
+
</Badge>
|
|
43
|
+
))
|
|
44
|
+
: null}
|
|
45
|
+
</Flex>
|
|
46
|
+
))}
|
|
47
|
+
</Flex>
|
|
48
|
+
))}
|
|
49
|
+
</Flex>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
```tsx
|
|
53
|
+
<Badge variant="subtle" size="md" colorScheme="info">
|
|
54
|
+
Badge
|
|
55
|
+
</Badge>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Variants
|
|
59
|
+
|
|
60
|
+
The variant prop controls the visual appearance of the Badge.
|
|
61
|
+
|
|
62
|
+
```tsx
|
|
63
|
+
<Flex gap="200">
|
|
64
|
+
<Badge variant="subtle">Subtle</Badge>
|
|
65
|
+
<Badge variant="emphasis">Emphasis</Badge>
|
|
66
|
+
<Badge variant="outline">Outline</Badge>
|
|
67
|
+
</Flex>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Sizes
|
|
71
|
+
|
|
72
|
+
The size prop controls the size of the Badge. This prop is responsive.
|
|
73
|
+
|
|
74
|
+
```tsx
|
|
75
|
+
<Flex gap="200" alignItems="center">
|
|
76
|
+
<Badge size="sm">Small</Badge>
|
|
77
|
+
<Badge size="md">Medium</Badge>
|
|
78
|
+
<Badge size={{ mobile: 'sm', desktop: 'md' }}>Responsive</Badge>
|
|
79
|
+
</Flex>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Color schemes
|
|
83
|
+
|
|
84
|
+
The `colorScheme` prop will change the Badge colours.
|
|
85
|
+
|
|
86
|
+
```tsx
|
|
87
|
+
<Flex gap="200" wrap="wrap">
|
|
88
|
+
<Badge colorScheme="info">Info</Badge>
|
|
89
|
+
<Badge colorScheme="positive">Positive</Badge>
|
|
90
|
+
<Badge colorScheme="danger">Danger</Badge>
|
|
91
|
+
<Badge colorScheme="warning">Warning</Badge>
|
|
92
|
+
<Badge colorScheme="functional">Functional</Badge>
|
|
93
|
+
<Badge colorScheme="energy">Energy</Badge>
|
|
94
|
+
<Badge colorScheme="mobile">Mobile</Badge>
|
|
95
|
+
<Badge colorScheme="broadband">Broadband</Badge>
|
|
96
|
+
</Flex>
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Dead prop combinations
|
|
100
|
+
|
|
101
|
+
Be aware there are some combinations of `colorScheme` & `variant` that do not work together (ie. `emphasis` &
|
|
102
|
+
`highlight`), and if used will render a button with no colours at all. You will also see a TypeScript error.
|
|
103
|
+
|
|
104
|
+
## Flat Base
|
|
105
|
+
|
|
106
|
+
The `flatBase` will remove the `border-bottom-right-radius` and `border-bottom-left-radius`, for use when the badge is positioned on top of another element.
|
|
107
|
+
|
|
108
|
+
```tsx
|
|
109
|
+
<Box>
|
|
110
|
+
<Flex justifyContent="end" paddingRight="300" width="400px">
|
|
111
|
+
<Badge colorScheme="positive" variant="emphasis" size="sm" flatBase>
|
|
112
|
+
Multi SIM offer
|
|
113
|
+
</Badge>
|
|
114
|
+
</Flex>
|
|
115
|
+
<Card width="400px" height="200px" colorScheme="neutralSubtle" />
|
|
116
|
+
</Box>
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Icons
|
|
120
|
+
|
|
121
|
+
You can enhance the your badge's meaning by adding a small icon to the
|
|
122
|
+
left. This icon is not an interactive icon button; its purpose is to reinforce
|
|
123
|
+
the meaning of the text.
|
|
124
|
+
|
|
125
|
+
```tsx
|
|
126
|
+
<Flex gap="200">
|
|
127
|
+
<Badge colorScheme="positive">
|
|
128
|
+
<TickSmallIcon />
|
|
129
|
+
Success
|
|
130
|
+
</Badge>
|
|
131
|
+
<Badge colorScheme="danger">
|
|
132
|
+
<CloseSmallIcon />
|
|
133
|
+
Unsuccessful
|
|
134
|
+
</Badge>
|
|
135
|
+
</Flex>
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## API
|
|
139
|
+
|
|
140
|
+
This component is based on the `span` element and supports the following common props:
|
|
141
|
+
|
|
142
|
+
- Margin
|
|
143
|
+
- Text transform
|
|
144
|
+
|
|
145
|
+
| Prop | Type | Default | Description |
|
|
146
|
+
| --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ----------------------------------------------------------------------------------- |
|
|
147
|
+
| `variant` | `"emphasis" \| "subtle" \| "outline"` | `subtle` | Sets the badges's visual variant |
|
|
148
|
+
| `size` | `Responsive<"sm" \| "md">` | `md` | Sets the badge size. |
|
|
149
|
+
| `colorScheme` | `"mobile" \| "info" \| "positive" \| "danger" \| "warning" \| "functional" \| "energy" \| "broadband" \| "insurance" \| "cashback" \| "pig" \| "highlight"` | `info` | Sets the colour scheme. |
|
|
150
|
+
| `flatBase` | `boolean` | `false` | Removes the bottom radius, set when the Badge sits directly above another container |
|
|
151
|
+
| `margin` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
152
|
+
| `marginTop` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
153
|
+
| `marginRight` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
154
|
+
| `marginBottom` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
155
|
+
| `marginLeft` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
156
|
+
| `marginX` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
157
|
+
| `marginY` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
158
|
+
| `textTransform` | `"none" \| "uppercase" \| "lowercase" \| "capitalize"` | — | Set the text-transform on the component. |
|