Skip to content

Commit 465c3c4

Browse files
committed
Add consistency and remove redundancy
- Use `Route::inertia` shorthand method - Use `route` helper in pages' breadcrumbs - Adopt the import ordering consistency in `auth` pages - Import `icons` for navigation items to minimize imports - Reuse breadcrumbs for a dynamic title (also fixes the wrong title for `password.tsx`)
1 parent 7e160e0 commit 465c3c4

File tree

15 files changed

+33
-50
lines changed

15 files changed

+33
-50
lines changed

resources/js/components/app-header.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,28 @@ import { useInitials } from '@/hooks/use-initials';
1111
import { cn } from '@/lib/utils';
1212
import { type BreadcrumbItem, type NavItem, type SharedData } from '@/types';
1313
import { Link, usePage } from '@inertiajs/react';
14-
import { BookOpen, Folder, LayoutGrid, Menu, Search } from 'lucide-react';
14+
import { Menu, Search, icons } from 'lucide-react';
1515
import AppLogo from './app-logo';
1616
import AppLogoIcon from './app-logo-icon';
1717

1818
const mainNavItems: NavItem[] = [
1919
{
2020
title: 'Dashboard',
21-
href: '/dashboard',
22-
icon: LayoutGrid,
21+
href: route('dashboard'),
22+
icon: icons.LayoutDashboard,
2323
},
2424
];
2525

2626
const rightNavItems: NavItem[] = [
2727
{
2828
title: 'Repository',
2929
href: 'https://github.com/laravel/react-starter-kit',
30-
icon: Folder,
30+
icon: icons.Folder,
3131
},
3232
{
3333
title: 'Documentation',
3434
href: 'https://laravel.com/docs/starter-kits',
35-
icon: BookOpen,
35+
icon: icons.BookOpen,
3636
},
3737
];
3838

resources/js/components/app-sidebar.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@ import { NavUser } from '@/components/nav-user';
44
import { Sidebar, SidebarContent, SidebarFooter, SidebarHeader, SidebarMenu, SidebarMenuButton, SidebarMenuItem } from '@/components/ui/sidebar';
55
import { type NavItem } from '@/types';
66
import { Link } from '@inertiajs/react';
7-
import { BookOpen, Folder, LayoutGrid } from 'lucide-react';
7+
import { icons } from 'lucide-react';
88
import AppLogo from './app-logo';
99

1010
const mainNavItems: NavItem[] = [
1111
{
1212
title: 'Dashboard',
13-
href: '/dashboard',
14-
icon: LayoutGrid,
13+
href: route('dashboard'),
14+
icon: icons.LayoutDashboard,
1515
},
1616
];
1717

1818
const footerNavItems: NavItem[] = [
1919
{
2020
title: 'Repository',
2121
href: 'https://github.com/laravel/react-starter-kit',
22-
icon: Folder,
22+
icon: icons.Folder,
2323
},
2424
{
2525
title: 'Documentation',
2626
href: 'https://laravel.com/docs/starter-kits',
27-
icon: BookOpen,
27+
icon: icons.BookOpen,
2828
},
2929
];
3030

resources/js/layouts/app-layout.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import AppLayoutTemplate from '@/layouts/app/app-sidebar-layout';
22
import { type BreadcrumbItem } from '@/types';
3+
import { Head } from '@inertiajs/react';
34
import { type ReactNode } from 'react';
45

