Skip to content

Commit cbc7971

Browse files
committed
update badge component with pill and outline variants
adds support for pill and outline badge variants, along with some layout fixes and color adjustments. replaces 'blue' variant with 'cyan' and adds new 'blue' variant.
1 parent 2b69e9c commit cbc7971

File tree

1 file changed

+33
-11
lines changed

1 file changed

+33
-11
lines changed

frontend/src/components/ui/badge.ts

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export type BadgeVariant =
1111
| "danger"
1212
| "neutral"
1313
| "primary"
14-
| "blue"
14+
| "cyan"
1515
| "high-contrast";
1616

1717
/**
@@ -27,6 +27,12 @@ export class Badge extends TailwindElement {
2727
@property({ type: String })
2828
variant: BadgeVariant = "neutral";
2929

30+
@property({ type: Boolean })
31+
outline = false;
32+
33+
@property({ type: Boolean })
34+
pill = false;
35+
3036
@property({ type: String, reflect: true })
3137
role: string | null = "status";
3238

@@ -40,16 +46,32 @@ export class Badge extends TailwindElement {
4046
return html`
4147
<span
4248
class=${clsx(
43-
tw`h-4.5 inline-flex items-center justify-center rounded-sm px-2 align-[1px] text-xs`,
44-
{
45-
success: tw`bg-success-500 text-neutral-0`,
46-
warning: tw`bg-warning-600 text-neutral-0`,
47-
danger: tw`bg-danger-500 text-neutral-0`,
48-
neutral: tw`bg-neutral-100 text-neutral-600`,
49-
"high-contrast": tw`bg-neutral-600 text-neutral-0`,
50-
primary: tw`bg-primary text-neutral-0`,
51-
blue: tw`bg-cyan-50 text-cyan-600`,
52-
}[this.variant],
49+
tw`inline-flex h-[1.125rem] items-center justify-center align-[1px] text-xs`,
50+
this.outline
51+
? [
52+
tw`ring-1`,
53+
{
54+
success: tw`bg-success-500 text-success-500 ring-success-500`,
55+
warning: tw`bg-warning-600 text-warning-600 ring-warning-600`,
56+
danger: tw`bg-danger-500 text-danger-500 ring-danger-500`,
57+
neutral: tw`g-neutral-100 text-neutral-600 ring-neutral-600`,
58+
"high-contrast": tw`bg-neutral-600 text-neutral-0 ring-neutral-0`,
59+
primary: tw`bg-white text-primary ring-primary`,
60+
cyan: tw`bg-cyan-50 text-cyan-600 ring-cyan-600`,
61+
blue: tw`bg-blue-50 text-blue-600 ring-blue-600`,
62+
}[this.variant],
63+
]
64+
: {
65+
success: tw`bg-success-500 text-neutral-0`,
66+
warning: tw`bg-warning-600 text-neutral-0`,
67+
danger: tw`bg-danger-500 text-neutral-0`,
68+
neutral: tw`bg-neutral-100 text-neutral-600`,
69+
"high-contrast": tw`bg-neutral-600 text-neutral-0`,
70+
primary: tw`bg-primary text-neutral-0`,
71+
cyan: tw`bg-cyan-50 text-cyan-600`,
72+
blue: tw`bg-blue-50 text-blue-600`,
73+
}[this.variant],
74+
this.pill ? tw`min-w-[1.125rem] rounded-full px-1` : tw`rounded px-2`,
5375
)}
5476
part="base"
5577
>

0 commit comments

Comments
 (0)