Skip to content

Commit

Permalink
feat: add cn tailwind merger and gradient card compo
Browse files Browse the repository at this point in the history
  • Loading branch information
Peqchji committed Oct 21, 2024
1 parent 6f5f2f9 commit e76ab98
Show file tree
Hide file tree
Showing 11 changed files with 262 additions and 25 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module.exports = {
rules: {
// general
'no-alert': 0,
camelcase: 0,
// camelcase: 0,
'no-console': 0,
'no-unused-vars': 1,
'no-nested-ternary': 1,
Expand All @@ -43,7 +43,7 @@ module.exports = {
'prefer-destructuring': [1, { object: true, array: false }],

// typescript
'@typescript-eslint/naming-convention': 1,
'@typescript-eslint/naming-convention': 0,
'@typescript-eslint/no-use-before-define': 1,
'@typescript-eslint/consistent-type-exports': 1,
'@typescript-eslint/consistent-type-imports': 1,
Expand Down
20 changes: 20 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "new-york",
"rsc": true,
"tsx": true,
"tailwind": {
"config": "tailwind.config.ts",
"css": "src/app/globals.css",
"baseColor": "neutral",
"cssVariables": true,
"prefix": ""
},
"aliases": {
"components": "@/components",
"utils": "@/lib/utils",
"ui": "@/components/ui",
"lib": "@/lib",
"hooks": "@/hooks"
}
}
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@
"prepare": "husky"
},
"dependencies": {
"@radix-ui/react-icons": "^1.3.0",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"lucide-react": "^0.453.0",
"next": "14.2.11",
"react": "^18",
"react-dom": "^18"
"react-dom": "^18",
"tailwind-merge": "^2.5.4",
"tailwindcss-animate": "^1.0.7"
},
"devDependencies": {
"@types/node": "^20",
Expand Down
69 changes: 69 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

79 changes: 65 additions & 14 deletions src/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,7 @@
@tailwind components;
@tailwind utilities;

:root {
--background: #ffffff;
--foreground: #171717;
}

@media (prefers-color-scheme: dark) {
:root {
--background: #0a0a0a;
--foreground: #ededed;
}
}

body {
color: var(--foreground);
background: var(--background);
font-family: Arial, Helvetica, sans-serif;
}

Expand All @@ -25,3 +11,68 @@ body {
text-wrap: balance;
}
}

@layer base {
:root {
--background: 0 0% 100%;
--foreground: 0 0% 3.9%;
--card: 0 0% 100%;
--card-foreground: 0 0% 3.9%;
--popover: 0 0% 100%;
--popover-foreground: 0 0% 3.9%;
--primary: 0 0% 9%;
--primary-foreground: 0 0% 98%;
--secondary: 0 0% 96.1%;
--secondary-foreground: 0 0% 9%;
--muted: 0 0% 96.1%;
--muted-foreground: 0 0% 45.1%;
--accent: 0 0% 96.1%;
--accent-foreground: 0 0% 9%;
--destructive: 0 84.2% 60.2%;
--destructive-foreground: 0 0% 98%;
--border: 0 0% 89.8%;
--input: 0 0% 89.8%;
--ring: 0 0% 3.9%;
--chart-1: 12 76% 61%;
--chart-2: 173 58% 39%;
--chart-3: 197 37% 24%;
--chart-4: 43 74% 66%;
--chart-5: 27 87% 67%;
--radius: 0.5rem;
}
.dark {
--background: 0 0% 3.9%;
--foreground: 0 0% 98%;
--card: 0 0% 3.9%;
--card-foreground: 0 0% 98%;
--popover: 0 0% 3.9%;
--popover-foreground: 0 0% 98%;
--primary: 0 0% 98%;
--primary-foreground: 0 0% 9%;
--secondary: 0 0% 14.9%;
--secondary-foreground: 0 0% 98%;
--muted: 0 0% 14.9%;
--muted-foreground: 0 0% 63.9%;
--accent: 0 0% 14.9%;
--accent-foreground: 0 0% 98%;
--destructive: 0 62.8% 30.6%;
--destructive-foreground: 0 0% 98%;
--border: 0 0% 14.9%;
--input: 0 0% 14.9%;
--ring: 0 0% 83.1%;
--chart-1: 220 70% 50%;
--chart-2: 160 60% 45%;
--chart-3: 30 80% 55%;
--chart-4: 280 65% 60%;
--chart-5: 340 75% 55%;
}
}

@layer base {
* {
@apply border-border;
}
body {
@apply bg-background text-foreground;
}
}
6 changes: 6 additions & 0 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { clsx, type ClassValue } from 'clsx';
import { twMerge } from 'tailwind-merge';

export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
34 changes: 34 additions & 0 deletions src/shared/components/gradient-card.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import type { PropsWithChildren } from 'react';
import { cn } from '../utils';

type Variant = 'primary' | 'secondary' | 'translucent';

type Props = {
className?: string;
variant?: Variant;
};

export function GradientCard({
children,
className,
variant = 'primary',
}: PropsWithChildren<Props>) {
const variantClasses = {
primary: 'bg-linear-white before:bg-linear-gray backdrop-blur-[70.5px]',
secondary:
'bg-linear-black-pink before:bg-linear-gray backdrop-blur-[70.5px]',
translucent: 'bg-linear-purple-gray before:bg-linear-gray',
};

return (
<div
className={cn(
"mask-effect relative rounded-xl before:absolute before:inset-0 before:-z-50 before:rounded-xl before:p-[2px] before:content-['']",
variantClasses[variant],
className,
)}
>
{children}
</div>
);
}
Empty file removed src/shared/utils/.gitkeep
Empty file.
6 changes: 6 additions & 0 deletions src/shared/utils/cn.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { clsx, type ClassValue } from 'clsx';
import { twMerge } from 'tailwind-merge';

export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
1 change: 1 addition & 0 deletions src/shared/utils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './cn';
Loading

0 comments on commit e76ab98

Please sign in to comment.