@@ -13,17 +13,15 @@ export type BadgeVariant =
1313 | "primary"
1414 | "cyan"
1515 | "blue"
16+ | "violet"
17+ | "orange"
1618 | "high-contrast"
1719 | "text"
1820 | "text-neutral" ;
1921
2022/**
21- * Show numeric value in a label
22- *
23- * Usage example:
24- * ```ts
25- * <btrix-badge aria-describedby="text">10</btrix-badge>
26- * ```
23+ * Badges are compact, non-interactive displays of contextual information.
24+ * They are an unobtrusive way of drawing attention to dynamic data like statuses or counts.
2725 */
2826@customElement ( "btrix-badge" )
2927export class Badge extends TailwindElement {
@@ -42,6 +40,12 @@ export class Badge extends TailwindElement {
4240 @property ( { type : String , reflect : true } )
4341 role : string | null = "status" ;
4442
43+ /**
44+ * Style as normal text and not data
45+ */
46+ @property ( { type : Boolean } )
47+ asLabel = false ;
48+
4549 static styles = css `
4650 :host {
4751 display: inline-flex;
@@ -52,21 +56,28 @@ export class Badge extends TailwindElement {
5256 return html `
5357 < span
5458 class =${ clsx (
55- tw `inline-flex min-h-4 items-center justify-center align-[1px] leading-none` ,
56- this . size === "medium" && tw `text-xs` ,
59+ tw `inline-flex min-h-4 items-center justify-center whitespace-nowrap leading-none` ,
60+ this . asLabel
61+ ? [ this . size === "medium" && tw `text-xs` ]
62+ : [
63+ tw `font-mono [font-variation-settings:var(--font-monostyle-variation)]` ,
64+ this . size === "medium" && tw `text-xs` ,
65+ ] ,
5766 this . outline
5867 ? [
5968 tw `mx-px ring-1` ,
6069 {
6170 success : tw `bg-success-50 text-success-700 ring-success-400` ,
62- warning : tw `bg-warning-600 text-warning-600 ring-warning-600` ,
63- danger : tw `bg-danger-500 text-danger-500 ring-danger-500` ,
71+ warning : tw `bg-warning-50 text-warning-600 ring-warning-600` ,
72+ danger : tw `bg-danger-50 text-danger-500 ring-danger-500` ,
6473 neutral : tw `bg-neutral-100 text-neutral-600 ring-neutral-300` ,
65- "high-contrast" : tw `bg-neutral-600 text-neutral-0 ring-neutral-0 ` ,
74+ "high-contrast" : tw `bg-neutral-0 text-neutral-700 ring-neutral-600 ` ,
6675 primary : tw `bg-white text-primary ring-primary` ,
6776 cyan : tw `bg-cyan-50 text-cyan-600 ring-cyan-600` ,
6877 blue : tw `bg-blue-50 text-blue-600 ring-blue-600` ,
6978 text : tw `text-blue-500 ring-blue-600` ,
79+ violet : tw `bg-violet-50 text-violet-600 ring-violet-600` ,
80+ orange : tw `bg-orange-50 text-orange-600 ring-orange-600` ,
7081 "text-neutral" : tw `text-neutral-500 ring-neutral-600` ,
7182 } [ this . variant ] ,
7283 ]
@@ -79,13 +90,15 @@ export class Badge extends TailwindElement {
7990 primary : tw `bg-primary text-neutral-0` ,
8091 cyan : tw `bg-cyan-50 text-cyan-600` ,
8192 blue : tw `bg-blue-50 text-blue-600` ,
93+ violet : tw `bg-violet-50 text-violet-600` ,
94+ orange : tw `bg-orange-50 text-orange-600` ,
8295 text : tw `text-blue-500` ,
8396 "text-neutral" : tw `text-neutral-500` ,
8497 } [ this . variant ] ,
8598 this . pill
8699 ? [
87- tw `min-w-[1.125rem] rounded-full` ,
88- this . size === "large" ? tw `px-1.5 py-0.5` : tw `px-1 `,
100+ tw `min-w-[1.125rem] rounded-full px-2 `,
101+ this . size === "large" && tw `py-0.5` ,
89102 ]
90103 : [ tw `rounded` , this . size === "large" ? tw `px-2.5 py-1` : tw `px-2 ` ] ,
91104 ) }
0 commit comments