Skip to content

Commit b471f47

Browse files
authored
Merge pull request #40 from GRACENOBLE/35-feat-shadcn-ui
feat(web): install and configure shadcn/ui
2 parents 47c348f + f8b1a2a commit b471f47

25 files changed

Lines changed: 4808 additions & 325 deletions

‎web/__tests__/button.test.tsx‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { render, screen } from '@testing-library/react'
2+
import { Button } from '@/components/ui/button'
3+
4+
it('renders with label', () => {
5+
render(<Button>Save</Button>)
6+
expect(screen.getByRole('button', { name: 'Save' })).toBeInTheDocument()
7+
})
8+
9+
it('renders as disabled when disabled prop is set', () => {
10+
render(<Button disabled>Submit</Button>)
11+
expect(screen.getByRole('button', { name: 'Submit' })).toBeDisabled()
12+
})
13+
14+
it('applies variant via data-variant attribute', () => {
15+
render(<Button variant="destructive">Delete</Button>)
16+
expect(screen.getByRole('button', { name: 'Delete' })).toHaveAttribute(
17+
'data-variant',
18+
'destructive'
19+
)
20+
})

‎web/__tests__/page.test.tsx‎

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,10 @@
1-
import { render, screen } from '@testing-library/react'
1+
import { render } from '@testing-library/react'
22
import { describe, it, expect } from 'vitest'
33
import Home from '../app/page'
44

