Skip to content

Commit 35ee171

Browse files
authored
design(web): next components (#451)
cleans up some nextjs componenets and lays framework for applyign design to migrated components
1 parent 1c2cb90 commit 35ee171

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2243
-1249
lines changed

apps/web/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111
},
1212
"dependencies": {
1313
"@phosphor-icons/react": "^2.1.5",
14+
"@radix-ui/react-avatar": "^1.0.4",
15+
"@radix-ui/react-dropdown-menu": "^2.0.6",
1416
"@radix-ui/react-slot": "^1.0.2",
17+
"@radix-ui/react-tooltip": "^1.0.7",
1518
"@radix-ui/themes": "^3.0.2",
1619
"@simplewebauthn/browser": "^10.0.0",
1720
"@tailwindcss/typography": "^0.5.13",
@@ -32,7 +35,6 @@
3235
"input-otp": "^1.2.4",
3336
"itty-time": "^1.0.6",
3437
"jotai": "^2.8.0",
35-
"lucide-react": "^0.368.0",
3638
"next": "14.2.3",
3739
"next-client-cookies": "^1.1.1",
3840
"next-runtime-env": "^3.2.1",

apps/web/src/app/(login)/_components/passkey-login.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client';
22

33
import { Button } from '@radix-ui/themes';
4-
import { Fingerprint } from 'lucide-react';
4+
import { Fingerprint } from '@phosphor-icons/react';
55
import { api } from '@/src/lib/trpc';
66
import { startAuthentication } from '@simplewebauthn/browser';
77
import { useRouter } from 'next/navigation';

apps/web/src/app/(login)/_components/password-login.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
InputOTP,
55
InputOTPGroup,
66
InputOTPSlot
7-
} from '@/src/components/input-otp';
7+
} from '@/src/components/shadcn-ui/input-otp';
88
import useLoading from '@/src/hooks/use-loading';
99
import { api } from '@/src/lib/trpc';
1010
import { useRouter } from 'next/navigation';
@@ -16,7 +16,7 @@ import {
1616
TextField,
1717
Checkbox
1818
} from '@radix-ui/themes';
19-
import { KeyRound, User } from 'lucide-react';
19+
import { Key, User } from '@phosphor-icons/react';
2020
import { useRef, useState } from 'react';
2121
import { toast } from 'sonner';
2222
import { zodSchemas } from '@u22n/utils';
@@ -80,7 +80,7 @@ export default function PasswordLoginButton() {
8080
size="3"
8181
className="w-72 cursor-pointer font-semibold"
8282
variant="surface">
83-
<KeyRound size={20} />
83+
<Key size={20} />
8484
<Text>Login with my password</Text>
8585
</Button>
8686
</Dialog.Trigger>
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
'use client';
2+
3+
import { Badge } from '@/src/components/shadcn-ui/badge';
4+
import { cn } from '@/src/lib/utils';
5+
import { CaretRight, Dot } from '@phosphor-icons/react';
6+
import { usePathname } from 'next/navigation';
7+
import { useRouter } from 'next/navigation';
8+
import { useEffect, useState } from 'react';
9+
import { Button } from '@/src/components/shadcn-ui/button';
10+
import type { ReactNode } from 'react';
11+
12+
export function SidebarNavButton({
13+
link,
14+
label,
15+
icon,
16+
isActive,
17+
isExpanded,
18+
sidebarCollapsed,
19+
disabled,
20+
badge,
21+
children,
22+
...props
23+
}: {
24+
link: string;
25+
label: string;
26+
icon: ReactNode;
27+
isActive: boolean;
28+
isExpanded?: boolean | undefined;
29+
disabled?: boolean;
30+
badge?: ReactNode;
31+
children?: ReactNode;
32+
sidebarCollapsed: boolean;
33+
}) {
34+
const [expanded, setExpanded] = useState(isExpanded);
35+
const [active, setActive] = useState(false);
36+
const pathname = usePathname();
37+
const router = useRouter();
38+
39+
if (isActive) {
40+
setActive(true);
41+
setExpanded(true);
42+
}
43+
useEffect(() => {
44+
if (
45+
(!children && pathname.startsWith(link)) ??
46+
(children && pathname === link)
47+
) {
48+
setActive(true);
49+
setExpanded(true);
50+
} else {
51+
setActive(false);
52+
}
53+
}, [children, link, pathname]);
54+
return (
55+
<div className={'flex w-full max-w-full flex-col gap-0 p-0'}>
56+
<div
57+
className={cn(
58+
'bg-sand-3 text-sand-12 flex w-full max-w-full flex-row items-center justify-start gap-0 overflow-hidden truncate rounded-md pl-1 text-left',
59+
sidebarCollapsed ? 'aspect-square max-w-16' : '',
60+
active ? 'bg-sand-5' : '',
61+
disabled ? 'opacity-80' : 'hover:bg-sand-4'
62+
)}
63+
{...props}>
64+
{children ? (
65+
<div
66+
className="text-sand-12 h-5 w-5 cursor-pointer rounded-sm p-0.5"
67+
onClick={() => {
68+
setExpanded(!expanded);
69+
}}>
70+
<CaretRight
71+
weight="duotone"
72+
className={cn(
73+
' h-4 w-4 transition-transform',
74+
expanded ? ' rotate-90' : 'rotate-0'
75+
)}
76+
/>
77+
</div>
78+
) : (
79+
<div className="h-5 w-5 rounded-sm p-0.5">
80+
<Dot
81+
weight="duotone"
82+
className={'h-4 w-4'}
83+
/>
84+
</div>
85+
)}
86+
<Button
87+
variant="child"
88+
onClick={() => {
89+
!disabled && router.push(link);
90+
}}
91+
disabled={disabled}
92+
asChild>
93+
<div
94+
className={cn(
95+
'text-sand-12 flex h-full w-full flex-row gap-0 overflow-hidden px-2 py-2',
96+
disabled ? 'cursor-not-allowed' : 'cursor-pointer'
97+
)}>
98+
<div className="mr-2 h-5 w-5 rounded-sm p-0 *:h-5 *:w-5">
99+
{icon}
100+
</div>
101+
<div className="text-sand-12 flex w-full max-w-full flex-row justify-between gap-2 overflow-hidden">
102+
<span
103+
className={cn(
104+
'text-sand-12 truncate text-sm',
105+
sidebarCollapsed ? 'hidden' : 'visible'
106+
)}>
107+
{label}
108+
</span>
109+
{badge && <Badge variant={'secondary'}>{badge}</Badge>}
110+
</div>
111+
</div>
112+
</Button>
113+
</div>
114+
{children && (
115+
<div
116+
className={cn(
117+
'w-full p-0 pl-7 transition-transform',
118+
expanded ? 'max-h-64 delay-0' : 'max-h-0 delay-1000 duration-1000'
119+
)}>
120+
<div
121+
className={cn(
122+
'w-full p-0 transition-opacity duration-100',
123+
expanded ? 'opacity-100 ' : 'opacity-0 '
124+
)}>
125+
{children}
126+
</div>
127+
</div>
128+
)}
129+
</div>
130+
);
131+
}

0 commit comments

Comments
 (0)