Skip to content

Commit 8668a5b

Browse files
authored
Installing ShadCN and configuring it to match current website state (#1668)
* manualy installing shadcn * adding button.tsx and chackbox.tsx for future use * adjust formatting
1 parent 08ae26f commit 8668a5b

File tree

7 files changed

+364
-1
lines changed

7 files changed

+364
-1
lines changed

components.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"$schema": "https://ui.shadcn.com/schema.json",
3+
"style": "new-york",
4+
"rsc": false,
5+
"tsx": true,
6+
"tailwind": {
7+
"config": "",
8+
"css": "src/styles/globals.css",
9+
"baseColor": "neutral",
10+
"cssVariables": true,
11+
"prefix": ""
12+
},
13+
"aliases": {
14+
"components": "@/components",
15+
"utils": "@/lib/utils",
16+
"ui": "@/components/ui",
17+
"lib": "@/lib",
18+
"hooks": "@/hooks"
19+
},
20+
"iconLibrary": "lucide"
21+
}

components/ui/button.tsx

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/* eslint-disable linebreak-style */
2+
/* eslint-disable quotes */
3+
import * as React from 'react';
4+
import { Slot } from '@radix-ui/react-slot';
5+
import { cva, type VariantProps } from 'class-variance-authority';
6+
7+
import { cn } from '@/lib/utils';
8+
9+
const buttonVariants = cva(
10+
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
11+
{
12+
variants: {
13+
variant: {
14+
default:
15+
'bg-primary text-primary-foreground shadow-xs hover:bg-primary/90',
16+
destructive:
17+
'bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60',
18+
outline:
19+
'border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50',
20+
secondary:
21+
'bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80',
22+
ghost:
23+
'hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50',
24+
link: 'text-primary underline-offset-4 hover:underline',
25+
},
26+
size: {
27+
default: 'h-9 px-4 py-2 has-[>svg]:px-3',
28+
sm: 'h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5',
29+
lg: 'h-10 rounded-md px-6 has-[>svg]:px-4',
30+
icon: 'size-9',
31+
},
32+
},
33+
defaultVariants: {
34+
variant: 'default',
35+
size: 'default',
36+
},
37+
},
38+
);
39+
40+
function Button({
41+
className,
42+
variant,
43+
size,
44+
asChild = false,
45+
...props
46+
}: React.ComponentProps<'button'> &
47+
VariantProps<typeof buttonVariants> & {
48+
asChild?: boolean;
49+
}) {
50+
const Comp = asChild ? Slot : 'button';
51+
52+
return (
53+
<Comp
54+
data-slot='button'
55+
className={cn(buttonVariants({ variant, size, className }))}
56+
{...props}
57+
/>
58+
);
59+
}
60+
61+
export { Button, buttonVariants };

components/ui/checkbox.tsx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/* eslint-disable linebreak-style */
2+
import * as React from 'react';
3+
4+
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
5+
6+
import { CheckIcon } from 'lucide-react';
7+
8+
import { cn } from '@/lib/utils';
9+
10+
function Checkbox({
11+
// eslint-disable-next-line react/prop-types
12+
className,
13+
14+
...props
15+
}: React.ComponentProps<typeof CheckboxPrimitive.Root>) {
16+
return (
17+
<CheckboxPrimitive.Root
18+
data-slot='checkbox'
19+
className={cn(
20+
'peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50',
21+
22+
className,
23+
)}
24+
{...props}
25+
>
26+
<CheckboxPrimitive.Indicator
27+
data-slot='checkbox-indicator'
28+
className='flex items-center justify-center text-current transition-none'
29+
>
30+
<CheckIcon className='size-3.5' />
31+
</CheckboxPrimitive.Indicator>
32+
</CheckboxPrimitive.Root>
33+
);
34+
}
35+
36+
export { Checkbox };

lib/utils.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { clsx, type ClassValue } from 'clsx';
2+
import { twMerge } from 'tailwind-merge';
3+
4+
export function cn(...inputs: ClassValue[]) {
5+
return twMerge(clsx(inputs));
6+
}

package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,22 @@
2727
},
2828
"dependencies": {
2929
"@docsearch/react": "3.8.0",
30+
"@radix-ui/react-checkbox": "^1.3.1",
31+
"@radix-ui/react-slot": "^1.2.2",
3032
"@types/jsonpath": "^0.2.4",
3133
"axios": "1.7.7",
3234
"babel-loader": "^9.2.1",
35+
"class-variance-authority": "^0.7.1",
3336
"classnames": "^2.5.1",
37+
"clsx": "^2.1.1",
3438
"feed": "^4.2.2",
3539
"file-saver": "^2.0.5",
3640
"fuse.js": "^7.0.0",
3741
"gray-matter": "^4.0.3",
3842
"js-yaml": "^4.1.0",
3943
"jsonpath": "^1.1.1",
4044
"jszip": "^3.10.1",
45+
"lucide-react": "^0.510.0",
4146
"markdown-to-jsx": "^7.7.3",
4247
"moment": "2.30.1",
4348
"next": "14.2.14",
@@ -52,6 +57,8 @@
5257
"slate": "^0.112.0",
5358
"slate-react": "^0.108.0",
5459
"slugify": "^1.6.5",
60+
"tailwind-merge": "^3.3.0",
61+
"tw-animate-css": "^1.2.9",
5562
"yarn": "1.22.22",
5663
"zero-fill": "^2.2.4",
5764
"zustand": "^5.0.0"

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"paths": {
1919
"react": ["./node_modules/@types/react"],
2020
"~/*": ["./*"],
21-
"@public/*": ["./public/*"]
21+
"@public/*": ["./public/*"],
22+
"@/*": ["./*"]
2223
}
2324
},
2425
"include": ["next-env.d.ts", "svgr.d.ts", "**/*.ts", "**/*.tsx"],

0 commit comments

Comments
 (0)