Skip to content

Commit 6c69712

Browse files
committed
moved button styling to new system
1 parent cd2b8c2 commit 6c69712

File tree

3 files changed

+36
-106
lines changed

3 files changed

+36
-106
lines changed

app/(sink)/demo/components/page.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
import { Badge } from '@/packages/ui'
1+
import { Badge, Button } from '@/packages/ui'
22
import React from 'react'
33

44
export default function page() {
55
return (
66
<div className='container max-w-6xl mx-auto'>
7+
<div className="space-x-4">
8+
<Button>Default Button</Button>
9+
<Button variant="outline">Outline Button</Button>
10+
<Button variant="link">Link Button</Button>
11+
</div>
712
<div className="space-x-4">
813
<Badge>Badge</Badge>
914
<Badge variant="success">Badge</Badge>

app/demo.tsx

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

packages/ui/Buttons/Button.tsx

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,43 @@
1+
import { cn } from "@/lib/utils";
2+
import { cva, VariantProps } from "class-variance-authority";
13
import React, { ButtonHTMLAttributes } from "react";
24

3-
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
4-
size?: "sm" | "md" | "lg";
5-
className?: string;
6-
variant?: "primary" | "outline" | "link";
7-
}
5+
const buttonVariants = cva(
6+
"font-head border-2 border-black shadow-md hover:shadow-xs transition-all",
7+
{
8+
variants: {
9+
variant: {
10+
default:
11+
"bg-primary-400 text-black border-2 border-black hover:bg-primary-500",
12+
outline: "bg-transparent text-black border-2 border-black",
13+
link: "bg-transparent text-primary-400 hover:underline",
14+
},
15+
size: {
16+
sm: "px-4 py-1 text-sm",
17+
md: "px-6 py-2 text-base",
18+
lg: "px-8 py-3 text-lg",
19+
},
20+
},
21+
defaultVariants: {
22+
size: "md",
23+
variant: "default",
24+
},
25+
}
26+
);
27+
28+
interface ButtonProps
29+
extends ButtonHTMLAttributes<HTMLButtonElement>,
30+
VariantProps<typeof buttonVariants> {}
831

932
export function Button({
1033
children,
1134
size = "md",
1235
className = "",
13-
variant = "primary",
36+
variant = "default",
1437
...props
1538
}: ButtonProps) {
16-
const sizeClasses = {
17-
sm: "px-4 py-1 text-sm",
18-
md: "px-6 py-2 text-base",
19-
lg: "px-8 py-3 text-lg",
20-
};
21-
22-
const variantClasses = {
23-
primary:
24-
"bg-primary-400 text-black border-2 border-black hover:bg-primary-500",
25-
outline: "bg-transparent text-black border-2 border-black",
26-
link: "bg-transparent text-primary-400 hover:underline",
27-
};
28-
2939
return (
30-
<button
31-
className={`font-head border-2 border-black shadow-md hover:shadow-xs transition-all ${sizeClasses[size]} ${variantClasses[variant]} ${className}`}
32-
{...props}
33-
>
40+
<button className={cn(buttonVariants({ variant, size }), className)} {...props}>
3441
{children}
3542
</button>
3643
);

0 commit comments

Comments
 (0)