Skip to content

Commit 1149eb5

Browse files
committed
refactor: improve code quality, add Card component and Prettier config
1 parent e782e4a commit 1149eb5

11 files changed

Lines changed: 696 additions & 467 deletions

File tree

.prettierrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"semi": true,
3+
"singleQuote": false,
4+
"tabWidth": 2,
5+
"trailingComma": "es5",
6+
"plugins": [
7+
"prettier-plugin-tailwindcss"
8+
]
9+
}

app/components/Button.tsx

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,42 @@ import { ButtonHTMLAttributes, ReactNode } from "react";
22
import { SequenceType } from "../types/sequence";
33

44
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
5-
children: ReactNode;
6-
variant?: "primary" | "secondary" | SequenceType;
7-
fullWidth?: boolean;
5+
children: ReactNode;
6+
variant?: "primary" | "secondary" | SequenceType;
7+
fullWidth?: boolean;
88
}
99

1010
export default function Button({
11-
children,
12-
variant = "primary",
13-
fullWidth = false,
14-
className = "",
15-
...props
11+
children,
12+
variant = "primary",
13+
fullWidth = false,
14+
className = "",
15+
...props
1616
}: ButtonProps) {
17-
const baseStyles =
18-
"px-6 py-3 rounded-lg font-medium transition-all duration-300 transform hover:scale-105 active:scale-95 shadow-lg";
17+
const baseStyles =
18+
"px-6 py-3 rounded-lg font-medium transition-all duration-300 transform hover:scale-[1.02] active:scale-[0.98] shadow-lg disabled:opacity-50 disabled:cursor-not-allowed focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-background";
1919

20-
const variantStyles: Record<string, string> = {
21-
primary:
22-
"bg-gradient-to-r from-orange-400 to-orange-600 hover:from-orange-500 hover:to-orange-700 text-white",
23-
secondary:
24-
"bg-gradient-to-r from-gray-500 to-gray-700 hover:from-gray-600 hover:to-gray-800 text-white",
25-
arithmetic:
26-
"bg-gradient-to-r from-blue-400 to-blue-600 hover:from-blue-500 hover:to-blue-700 text-white",
27-
geometric:
28-
"bg-gradient-to-r from-purple-400 to-purple-600 hover:from-purple-500 hover:to-purple-700 text-white",
29-
alphabet:
30-
"bg-gradient-to-r from-green-400 to-green-600 hover:from-green-500 hover:to-green-700 text-white",
31-
};
20+
const variantStyles: Record<string, string> = {
21+
primary:
22+
"bg-primary text-primary-foreground hover:brightness-110 focus:ring-primary",
23+
secondary:
24+
"bg-secondary text-secondary-foreground hover:bg-secondary/80 focus:ring-secondary",
25+
arithmetic:
26+
"bg-seq-arithmetic text-white hover:brightness-110 focus:ring-seq-arithmetic",
27+
geometric:
28+
"bg-seq-geometric text-white hover:brightness-110 focus:ring-seq-geometric",
29+
alphabet:
30+
"bg-seq-alphabet text-white hover:brightness-110 focus:ring-seq-alphabet",
31+
};
3232

33-
const widthStyles = fullWidth ? "w-full" : "w-auto";
33+
const widthStyles = fullWidth ? "w-full" : "w-auto";
3434

35-
return (
36-
<button
37-
className={`${baseStyles} ${variantStyles[variant]} ${widthStyles} ${className}`}
38-
{...props}
39-
>
40-
{children}
41-
</button>
42-
);
35+
return (
36+
<button
37+
className={`${baseStyles} ${variantStyles[variant]} ${widthStyles} ${className}`}
38+
{...props}
39+
>
40+
{children}
41+
</button>
42+
);
4343
}

app/components/Card.tsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { HTMLAttributes, ReactNode } from "react";
2+
3+
interface CardProps extends HTMLAttributes<HTMLDivElement> {
4+
children: ReactNode;
5+
variant?: "default" | "glass";
6+
}
7+
8+
export default function Card({
9+
children,
10+
className = "",
11+
variant = "glass",
12+
...props
13+
}: CardProps) {
14+
const baseStyles = "rounded-xl p-6 transition-all duration-300";
15+
16+
const variants = {
17+
default: "bg-secondary text-secondary-foreground shadow-lg",
18+
glass: "glass text-card-foreground",
19+
};
20+
21+
return (
22+
<div
23+
className={`${baseStyles} ${variants[variant]} ${className}`}
24+
{...props}
25+
>
26+
{children}
27+
</div>
28+
);
29+
}

0 commit comments

Comments
 (0)