Skip to content

Commit bae75af

Browse files
committed
further improve icons and things
1 parent 9af855c commit bae75af

File tree

9 files changed

+77
-64
lines changed

9 files changed

+77
-64
lines changed

exercises/99.final/01.solution.final/src/components/button.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ const buttonStyles = cva(
2727
'hover:bg-button/10',
2828
'active:bg-button/20',
2929
],
30+
},
31+
status: {
3032
success: [
3133
'bg-success-background text-success-foreground',
3234
'hover:bg-success-background/90',
@@ -52,23 +54,31 @@ const buttonStyles = cva(
5254

5355
export function Button({
5456
variant,
57+
status,
5558
icon,
5659
className,
5760
...props
5861
}: ButtonHTMLAttributes<HTMLButtonElement> &
5962
VariantProps<typeof buttonStyles>) {
6063
return (
61-
<button className={buttonStyles({ variant, icon, className })} {...props} />
64+
<button
65+
className={buttonStyles({ variant, status, icon, className })}
66+
{...props}
67+
/>
6268
)
6369
}
6470

65-
export function LinkButton({
71+
export function ButtonLink({
6672
variant,
73+
status,
6774
icon,
6875
className,
6976
...props
7077
}: LinkProps & VariantProps<typeof buttonStyles>) {
7178
return (
72-
<Link className={buttonStyles({ variant, icon, className })} {...props} />
79+
<Link
80+
className={buttonStyles({ variant, status, icon, className })}
81+
{...props}
82+
/>
7383
)
7484
}

exercises/99.final/01.solution.final/src/components/icons.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,20 @@ export function ArrowLeftIcon({ title, ...props }: IconProps) {
1616
)
1717
}
1818

19+
export function ArrowRightIcon({ title, ...props }: IconProps) {
20+
return (
21+
<svg fill="none" viewBox="0 0 24 24" stroke="currentColor" {...props}>
22+
{title ? <title>{title}</title> : null}
23+
<path
24+
strokeLinecap="round"
25+
strokeLinejoin="round"
26+
strokeWidth={2}
27+
d="M9 5l7 7-7 7"
28+
/>
29+
</svg>
30+
)
31+
}
32+
1933
export function PhoneIcon({ title, ...props }: IconProps) {
2034
return (
2135
<svg fill="none" viewBox="0 0 24 24" stroke="currentColor" {...props}>
Lines changed: 23 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import { createBrowserRouter } from 'react-router'
1+
import {
2+
createBrowserRouter,
3+
createRoutesFromElements,
4+
Route,
5+
} from 'react-router'
6+
import { NotFoundRoute } from './routes/404.tsx'
27
import { AppLayout } from './routes/app/layout.tsx'
38
import { AboutRoute } from './routes/app/marketing/about.tsx'
49
import { HomepageRoute } from './routes/app/marketing/homepage.tsx'
@@ -8,39 +13,20 @@ import { RecipientRoute } from './routes/app/recipient.tsx'
813
import { RecipientsRoute } from './routes/app/recipients.tsx'
914
import { SignupRoute } from './routes/signup.tsx'
1015

11-
export const router = createBrowserRouter([
12-
{
13-
element: <AppLayout />,
14-
children: [
15-
{
16-
element: <MarketingLayout />,
17-
children: [
18-
{
19-
index: true,
20-
element: <HomepageRoute />,
21-
},
22-
{
23-
path: 'about',
24-
element: <AboutRoute />,
25-
},
26-
],
27-
},
28-
{
29-
path: 'recipients',
30-
element: <RecipientsRoute />,
31-
},
32-
{
33-
path: 'recipients/new',
34-
element: <NewRecipientRoute />,
35-
},
36-
{
37-
path: 'recipients/:id',
38-
element: <RecipientRoute />,
39-
},
40-
],
41-
},
42-
{
43-
path: '/signup',
44-
element: <SignupRoute />,
45-
},
46-
])
16+
export const router = createBrowserRouter(
17+
createRoutesFromElements(
18+
<Route>
19+
<Route element={<AppLayout />}>
20+
<Route element={<MarketingLayout />}>
21+
<Route index element={<HomepageRoute />} />
22+
<Route path="about" element={<AboutRoute />} />
23+
</Route>
24+
<Route path="recipients" element={<RecipientsRoute />} />
25+
<Route path="recipients/new" element={<NewRecipientRoute />} />
26+
<Route path="recipients/:id" element={<RecipientRoute />} />
27+
</Route>
28+
<Route path="/signup" element={<SignupRoute />} />
29+
<Route path="*" element={<NotFoundRoute />} />
30+
</Route>,
31+
),
32+
)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { ButtonLink } from '#src/components/button.tsx'
2+
3+
export function NotFoundRoute() {
4+
return (
5+
<div className="flex min-h-screen flex-col items-center justify-center gap-4">
6+
<h1 className="text-4xl font-bold">404 - Page Not Found</h1>
7+
<p className="text-lg opacity-80">
8+
Sorry, we couldn't find the page you're looking for.
9+
</p>
10+
<ButtonLink to="/">Go back home</ButtonLink>
11+
</div>
12+
)
13+
}

exercises/99.final/01.solution.final/src/routes/app/layout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Link, Outlet } from 'react-router'
2-
import { LinkButton } from '#src/components/button.tsx'
2+
import { ButtonLink } from '#src/components/button.tsx'
33

44
export function AppLayout() {
55
return (
@@ -13,7 +13,7 @@ export function AppLayout() {
1313
gratitext
1414
</Link>
1515
<nav>
16-
<LinkButton to="/recipients">Recipients</LinkButton>
16+
<ButtonLink to="/recipients">Recipients</ButtonLink>
1717
</nav>
1818
</div>
1919
</header>

exercises/99.final/01.solution.final/src/routes/app/marketing/homepage.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { LinkButton } from '#src/components/button.tsx'
1+
import { ButtonLink } from '#src/components/button.tsx'
22

33
export function HomepageRoute() {
44
return (
@@ -12,9 +12,9 @@ export function HomepageRoute() {
1212
love and gratitude.
1313
</p>
1414
<div>
15-
<LinkButton to="/signup" variant="secondary">
15+
<ButtonLink to="/signup" variant="secondary">
1616
Get Started
17-
</LinkButton>
17+
</ButtonLink>
1818
</div>
1919
</div>
2020
<div className="order-1 mx-16 flex justify-center md:order-2 md:mx-0">

exercises/99.final/01.solution.final/src/routes/app/new-recipient.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export function NewRecipientRoute() {
120120
</Icon>
121121
</div>
122122

123-
<Button type="submit" variant="success">
123+
<Button type="submit" status="success">
124124
<Icon name="Plus">Add New Recipient</Icon>
125125
</Button>
126126
</form>

exercises/99.final/01.solution.final/src/routes/app/recipients.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Link } from 'react-router'
2-
import { Button, LinkButton } from '#src/components/button.tsx'
2+
import { Button, ButtonLink } from '#src/components/button.tsx'
33
import { Icon } from '#src/components/icon.tsx'
44

55
const recipients = [
@@ -31,15 +31,15 @@ export function RecipientsRoute() {
3131
<div className="container mx-auto p-4 md:p-8">
3232
<div className="mb-8 flex items-center justify-between">
3333
<h1 className="text-4xl font-bold">Recipients</h1>
34-
<LinkButton
34+
<ButtonLink
3535
to="/recipients/new"
3636
className="hidden items-center gap-2 md:flex"
3737
>
3838
<Icon name="Plus">Add New Recipient</Icon>
39-
</LinkButton>
40-
<LinkButton icon to="/recipients/new" className="md:hidden">
39+
</ButtonLink>
40+
<ButtonLink icon to="/recipients/new" className="md:hidden">
4141
<Icon name="Plus" />
42-
</LinkButton>
42+
</ButtonLink>
4343
</div>
4444

4545
{/* Table view (hidden on mobile) */}

exercises/99.final/01.solution.final/src/routes/signup.tsx

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Link } from 'react-router'
22
import { Button } from '#src/components/button.tsx'
3+
import { Icon } from '#src/components/icon.tsx'
34

45
export function SignupRoute() {
56
return (
@@ -48,21 +49,10 @@ export function SignupRoute() {
4849
<Button
4950
type="submit"
5051
className="flex w-full items-center justify-center gap-2"
52+
status="success"
5153
>
5254
<span>Continue</span>
53-
<svg
54-
className="h-5 w-5"
55-
fill="none"
56-
viewBox="0 0 24 24"
57-
stroke="currentColor"
58-
>
59-
<path
60-
strokeLinecap="round"
61-
strokeLinejoin="round"
62-
strokeWidth={2}
63-
d="M9 5l7 7-7 7"
64-
/>
65-
</svg>
55+
<Icon name="ArrowRight" size="md" />
6656
</Button>
6757
</div>
6858
</form>

0 commit comments

Comments
 (0)