Skip to content

Commit f1bcf08

Browse files
committed
feat: enhance device authentication page layout and improve user feedback messages
1 parent 51a71a1 commit f1bcf08

1 file changed

Lines changed: 40 additions & 26 deletions

File tree

apps/studio/src/routes/auth.device.tsx

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { Input } from '@/components/ui/input';
99
import { Label } from '@/components/ui/label';
1010
import { toast } from '@/hooks/use-toast';
1111
import { useSession } from '@/hooks/useSession';
12-
import { CheckCircle2, Monitor, AlertCircle } from 'lucide-react';
12+
import { CheckCircle2, GalleryVerticalEnd } from 'lucide-react';
1313

1414
export const Route = createFileRoute('/auth/device')({
1515
validateSearch: (search: Record<string, unknown>) => ({
@@ -18,6 +18,22 @@ export const Route = createFileRoute('/auth/device')({
1818
component: DeviceAuthPage,
1919
});
2020

21+
function PageShell({ children }: { children: React.ReactNode }) {
22+
return (
23+
<div className="flex min-h-svh w-full flex-col items-center justify-center gap-6 bg-muted p-6 md:p-10">
24+
<div className="flex w-full max-w-sm flex-col gap-6">
25+
<a href="#" className="flex items-center gap-2 self-center font-medium">
26+
<div className="flex size-6 items-center justify-center rounded-md bg-primary text-primary-foreground">
27+
<GalleryVerticalEnd className="size-4" />
28+
</div>
29+
ObjectStack
30+
</a>
31+
<div className="flex flex-col gap-6">{children}</div>
32+
</div>
33+
</div>
34+
);
35+
}
36+
2137
function DeviceAuthPage() {
2238
const { code } = Route.useSearch();
2339
const { user, refresh } = useSession();
@@ -32,31 +48,28 @@ function DeviceAuthPage() {
3248

3349
if (!code) {
3450
return (
35-
<div className="min-h-screen flex items-center justify-center bg-background">
36-
<Card className="w-full max-w-md">
51+
<PageShell>
52+
<Card>
3753
<CardHeader className="text-center">
38-
<AlertCircle className="h-12 w-12 text-destructive mx-auto mb-2" />
3954
<CardTitle>Invalid Request</CardTitle>
40-
<CardDescription>No device code provided.</CardDescription>
55+
<CardDescription>No device code provided. Please re-run the CLI command.</CardDescription>
4156
</CardHeader>
4257
</Card>
43-
</div>
58+
</PageShell>
4459
);
4560
}
4661

4762
if (approved) {
4863
return (
49-
<div className="min-h-screen flex items-center justify-center bg-background">
50-
<Card className="w-full max-w-md">
64+
<PageShell>
65+
<Card>
5166
<CardHeader className="text-center">
52-
<CheckCircle2 className="h-12 w-12 text-green-500 mx-auto mb-2" />
53-
<CardTitle>Login Approved</CardTitle>
54-
<CardDescription>
55-
You can close this tab. The CLI has been authenticated successfully.
56-
</CardDescription>
67+
<CheckCircle2 className="h-10 w-10 text-green-500 mx-auto mb-2" />
68+
<CardTitle>CLI Authorized</CardTitle>
69+
<CardDescription>You can close this tab.</CardDescription>
5770
</CardHeader>
5871
</Card>
59-
</div>
72+
</PageShell>
6073
);
6174
}
6275

@@ -103,10 +116,9 @@ function DeviceAuthPage() {
103116
};
104117

105118
return (
106-
<div className="min-h-screen flex items-center justify-center bg-background p-4">
107-
<Card className="w-full max-w-md">
119+
<PageShell>
120+
<Card>
108121
<CardHeader className="text-center">
109-
<Monitor className="h-10 w-10 text-primary mx-auto mb-2" />
110122
<CardTitle>CLI Login Request</CardTitle>
111123
<CardDescription>
112124
{user
@@ -115,7 +127,7 @@ function DeviceAuthPage() {
115127
</CardDescription>
116128
</CardHeader>
117129
<CardContent className="space-y-4">
118-
<div className="bg-muted rounded-md px-4 py-2 text-center">
130+
<div className="rounded-md border bg-background px-4 py-3 text-center">
119131
<p className="text-xs text-muted-foreground mb-1">Device Code</p>
120132
<p className="font-mono font-semibold tracking-widest text-lg">{code}</p>
121133
</div>
@@ -158,17 +170,19 @@ function DeviceAuthPage() {
158170
<Button onClick={handleApprove} className="w-full" disabled={submitting}>
159171
{submitting ? 'Approving…' : 'Approve CLI Access'}
160172
</Button>
161-
<Button
162-
variant="outline"
163-
className="w-full"
164-
onClick={() => navigate({ to: '/' })}
165-
>
166-
Cancel
167-
</Button>
173+
<div className="text-center">
174+
<button
175+
type="button"
176+
className="text-sm text-muted-foreground underline-offset-4 hover:underline"
177+
onClick={() => navigate({ to: '/' })}
178+
>
179+
Cancel
180+
</button>
181+
</div>
168182
</div>
169183
)}
170184
</CardContent>
171185
</Card>
172-
</div>
186+
</PageShell>
173187
);
174188
}

0 commit comments

Comments
 (0)