Skip to content

Commit 3011f6a

Browse files
authored
Merge branch 'master' into nm/DE-739
2 parents 225c11e + 389f447 commit 3011f6a

File tree

5 files changed

+121
-16
lines changed

5 files changed

+121
-16
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
---
2+
title: Tag
3+
description: Tags are highlighted text elements that provide quick, at-a-glance contextual information such as status indicators.
4+
category: status
5+
source: 'sentry/components/core/badge/tag'
6+
resources:
7+
figma: https://www.figma.com/design/eTJz6aPgudMY9E6mzyZU0B/ChonkUI--App-Components--WIP-?node-id=3574-5336
8+
js: https://github.com/getsentry/sentry/blob/master/static/app/components/core/badge/tag.tsx
9+
a11y:
10+
WCAG 1.4.3: https://www.w3.org/TR/WCAG22/#contrast-minimum
11+
---
12+
13+
import {useState} from 'react';
14+
15+
import {Tag} from 'sentry/components/core/badge/tag';
16+
import {IconCheckmark, IconCircle, IconRefresh, IconWarning} from 'sentry/icons';
17+
import * as Storybook from 'sentry/stories';
18+
19+
The `Tag` component is a generic primitive for displaying status information. Depending on the `variant` prop, it can be used as an error/warning/success indicator and for various other use cases.
20+
21+
## Variants
22+
23+
Tags support multiple variants for different semantic meanings.
24+
25+
<Storybook.Demo>
26+
<Tag variant="muted">Default</Tag>
27+
<Tag variant="success">Success</Tag>
28+
<Tag variant="danger">Error</Tag>
29+
<Tag variant="warning">Warning</Tag>
30+
<Tag variant="info">Info</Tag>
31+
<Tag variant="promotion">Promotion</Tag>
32+
</Storybook.Demo>
33+
```jsx
34+
<Tag variant="muted">Default</Tag>
35+
<Tag variant="success">Success</Tag>
36+
<Tag variant="danger">Error</Tag>
37+
<Tag variant="warning">Warning</Tag>
38+
<Tag variant="info">Info</Tag>
39+
<Tag variant="promotion">Promotion</Tag>
40+
```
41+
42+
## Icons
43+
44+
The `icon` prop accepts an `<Icon />` component to render a custom leading icon.
45+
46+
<Storybook.Demo>
47+
<Tag icon={<IconCheckmark />} variant="success">
48+
Success
49+
</Tag>
50+
<Tag icon={<IconWarning />} variant="warning">
51+
Warning
52+
</Tag>
53+
<Tag icon={<IconCircle />} variant="promotion">
54+
Promotion
55+
</Tag>
56+
</Storybook.Demo>
57+
```jsx
58+
<Tag icon={<IconCheckmark />} variant="success">
59+
Success
60+
</Tag>
61+
<Tag icon={<IconWarning />} variant="warning">
62+
Warning
63+
</Tag>
64+
<Tag icon={<IconCircle />} variant="promotion">
65+
Promotion
66+
</Tag>
67+
```
68+
69+
## Dismissible Tags
70+
71+
Pass a custom `onDismiss` callback to create a dismissible tag with a trailing close icon.
72+
73+
export function DismissibleTag() {
74+
const [dismissed, setDismissed] = useState(false);
75+
76+
if (dismissed) {
77+
return <Tag icon={<IconRefresh />} variant="muted" onClick={() => setDismissed(false)}>Reset Tag</Tag>
78+
}
79+
80+
return <Tag variant="info" onDismiss={() => setDismissed(true)}>
81+
Dismiss Tag
82+
83+
</Tag>
84+
}
85+
86+
<Storybook.Demo>
87+
<DismissibleTag />
88+
</Storybook.Demo>
89+
```jsx
90+
<Tag variant="info" onDismiss={() => setDismissed(true)}>
91+
Dismiss Tag
92+
</Tag>
93+
```
94+
95+
## See Also
96+
97+
- [Badge](/stories/core/badge/) - Related component for feature badges, alert badges, and deploy badges

