Skip to content

Commit 17142b7

Browse files
author
root
committed
fix: preserve legacy button compatibility classes
1 parent 9a2cedc commit 17142b7

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

packages/web/src/components/ui/button/index.test.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,21 @@ describe("Button", () => {
4242
expect(screen.getByRole("button", { name: "Large" })).toBeInTheDocument();
4343
});
4444

45+
it("preserves legacy compatibility classes for migrated callers", () => {
46+
render(
47+
<Button variant="primary" size="lg" className="auth-submit">
48+
Submit
49+
</Button>
50+
);
51+
52+
expect(screen.getByRole("button", { name: "Submit" })).toHaveClass(
53+
"btn",
54+
"btn-primary",
55+
"btn-lg",
56+
"auth-submit"
57+
);
58+
});
59+
4560
it("disables click handlers while loading", async () => {
4661
const user = userEvent.setup();
4762
const onClick = vi.fn();

packages/web/src/components/ui/button/index.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,19 @@ const sizeClassMap: Record<ButtonSize, string | undefined> = {
4040
lg: styles.lg,
4141
};
4242

43+
const legacyVariantClassMap: Record<ButtonVariant, string> = {
44+
primary: "btn-primary",
45+
secondary: "btn-secondary",
46+
ghost: "btn-ghost",
47+
danger: "btn-danger",
48+
};
49+
50+
const legacySizeClassMap: Record<ButtonSize, string | undefined> = {
51+
sm: "btn-sm",
52+
md: undefined,
53+
lg: "btn-lg",
54+
};
55+
4356
const ButtonContent = ({
4457
children,
4558
leadingIcon,
@@ -82,6 +95,9 @@ export const Button = (props: ButtonProps) => {
8295
styles.btn,
8396
variantClassMap[variant],
8497
sizeClassMap[size],
98+
"btn",
99+
legacyVariantClassMap[variant],
100+
legacySizeClassMap[size],
85101
loading ? styles.loading : undefined,
86102
className
87103
);

0 commit comments

Comments
 (0)