Skip to content

Commit f593d41

Browse files
committed
prettier
1 parent 8e1e8d5 commit f593d41

9 files changed

Lines changed: 232 additions & 236 deletions

File tree

playground/connect-next/app/(auth-required)/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
import { ProtectedRoute } from '@/components/ProtectedRoute';
44

55
export default function AuthenticatedLayout({ children }: { children: React.ReactNode }) {
6-
return <ProtectedRoute>{children}</ProtectedRoute>;
6+
return <ProtectedRoute>{children}</ProtectedRoute>;
77
}

playground/connect-next/app/globals.css

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ html {
1212
font-size: 14px;
1313
}
1414

15-
16-
1715
@layer base {
1816
:root {
1917
--background: 0 0% 100%;
@@ -70,8 +68,6 @@ html {
7068
}
7169
}
7270

73-
74-
7571
@layer base {
7672
* {
7773
@apply border-border;
Lines changed: 64 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,72 @@
1-
import {FormEvent, useState} from "react";
1+
import { FormEvent, useState } from 'react';
22

33
type Props = {
4-
initialUserProvidedIdentifier: string;
5-
initialError?: string;
6-
onClick: (username: string, password: string) => Promise<string|undefined>;
7-
}
4+
initialUserProvidedIdentifier: string;
5+
initialError?: string;
6+
onClick: (username: string, password: string) => Promise<string | undefined>;
7+
};
88

9-
export const PasswordForm = ({onClick, initialUserProvidedIdentifier}: Props) => {
10-
const [username, setUsername] = useState(initialUserProvidedIdentifier);
11-
const [password, setPassword] = useState('');
12-
const [message, setMessage] = useState('');
9+
export const PasswordForm = ({ onClick, initialUserProvidedIdentifier }: Props) => {
10+
const [username, setUsername] = useState(initialUserProvidedIdentifier);
11+
const [password, setPassword] = useState('');
12+
const [message, setMessage] = useState('');
1313

14-
const handleLogin = async (e: FormEvent<HTMLButtonElement>) => {
15-
e.preventDefault();
16-
setMessage('Loading...');
17-
const maybeError = await onClick(username, password);
18-
if (maybeError) {
19-
setMessage(maybeError);
20-
}
14+
const handleLogin = async (e: FormEvent<HTMLButtonElement>) => {
15+
e.preventDefault();
16+
setMessage('Loading...');
17+
const maybeError = await onClick(username, password);
18+
if (maybeError) {
19+
setMessage(maybeError);
2120
}
21+
};
2222

23-
return (
24-
<form
25-
className="flex flex-col space-y-4"
23+
return (
24+
<form className='flex flex-col space-y-4'>
25+
<div>
26+
<label
27+
htmlFor='email'
28+
className='block text-xs text-gray-600 uppercase'
2629
>
27-
<div>
28-
<label
29-
htmlFor="email"
30-
className="block text-xs text-gray-600 uppercase"
31-
>
32-
Email Address
33-
</label>
34-
<input
35-
id="email"
36-
name="email"
37-
type="email"
38-
placeholder="user@acme.com"
39-
autoComplete="email"
40-
required
41-
className="mt-1 block w-full appearance-none rounded-md border border-gray-300 px-3 py-2 placeholder-gray-400 shadow-sm focus:border-black focus:outline-none focus:ring-black sm:text-sm"
42-
value={username}
43-
onChange={(e) => setUsername(e.target.value)}
44-
/>
45-
</div>
46-
<div>
47-
<label
48-
htmlFor="password"
49-
className="block text-xs text-gray-600 uppercase"
50-
>
51-
Password
52-
</label>
53-
<input
54-
id="password"
55-
name="password"
56-
type="password"
57-
required
58-
className="mt-1 block w-full appearance-none rounded-md border border-gray-300 px-3 py-2 placeholder-gray-400 shadow-sm focus:border-black focus:outline-none focus:ring-black sm:text-sm"
59-
value={password}
60-
onChange={(e) => setPassword(e.target.value)}
61-
/>
62-
</div>
63-
<div className='text-center'>{message}</div>
64-
<button
65-
onClick={handleLogin}
66-
className="flex h-10 w-full items-center justify-center rounded-md border text-sm transition-all focus:outline-none cursor-pointer"
67-
>Login
68-
</button>
69-
</form>
70-
);
71-
}
30+
Email Address
31+
</label>
32+
<input
33+
id='email'
34+
name='email'
35+
type='email'
36+
placeholder='user@acme.com'
37+
autoComplete='email'
38+
required
39+
className='mt-1 block w-full appearance-none rounded-md border border-gray-300 px-3 py-2 placeholder-gray-400 shadow-sm focus:border-black focus:outline-none focus:ring-black sm:text-sm'
40+
value={username}
41+
onChange={e => setUsername(e.target.value)}
42+
/>
43+
</div>
44+
<div>
45+
<label
46+
htmlFor='password'
47+
className='block text-xs text-gray-600 uppercase'
48+
>
49+
Password
50+
</label>
51+
<input
52+
id='password'
53+
name='password'
54+
type='password'
55+
required
56+
className='mt-1 block w-full appearance-none rounded-md border border-gray-300 px-3 py-2 placeholder-gray-400 shadow-sm focus:border-black focus:outline-none focus:ring-black sm:text-sm'
57+
value={password}
58+
onChange={e => setPassword(e.target.value)}
59+
/>
60+
</div>
61+
<div className='text-center'>{message}</div>
62+
<button
63+
onClick={handleLogin}
64+
className='flex h-10 w-full items-center justify-center rounded-md border text-sm transition-all focus:outline-none cursor-pointer'
65+
>
66+
Login
67+
</button>
68+
</form>
69+
);
70+
};
7271

73-
export default PasswordForm;
72+
export default PasswordForm;

playground/connect-next/components.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818
"hooks": "@/hooks"
1919
},
2020
"iconLibrary": "lucide"
21-
}
21+
}