static/app/components/core/button/button.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,8 @@ In scenarios where high information density is critical, buttons may be displaye
194194
To meet WCAG 2.2 AA compliance, `<Button>` automatically meets the [WCAG 1.4.3](https://www.w3.org/TR/WCAG22/#contrast-minimum), [WCAG 2.1.1](https://www.w3.org/TR/WCAG22/#keyboard), [WCAG 2.4.7](https://www.w3.org/TR/WCAG22/#focus-visible), [WCAG 2.5.8](https://www.w3.org/TR/WCAG22/#target-size-minimum) success criteria.
195195

196196
Developers should take care to ensure that their implementations additionally follow the [WAI-ARIA Button Pattern](https://www.w3.org/WAI/ARIA/apg/patterns/button/) and properly handle focus changes when an action is triggered.
197+
198+
## See Also
199+
200+
- [LinkButton](/stories/core/linkbutton/) - Button-styled component for navigation
201+
- [Link](/stories/core/link/) - Text link component for navigation

static/app/components/core/button/linkButton.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,3 +227,8 @@ For optimal accessibility:
227227
- Always include `aria-label` for icon-only LinkButtons
228228
- Use descriptive link text that makes sense out of context
229229
- Consider using `title` prop for additional context when needed
230+
231+
## See Also
232+
233+
- [Button](/stories/core/button/) - Standard button for actions that don't navigate
234+
- [Link](/stories/core/link/) - Text link component for navigation

static/app/components/core/link/link.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,8 @@ Both `<Link>` and `<ExternalLink>` components can be used inline in `<Text>` com
116116
that inherits text styling.
117117
</Text>
118118
```
119+
120+
## See Also
121+
122+
- [Button](/stories/core/button/) - Clickable element for actions that don't navigate
123+
- [LinkButton](/stories/core/linkbutton/) - Button-styled component for navigation

static/app/stories/view/storyTree.tsx

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,9 @@ type ComponentSubcategory =
114114
| 'layout'
115115
| 'buttons'
116116
| 'forms'
117-
| 'pickers'
118117
| 'navigation'
119-
| 'status-feedback'
120-
| 'data-display'
118+
| 'status'
119+
| 'display'
121120
| 'overlays'
122121
| 'utilities'
123122
| 'shared';
@@ -139,7 +138,7 @@ export const COMPONENT_SUBCATEGORY_CONFIG: Record<
139138
> = {
140139
layout: {
141140
label: 'Layout',
142-
components: ['composition', 'container', 'flex', 'grid', 'stack'],
141+
components: ['composition', 'container', 'disclosure', 'flex', 'grid', 'stack'],
143142
},
144143
typography: {
145144
label: 'Typography',
@@ -160,11 +159,6 @@ export const COMPONENT_SUBCATEGORY_CONFIG: Record<
160159
'radio',
161160
'switch',
162161
'slider',
163-
],
164-
},
165-
pickers: {
166-
label: 'Pickers',
167-
components: [
168162
'select',
169163
'multiselect',
170164
'compactselect',
@@ -174,13 +168,13 @@ export const COMPONENT_SUBCATEGORY_CONFIG: Record<
174168
},
175169
navigation: {
176170
label: 'Navigation',
177-
components: ['link', 'tabs', 'menulistitem', 'disclosure'],
171+
components: ['link', 'tabs', 'menulistitem'],
178172
},
179-
'status-feedback': {
173+
status: {
180174
label: 'Status & Feedback',
181-
components: ['alert', 'badge', 'toast'],
175+
components: ['alert', 'badge', 'tag', 'toast'],
182176
},
183-
'data-display': {
177+
display: {
184178
label: 'Data Display',
185179
components: ['avatar', 'image', 'codeblock'],
186180
},
@@ -211,10 +205,9 @@ const COMPONENT_SUBCATEGORY_ORDER: ComponentSubcategory[] = [
211205
'typography',
212206
'buttons',
213207
'forms',
214-
'pickers',
215208
'navigation',
216-
'status-feedback',
217-
'data-display',
209+
'status',
210+
'display',
218211
'overlays',
219212
'utilities',
220213
'shared',

0 commit comments

Comments
 (0)