Skip to content

Commit 359345f

Browse files
authored
export badge configs (#241)
1 parent e673006 commit 359345f

2 files changed

Lines changed: 46 additions & 18 deletions

File tree

packages/components/src/components/badge/badge.tsx

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,27 @@ import { Icon } from "@/components/icon";
33
import { cn } from "@/utils/cn";
44
import type { IconLibrary, IconType } from "@/utils/icon-utils";
55

6-
type BadgeSize = "xs" | "sm" | "md" | "lg";
7-
type BadgeShape = "rounded" | "pill";
8-
type BadgeVariant = "solid" | "outline";
9-
type BadgeColor =
10-
| "gray"
11-
| "blue"
12-
| "green"
13-
| "orange"
14-
| "yellow"
15-
| "red"
16-
| "purple"
17-
| "white"
18-
| "surface"
19-
| "white-destructive"
20-
| "surface-destructive";
6+
const BADGE_COLORS = [
7+
"gray",
8+
"blue",
9+
"green",
10+
"orange",
11+
"yellow",
12+
"red",
13+
"purple",
14+
"white",
15+
"surface",
16+
"white-destructive",
17+
"surface-destructive",
18+
] as const;
19+
const BADGE_SHAPES = ["rounded", "pill"] as const;
20+
const BADGE_SIZES = ["xs", "sm", "md", "lg"] as const;
21+
const BADGE_VARIANTS = ["solid", "outline"] as const;
22+
23+
type BadgeSize = (typeof BADGE_SIZES)[number];
24+
type BadgeShape = (typeof BADGE_SHAPES)[number];
25+
type BadgeVariant = (typeof BADGE_VARIANTS)[number];
26+
type BadgeColor = (typeof BADGE_COLORS)[number];
2127

2228
const sizeVariants: Record<BadgeSize, string> = {
2329
lg: 'gap-1 py-1 pl-2.5 pr-2.5 [&_svg]:size-3.5 text-sm tracking-[-0.1px] data-[shape="rounded"]:rounded-[8px]',
@@ -170,5 +176,13 @@ const Badge = ({
170176
return <span {...commonProps}>{content}</span>;
171177
};
172178

173-
export { Badge };
179+
export {
180+
Badge,
181+
BADGE_COLORS,
182+
BADGE_SHAPES,
183+
BADGE_SIZES,
184+
BADGE_VARIANTS,
185+
colorVariants,
186+
sizeVariants,
187+
};
174188
export type { BadgeSize, BadgeProps, BadgeShape, BadgeVariant, BadgeColor };
Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,16 @@
1-
export type { BadgeColor, BadgeProps, BadgeShape, BadgeSize } from "./badge";
2-
export { Badge } from "./badge";
1+
export type {
2+
BadgeColor,
3+
BadgeProps,
4+
BadgeShape,
5+
BadgeSize,
6+
BadgeVariant,
7+
} from "./badge";
8+
export {
9+
BADGE_COLORS,
10+
BADGE_SHAPES,
11+
BADGE_SIZES,
12+
BADGE_VARIANTS,
13+
Badge,
14+
colorVariants,
15+
sizeVariants,
16+
} from "./badge";

0 commit comments

Comments
 (0)