Skip to content

Commit 031b227

Browse files
dnywhjoshenlim
andauthored
studio(chore): badge component defrag (supabase#40118)
* component clean up * optically center * docs and type size * code badge variant * sensible defaults * fix product menu flex * badge sweep * new project badges * logs * compute badge * studio badge sweep * www sweep * docs sweep * clean up * fixes * cleanup * fixes * better docs * fixes * misc fixes * consistency * Minor fixes for issues i found * simplify mt-0 * mt simplification * remaining optical alignment --------- Co-authored-by: Joshen Lim <[email protected]>
1 parent 0a02451 commit 031b227

File tree

96 files changed

+358
-569
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+358
-569
lines changed

apps/design-system/__registry__/index.tsx

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -192,24 +192,13 @@ export const Index: Record<string, any> = {
192192
subcategory: "undefined",
193193
chunks: []
194194
},
195-
"badge-destructive": {
196-
name: "badge-destructive",
195+
"badge-state": {
196+
name: "badge-state",
197197
type: "components:example",
198198
registryDependencies: ["badge"],
199-
component: React.lazy(() => import("@/registry/default/example/badge-destructive")),
199+
component: React.lazy(() => import("@/registry/default/example/badge-state")),
200200
source: "",
201-
files: ["registry/default/example/badge-destructive.tsx"],
202-
category: "undefined",
203-
subcategory: "undefined",
204-
chunks: []
205-
},
206-
"badge-outline": {
207-
name: "badge-outline",
208-
type: "components:example",
209-
registryDependencies: ["badge"],
210-
component: React.lazy(() => import("@/registry/default/example/badge-outline")),
211-
source: "",
212-
files: ["registry/default/example/badge-outline.tsx"],
201+
files: ["registry/default/example/badge-state.tsx"],
213202
category: "undefined",
214203
subcategory: "undefined",
215204
chunks: []

apps/design-system/components/source-panel.tsx

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import Link from 'next/link'
33
import { forwardRef } from 'react'
44

55
import { ExternalLink } from 'lucide-react'
6+
import Image from 'next/image'
67
import { Button } from 'ui'
78
import { cn } from 'ui/src/lib/utils/cn'
8-
import Image from 'next/image'
99

1010
const SourcePanel = forwardRef<HTMLDivElement, React.HTMLProps<HTMLDivElement> & { doc: Doc }>(
1111
({ doc, children, ...props }, ref) => {
@@ -133,13 +133,7 @@ const SourcePanel = forwardRef<HTMLDivElement, React.HTMLProps<HTMLDivElement> &
133133
className="rounded-full"
134134
icon={<ExternalLink className="text-foreground-muted" strokeWidth={1} />}
135135
>
136-
<Link
137-
href={doc.links.api}
138-
target="_blank"
139-
rel="noreferrer"
140-
141-
// className={cn(badgeVariants({ variant: 'default' }), 'gap-1')}
142-
>
136+
<Link href={doc.links.api} target="_blank" rel="noreferrer">
143137
API Reference
144138
</Link>
145139
</Button>
@@ -233,13 +227,7 @@ const SourcePanel = forwardRef<HTMLDivElement, React.HTMLProps<HTMLDivElement> &
233227
className="rounded-full"
234228
icon={<ExternalLink className="text-foreground-muted" strokeWidth={1} />}
235229
>
236-
<Link
237-
href={doc.links.api}
238-
target="_blank"
239-
rel="noreferrer"
240-
241-
// className={cn(badgeVariants({ variant: 'default' }), 'gap-1')}
242-
>
230+
<Link href={doc.links.api} target="_blank" rel="noreferrer">
243231
API Reference
244232
</Link>
245233
</Button>
Lines changed: 11 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,12 @@
11
---
22
title: Badge
3-
description: Displays a badge or a component that looks like a badge.
3+
description: Add contextual metadata to another item.
44
component: true
5-
source:
6-
shadcn: true
75
---
86

9-
<ComponentPreview name="badge-demo" peekCode wide />
7+
Badge displays contextual information such as surrounding state or product category. Its purpose should be be self-evident based on surrounding context.
108

11-
## Installation
12-
13-
<Tabs defaultValue="cli">
14-
15-
<TabsList>
16-
<TabsTrigger value="cli">CLI</TabsTrigger>
17-
<TabsTrigger value="manual">Manual</TabsTrigger>
18-
</TabsList>
19-
<TabsContent value="cli">
20-
21-
```bash
22-
npx shadcn-ui@latest add badge
23-
```
24-
25-
</TabsContent>
26-
27-
<TabsContent value="manual">
28-
29-
<Steps>
30-
31-
<Step>Copy and paste the following code into your project.</Step>
32-
33-
<ComponentSource name="badge" />
34-
35-
<Step>Update the import paths to match your project setup.</Step>
36-
37-
</Steps>
38-
39-
</TabsContent>
40-
41-
</Tabs>
9+
<ComponentPreview name="badge-demo" peekCode />
4210

4311
## Usage
4412

@@ -47,41 +15,23 @@ import { Badge } from '@/components/ui/badge'
4715
```
4816

4917
```tsx
50-
<Badge variant="outline">Badge</Badge>
18+
<Badge variant="default">Default</Badge>
5119
```
5220

53-
### Link
21+
Avoid altering the Badge style, such as text case or roundedness. Consistent implementation makes Badge immediately recognizable throughout Supabase for denoting state or category. Use or create another component for other use cases, such as compute size and status.
5422

55-
You can use the `badgeVariants` helper to create a link that looks like a badge.
23+
Keep Badge text to one or two words as it is designed to support other elements, not as a primary communication aid.
5624

57-
```tsx
58-
import { badgeVariants } from '@/components/ui/badge'
59-
```
60-
61-
```tsx
62-
<Link className={badgeVariants({ variant: 'outline' })}>Badge</Link>
63-
```
25+
Badge is designed to stand out, so should be used sparingly.
6426

6527
## Examples
6628

67-
### Default
29+
### States
6830

69-
<ComponentPreview name="badge-demo" peekCode wide />
70-
71-
---
31+
<ComponentPreview name="badge-state" peekCode />
7232

7333
### Secondary
7434

75-
<ComponentPreview name="badge-secondary" />
76-
77-
---
78-
79-
### Outline
80-
81-
<ComponentPreview name="badge-outline" />
82-
83-
---
84-
85-
### Destructive
35+
A content-only variant similar to the `text` variant of [Button](../components/button#types).
8636

87-
<ComponentPreview name="badge-destructive" />
37+
<ComponentPreview name="badge-secondary" peekCode />
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Badge } from 'ui'
22

33
export default function BadgeDemo() {
4-
return <Badge>Badge</Badge>
4+
return <Badge>Default</Badge>
55
}

apps/design-system/registry/default/example/badge-destructive.tsx

Lines changed: 0 additions & 5 deletions
This file was deleted.

apps/design-system/registry/default/example/badge-outline.tsx

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Badge } from 'ui'
2+
3+
export default function BadgeState() {
4+
return (
5+
<div className="flex flex-row gap-2">
6+
<Badge variant="default">Default</Badge>
7+
<Badge variant="warning">Warning</Badge>
8+
<Badge variant="success">Success</Badge>
9+
<Badge variant="destructive">Destructive</Badge>
10+
</div>
11+
)
12+
}

apps/design-system/registry/default/example/modal-custom-footer.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ export default function ModalVerticalCustomFooter() {
3232
customFooter={
3333
<div className="flex items-center gap-3">
3434
<div>
35-
<Badge variant="destructive" dot size="small">
36-
Proceed with caution
37-
</Badge>
35+
<Badge variant="destructive">Proceed with caution</Badge>
3836
</div>
3937
<Button type="secondary">Cancel</Button>
4038
<Button type="danger">Delete</Button>

apps/design-system/registry/examples.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,10 @@ export const examples: Registry = [
6262
files: ['example/badge-demo.tsx'],
6363
},
6464
{
65-
name: 'badge-destructive',
65+
name: 'badge-state',
6666
type: 'components:example',
6767
registryDependencies: ['badge'],
68-
files: ['example/badge-destructive.tsx'],
69-
},
70-
{
71-
name: 'badge-outline',
72-
type: 'components:example',
73-
registryDependencies: ['badge'],
74-
files: ['example/badge-outline.tsx'],
68+
files: ['example/badge-state.tsx'],
7569
},
7670
{
7771
name: 'badge-secondary',

apps/docs/components/Navigation/NavigationMenu/GlobalNavigationMenu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ export const MenuItem = React.forwardRef<
179179
<>
180180
{icon && <MenuIconPicker icon={icon} className="text-foreground-lighter" />}
181181
<span className="flex-1">{title}</span>
182-
{community && <Badge size="small">Community</Badge>}
182+
{community && <Badge>Community</Badge>}
183183
</>
184184
)}
185185
</Link>

0 commit comments

Comments
 (0)