55
describe('Home page', () => {
6-
it('renders the getting-started heading', () => {
7-
render(<Home />)
8-
expect(screen.getByText(/get started/i)).toBeInTheDocument()
9-
})
10-
11-
it('renders the Deploy Now link', () => {
12-
render(<Home />)
13-
expect(screen.getByText('Deploy Now')).toBeInTheDocument()
14-
})
15-
16-
it('renders the Documentation link', () => {
17-
render(<Home />)
18-
expect(screen.getByText('Documentation')).toBeInTheDocument()
6+
it('renders without crashing', () => {
7+
const { container } = render(<Home />)
8+
expect(container.firstChild).toBeInTheDocument()
199
})
2010
})

‎web/app/globals.css‎

Lines changed: 125 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,137 @@
11
@import "tailwindcss";
2+
@import "tw-animate-css";
3+
@import "shadcn/tailwind.css";
24

3-
:root {
4-
--background: #ffffff;
5-
--foreground: #171717;
6-
}
5+
@custom-variant dark (&:is(.dark *));
76

87
@theme inline {
98
--color-background: var(--background);
109
--color-foreground: var(--foreground);
11-
--font-sans: var(--font-geist-sans);
10+
--font-sans: var(--font-sans);
1211
--font-mono: var(--font-geist-mono);
12+
--font-heading: var(--font-sans);
13+
--color-sidebar-ring: var(--sidebar-ring);
14+
--color-sidebar-border: var(--sidebar-border);
15+
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
16+
--color-sidebar-accent: var(--sidebar-accent);
17+
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
18+
--color-sidebar-primary: var(--sidebar-primary);
19+
--color-sidebar-foreground: var(--sidebar-foreground);
20+
--color-sidebar: var(--sidebar);
21+
--color-chart-5: var(--chart-5);
22+
--color-chart-4: var(--chart-4);
23+
--color-chart-3: var(--chart-3);
24+
--color-chart-2: var(--chart-2);
25+
--color-chart-1: var(--chart-1);
26+
--color-ring: var(--ring);
27+
--color-input: var(--input);
28+
--color-border: var(--border);
29+
--color-destructive: var(--destructive);
30+
--color-accent-foreground: var(--accent-foreground);
31+
--color-accent: var(--accent);
32+
--color-muted-foreground: var(--muted-foreground);
33+
--color-muted: var(--muted);
34+
--color-secondary-foreground: var(--secondary-foreground);
35+
--color-secondary: var(--secondary);
36+
--color-primary-foreground: var(--primary-foreground);
37+
--color-primary: var(--primary);
38+
--color-popover-foreground: var(--popover-foreground);
39+
--color-popover: var(--popover);
40+
--color-card-foreground: var(--card-foreground);
41+
--color-card: var(--card);
42+
--radius-sm: calc(var(--radius) * 0.6);
43+
--radius-md: calc(var(--radius) * 0.8);
44+
--radius-lg: var(--radius);
45+
--radius-xl: calc(var(--radius) * 1.4);
46+
--radius-2xl: calc(var(--radius) * 1.8);
47+
--radius-3xl: calc(var(--radius) * 2.2);
48+
--radius-4xl: calc(var(--radius) * 2.6);
1349
}
1450

15-
@media (prefers-color-scheme: dark) {
16-
:root {
17-
--background: #0a0a0a;
18-
--foreground: #ededed;
19-
}
51+
:root {
52+
--background: oklch(1 0 0);
53+
--foreground: oklch(0.145 0 0);
54+
--card: oklch(1 0 0);
55+
--card-foreground: oklch(0.145 0 0);
56+
--popover: oklch(1 0 0);
57+
--popover-foreground: oklch(0.145 0 0);
58+
--primary: oklch(0.205 0 0);
59+
--primary-foreground: oklch(0.985 0 0);
60+
--secondary: oklch(0.97 0 0);
61+
--secondary-foreground: oklch(0.205 0 0);
62+
--muted: oklch(0.97 0 0);
63+
--muted-foreground: oklch(0.556 0 0);
64+
--accent: oklch(0.97 0 0);
65+
--accent-foreground: oklch(0.205 0 0);
66+
--destructive: oklch(0.577 0.245 27.325);
67+
--border: oklch(0.922 0 0);
68+
--input: oklch(0.922 0 0);
69+
--ring: oklch(0.708 0 0);
70+
--chart-1: oklch(0.87 0 0);
71+
--chart-2: oklch(0.556 0 0);
72+
--chart-3: oklch(0.439 0 0);
73+
--chart-4: oklch(0.371 0 0);
74+
--chart-5: oklch(0.269 0 0);
75+
--radius: 0.625rem;
76+
--sidebar: oklch(0.985 0 0);
77+
--sidebar-foreground: oklch(0.145 0 0);
78+
--sidebar-primary: oklch(0.205 0 0);
79+
--sidebar-primary-foreground: oklch(0.985 0 0);
80+
--sidebar-accent: oklch(0.97 0 0);
81+
--sidebar-accent-foreground: oklch(0.205 0 0);
82+
--sidebar-border: oklch(0.922 0 0);
83+
--sidebar-ring: oklch(0.708 0 0);
84+
}
85+
86+
.dark {
87+
--background: oklch(0.145 0 0);
88+
--foreground: oklch(0.985 0 0);
89+
--card: oklch(0.205 0 0);
90+
--card-foreground: oklch(0.985 0 0);
91+
--popover: oklch(0.205 0 0);
92+
--popover-foreground: oklch(0.985 0 0);
93+
--primary: oklch(0.922 0 0);
94+
--primary-foreground: oklch(0.205 0 0);
95+
--secondary: oklch(0.269 0 0);
96+
--secondary-foreground: oklch(0.985 0 0);
97+
--muted: oklch(0.269 0 0);
98+
--muted-foreground: oklch(0.708 0 0);
99+
--accent: oklch(0.269 0 0);
100+
--accent-foreground: oklch(0.985 0 0);
101+
--destructive: oklch(0.704 0.191 22.216);
102+
--border: oklch(1 0 0 / 10%);
103+
--input: oklch(1 0 0 / 15%);
104+
--ring: oklch(0.556 0 0);
105+
--chart-1: oklch(0.87 0 0);
106+
--chart-2: oklch(0.556 0 0);
107+
--chart-3: oklch(0.439 0 0);
108+
--chart-4: oklch(0.371 0 0);
109+
--chart-5: oklch(0.269 0 0);
110+
--sidebar: oklch(0.205 0 0);
111+
--sidebar-foreground: oklch(0.985 0 0);
112+
--sidebar-primary: oklch(0.488 0.243 264.376);
113+
--sidebar-primary-foreground: oklch(0.985 0 0);
114+
--sidebar-accent: oklch(0.269 0 0);
115+
--sidebar-accent-foreground: oklch(0.985 0 0);
116+
--sidebar-border: oklch(1 0 0 / 10%);
117+
--sidebar-ring: oklch(0.556 0 0);
20118
}
21119

22-
body {
23-
background: var(--background);
24-
color: var(--foreground);
25-
font-family: Arial, Helvetica, sans-serif;
120+
.toaster {
121+
--normal-bg: var(--popover);
122+
--normal-text: var(--popover-foreground);
123+
--normal-border: var(--border);
124+
--border-radius: var(--radius);
26125
}
126+
127+
@layer base {
128+
* {
129+
@apply border-border outline-ring/50;
130+
}
131+
body {
132+
@apply bg-background text-foreground;
133+
}
134+
html {
135+
@apply font-sans;
136+
}
137+
}

‎web/app/page.tsx‎

Lines changed: 5 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,7 @@
1-
import Image from "next/image";
2-
3-
export default function Home() {
1+
const page = () => {
42
return (
5-
<div className="flex flex-col flex-1 items-center justify-center bg-zinc-50 font-sans dark:bg-black">
6-
<main className="flex flex-1 w-full max-w-3xl flex-col items-center justify-between py-32 px-16 bg-white dark:bg-black sm:items-start">
7-
<Image
8-
className="dark:invert"
9-
src="/next.svg"
10-
alt="Next.js logo"
11-
width={100}
12-
height={20}
13-
priority
14-
/>
15-
<div className="flex flex-col items-center gap-6 text-center sm:items-start sm:text-left">
16-
<h1 className="max-w-xs text-3xl font-semibold leading-10 tracking-tight text-black dark:text-zinc-50">
17-
To get started, edit the page.tsx file.
18-
</h1>
19-
<p className="max-w-md text-lg leading-8 text-zinc-600 dark:text-zinc-400">
20-
Looking for a starting point or more instructions? Head over to{" "}
21-
<a
22-
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
23-
className="font-medium text-zinc-950 dark:text-zinc-50"
24-
>
25-
Templates
26-
</a>{" "}
27-
or the{" "}
28-
<a
29-
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
30-
className="font-medium text-zinc-950 dark:text-zinc-50"
31-
>
32-
Learning
33-
</a>{" "}
34-
center.
35-
</p>
36-
</div>
37-
<div className="flex flex-col gap-4 text-base font-medium sm:flex-row">
38-
<a
39-
className="flex h-12 w-full items-center justify-center gap-2 rounded-full bg-foreground px-5 text-background transition-colors hover:bg-[#383838] dark:hover:bg-[#ccc] md:w-39.5"
40-
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
41-
target="_blank"
42-
rel="noopener noreferrer"
43-
>
44-
<Image
45-
className="dark:invert"
46-
src="/vercel.svg"
47-
alt="Vercel logomark"
48-
width={16}
49-
height={16}
50-
/>
51-
Deploy Now
52-
</a>
53-
<a
54-
className="flex h-12 w-full items-center justify-center rounded-full border border-solid border-black/[.08] px-5 transition-colors hover:border-transparent hover:bg-black/[.04] dark:border-white/[.145] dark:hover:bg-[#1a1a1a] md:w-[158px]"
55-
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
56-
target="_blank"
57-
rel="noopener noreferrer"
58-
>
59-
Documentation
60-
</a>
61-
</div>
62-
</main>
63-
</div>
3+
<div></div>
644
);
65-
}
5+
};
6+
7+
export default page;

‎web/components.json‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"$schema": "https://ui.shadcn.com/schema.json",
3+
"style": "radix-nova",
4+
"rsc": true,
5+
"tsx": true,
6+
"tailwind": {
7+
"config": "",
8+
"css": "app/globals.css",
9+
"baseColor": "neutral",
10+
"cssVariables": true,
11+
"prefix": ""
12+
},
13+
"iconLibrary": "lucide",
14+
"rtl": false,
15+
"aliases": {
16+
"components": "@/components",
17+
"utils": "@/lib/utils",
18+
"ui": "@/components/ui",
19+
"lib": "@/lib",
20+
"hooks": "@/hooks"
21+
},
22+
"menuColor": "default",
23+
"menuAccent": "subtle",
24+
"registries": {}
25+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { cn } from "@/lib/utils";
2+
3+
const Container = ({ children, className }: { children: React.ReactNode; className?: string }) => {
4+
return <div className={cn("mx-auto max-w-7xl", className)}>{children}</div>;
5+
};
6+
7+
export default Container;

‎web/components/common/h1.tsx‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { cn } from "@/lib/utils";
2+
3+
const H1 = ({
4+
children,
5+
className,
6+
}: {
7+
children: React.ReactNode;
8+
className: string;
9+
}) => {
10+
return <h1 className={cn(className)}>{children}</h1>;
11+
};
12+
13+
export default H1;

‎web/components/common/h2.tsx‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { cn } from "@/lib/utils";
2+
3+
const H2 = ({
4+
children,
5+
className,
6+
}: {
7+
children: React.ReactNode;
8+
className?: string;
9+
}) => {
10+
return <h2 className={cn(className)}>{children}</h2>;
11+
};
12+
13+
export default H2;

‎web/components/common/h3.tsx‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { cn } from "@/lib/utils";
2+
3+
const H3 = ({
4+
children,
5+
className,
6+
}: {
7+
children: React.ReactNode;
8+
className: string;
9+
}) => {
10+
return <h3 className={cn(className)}>{children}</h3>;
11+
};
12+
13+
export default H3;

‎web/components/common/loader.tsx‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { cn } from "@/lib/utils";
2+
3+
const Loader = ({ className }: { className: string }) => {
4+
return <div className={cn("",className)}></div>;
5+
};
6+
7+
export default Loader;

0 commit comments

Comments
 (0)