Skip to content

Commit 83a4020

Browse files
author
y-crew server
committed
[web] add auth and login page
1 parent ebc5101 commit 83a4020

File tree

16 files changed

+659
-110
lines changed

16 files changed

+659
-110
lines changed

web/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<title>Vite + React + TS</title>
88
</head>
99
<body>
10-
<div id="root"></div>
10+
<div id="app"></div>
1111
<script type="module" src="/src/main.tsx"></script>
1212
</body>
1313
</html>

web/package-lock.json

Lines changed: 114 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,21 @@
1010
"preview": "vite preview"
1111
},
1212
"dependencies": {
13+
"@hookform/resolvers": "^3.4.0",
1314
"@radix-ui/react-icons": "^1.3.0",
15+
"@radix-ui/react-label": "^2.0.2",
16+
"@radix-ui/react-slot": "^1.0.2",
1417
"@tanstack/react-router": "^1.33.4",
1518
"axios": "^1.6.8",
1619
"class-variance-authority": "^0.7.0",
1720
"clsx": "^2.1.1",
1821
"mqtt": "^5.6.1",
1922
"react": "^18.2.0",
2023
"react-dom": "^18.2.0",
24+
"react-hook-form": "^7.51.4",
2125
"tailwind-merge": "^2.3.0",
22-
"tailwindcss-animate": "^1.0.7"
26+
"tailwindcss-animate": "^1.0.7",
27+
"zod": "^3.23.8"
2328
},
2429
"devDependencies": {
2530
"@tanstack/router-devtools": "^1.33.4",

web/src/auth.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,11 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
2828
const isAuthenticated = !!user
2929

3030
const logout = React.useCallback(async () => {
31-
32-
3331
setStoredUser(null)
3432
setUser(null)
3533
}, [])
3634

3735
const login = React.useCallback(async (username: string) => {
38-
3936
setStoredUser(username)
4037
setUser(username)
4138
}, [])

web/src/components/ui/button.tsx

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

0 commit comments

Comments
 (0)