56
interface AppLayoutProps {
@@ -9,6 +10,7 @@ interface AppLayoutProps {
910

1011
export default ({ children, breadcrumbs, ...props }: AppLayoutProps) => (
1112
<AppLayoutTemplate breadcrumbs={breadcrumbs} {...props}>
13+
<Head title={breadcrumbs?.map((item) => item.title).join(' > ')} />
1214
{children}
1315
</AppLayoutTemplate>
1416
);

resources/js/layouts/app/app-header-layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { AppContent } from '@/components/app-content';
22
import { AppHeader } from '@/components/app-header';
33
import { AppShell } from '@/components/app-shell';
44
import { type BreadcrumbItem } from '@/types';
5-
import type { PropsWithChildren } from 'react';
5+
import { type PropsWithChildren } from 'react';
66

77
export default function AppHeaderLayout({ children, breadcrumbs }: PropsWithChildren<{ breadcrumbs?: BreadcrumbItem[] }>) {
88
return (

resources/js/pages/auth/confirm-password.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// Components
21
import { Head, useForm } from '@inertiajs/react';
32
import { LoaderCircle } from 'lucide-react';
43
import { FormEventHandler } from 'react';

resources/js/pages/auth/forgot-password.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// Components
21
import { Head, useForm } from '@inertiajs/react';
32
import { LoaderCircle } from 'lucide-react';
43
import { FormEventHandler } from 'react';

resources/js/pages/auth/verify-email.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// Components
21
import { Head, useForm } from '@inertiajs/react';
32
import { LoaderCircle } from 'lucide-react';
43
import { FormEventHandler } from 'react';

resources/js/pages/dashboard.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,32 @@
11
import { PlaceholderPattern } from '@/components/ui/placeholder-pattern';
22
import AppLayout from '@/layouts/app-layout';
33
import { type BreadcrumbItem } from '@/types';
4-
import { Head } from '@inertiajs/react';
54

65
const breadcrumbs: BreadcrumbItem[] = [
76
{
87
title: 'Dashboard',
9-
href: '/dashboard',
8+
href: route('dashboard'),
109
},
1110
];
1211

1312
export default function Dashboard() {
1413
return (
1514
<AppLayout breadcrumbs={breadcrumbs}>
16-
<Head title="Dashboard" />
1715
<div className="flex h-full flex-1 flex-col gap-4 rounded-xl p-4">
1816
<div className="grid auto-rows-min gap-4 md:grid-cols-3">
1917
<div className="border-sidebar-border/70 dark:border-sidebar-border relative aspect-video overflow-hidden rounded-xl border">
2018
<PlaceholderPattern className="absolute inset-0 size-full stroke-neutral-900/20 dark:stroke-neutral-100/20" />
2119
</div>
20+
2221
<div className="border-sidebar-border/70 dark:border-sidebar-border relative aspect-video overflow-hidden rounded-xl border">
2322
<PlaceholderPattern className="absolute inset-0 size-full stroke-neutral-900/20 dark:stroke-neutral-100/20" />
2423
</div>
24+
2525
<div className="border-sidebar-border/70 dark:border-sidebar-border relative aspect-video overflow-hidden rounded-xl border">
2626
<PlaceholderPattern className="absolute inset-0 size-full stroke-neutral-900/20 dark:stroke-neutral-100/20" />
2727
</div>
2828
</div>
29+
2930
<div className="border-sidebar-border/70 dark:border-sidebar-border relative min-h-[100vh] flex-1 overflow-hidden rounded-xl border md:min-h-min">
3031
<PlaceholderPattern className="absolute inset-0 size-full stroke-neutral-900/20 dark:stroke-neutral-100/20" />
3132
</div>

resources/js/pages/settings/appearance.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
1-
import { Head } from '@inertiajs/react';
2-
31
import AppearanceTabs from '@/components/appearance-tabs';
42
import HeadingSmall from '@/components/heading-small';
5-
import { type BreadcrumbItem } from '@/types';
6-
73
import AppLayout from '@/layouts/app-layout';
84
import SettingsLayout from '@/layouts/settings/layout';
5+
import { type BreadcrumbItem } from '@/types';
96

107
const breadcrumbs: BreadcrumbItem[] = [
118
{
129
title: 'Appearance settings',
13-
href: '/settings/appearance',
10+
href: route('appearance'),
1411
},
1512
];
1613

1714
export default function Appearance() {
1815
return (
1916
<AppLayout breadcrumbs={breadcrumbs}>
20-
<Head title="Appearance settings" />
21-
2217
<SettingsLayout>
2318
<div className="space-y-6">
2419
<HeadingSmall title="Appearance settings" description="Update your account's appearance settings" />

resources/js/pages/settings/password.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
import InputError from '@/components/input-error';
2-
import AppLayout from '@/layouts/app-layout';
3-
import SettingsLayout from '@/layouts/settings/layout';
4-
import { type BreadcrumbItem } from '@/types';
51
import { Transition } from '@headlessui/react';
6-
import { Head, useForm } from '@inertiajs/react';
2+
import { useForm } from '@inertiajs/react';
73
import { FormEventHandler, useRef } from 'react';
84

95
import HeadingSmall from '@/components/heading-small';
6+
import InputError from '@/components/input-error';
107
import { Button } from '@/components/ui/button';
118
import { Input } from '@/components/ui/input';
129
import { Label } from '@/components/ui/label';
10+
import AppLayout from '@/layouts/app-layout';
11+
import SettingsLayout from '@/layouts/settings/layout';
12+
import { type BreadcrumbItem } from '@/types';
1313

1414
const breadcrumbs: BreadcrumbItem[] = [
1515
{
1616
title: 'Password settings',
17-
href: '/settings/password',
17+
href: route('password.edit'),
1818
},
1919
];
2020

@@ -50,8 +50,6 @@ export default function Password() {
5050

5151
return (
5252
<AppLayout breadcrumbs={breadcrumbs}>
53-
<Head title="Profile settings" />
54-
5553
<SettingsLayout>
5654
<div className="space-y-6">
5755
<HeadingSmall title="Update password" description="Ensure your account is using a long, random password to stay secure" />

0 commit comments

Comments
 (0)