playground/connect-next/components/ProtectedRoute.tsx

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,31 @@ import { useRouter } from 'next/navigation';
55
import { fetchAuthSession } from 'aws-amplify/auth';
66

77
const isUserSignedIn = async (): Promise<boolean> => {
8-
try {
9-
const session = await fetchAuthSession();
10-
return session?.tokens?.idToken != null;
11-
} catch {
12-
return false;
13-
}
8+
try {
9+
const session = await fetchAuthSession();
10+
return session?.tokens?.idToken != null;
11+
} catch {
12+
return false;
13+
}
1414
};
1515

1616
export const ProtectedRoute = ({ children }: { children: React.ReactNode }) => {
17-
const router = useRouter();
18-
const [loading, setLoading] = useState(true);
17+
const router = useRouter();
18+
const [loading, setLoading] = useState(true);
1919

20-
useEffect(() => {
21-
isUserSignedIn().then(isSignedIn => {
22-
if (!isSignedIn) {
23-
router.replace('/login');
24-
} else {
25-
setLoading(false);
26-
}
27-
});
28-
}, [router]);
20+
useEffect(() => {
21+
isUserSignedIn().then(isSignedIn => {
22+
if (!isSignedIn) {
23+
router.replace('/login');
24+
} else {
25+
setLoading(false);
26+
}
27+
});
28+
}, [router]);
2929

30-
if (loading) return null; // or loading spinner
30+
if (loading) return null; // or loading spinner
3131

32-
return <>{children}</>;
32+
return <>{children}</>;
3333
};
3434

35-
export default ProtectedRoute;
35+
export default ProtectedRoute;
Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,53 @@
1-
import * as React from "react"
2-
import { Slot } from "@radix-ui/react-slot"
3-
import { cva, type VariantProps } from "class-variance-authority"
1+
import * as React from 'react';
2+
import { Slot } from '@radix-ui/react-slot';
3+
import { cva, type VariantProps } from 'class-variance-authority';
44

5-
import { cn } from "@/lib/utils"
5+
import { cn } from '@/lib/utils';
66

77
const buttonVariants = cva(
8-
"inline-flex items-center justify-center gap-2 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 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
8+
'inline-flex items-center justify-center gap-2 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 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0',
99
{
1010
variants: {
1111
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",
12+
default: 'bg-primary text-primary-foreground shadow hover:bg-primary/90',
13+
destructive: 'bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90',
14+
outline: 'border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground',
15+
secondary: 'bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80',
16+
ghost: 'hover:bg-accent hover:text-accent-foreground',
17+
link: 'text-primary underline-offset-4 hover:underline',
2218
},
2319
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",
20+
default: 'h-9 px-4 py-2',
21+
sm: 'h-8 rounded-md px-3 text-xs',
22+
lg: 'h-10 rounded-md px-8',
23+
icon: 'h-9 w-9',
2824
},
2925
},
3026
defaultVariants: {
31-
variant: "default",
32-
size: "default",
27+
variant: 'default',
28+
size: 'default',
3329
},
34-
}
35-
)
30+
},
31+
);
3632

3733
export interface ButtonProps
3834
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
3935
VariantProps<typeof buttonVariants> {
40-
asChild?: boolean
36+
asChild?: boolean;
4137
}
4238

4339
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
4440
({ className, variant, size, asChild = false, ...props }, ref) => {
45-
const Comp = asChild ? Slot : "button"
41+
const Comp = asChild ? Slot : 'button';
4642
return (
4743
<Comp
4844
className={cn(buttonVariants({ variant, size, className }))}
4945
ref={ref}
5046
{...props}
5147
/>
52-
)
53-
}
54-
)
55-
Button.displayName = "Button"
48+
);
49+
},
50+
);
51+
Button.displayName = 'Button';
5652

57-
export { Button, buttonVariants }
53+
export { Button, buttonVariants };

0 commit comments

Comments
 (0)