Skip to content

Replace Ziggy with Wayfinder #151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ jobs:
- name: Install Node Dependencies
run: npm ci

- name: Build Assets
run: npm run build

- name: Install Dependencies
run: composer install --no-interaction --prefer-dist --optimize-autoloader

- name: Build Assets
run: npm run build

- name: Copy Environment File
run: cp .env.example .env

Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
/public/build
/public/hot
/public/storage
/resources/js/actions
/resources/js/routes
/resources/js/wayfinder
/storage/*.key
/storage/pail
/vendor
Expand Down
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
resources/js/components/ui/*
resources/js/ziggy.js
resources/views/mail/*
5 changes: 0 additions & 5 deletions app/Http/Middleware/HandleInertiaRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Illuminate\Foundation\Inspiring;
use Illuminate\Http\Request;
use Inertia\Middleware;
use Tighten\Ziggy\Ziggy;

class HandleInertiaRequests extends Middleware
{
Expand Down Expand Up @@ -46,10 +45,6 @@ public function share(Request $request): array
'auth' => [
'user' => $request->user(),
],
'ziggy' => fn (): array => [
...(new Ziggy)->toArray(),
'location' => $request->url(),
],
'sidebarOpen' => ! $request->hasCookie('sidebar_state') || $request->cookie('sidebar_state') === 'true',
];
}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"inertiajs/inertia-laravel": "^2.0",
"laravel/framework": "^12.0",
"laravel/tinker": "^2.10.1",
"tightenco/ziggy": "^2.4"
"laravel/wayfinder": "^0.1.9"
},
"require-dev": {
"fakerphp/faker": "^1.23",
Expand Down
7 changes: 7 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
},
"devDependencies": {
"@eslint/js": "^9.19.0",
"@laravel/vite-plugin-wayfinder": "^0.1.3",
"@types/node": "^22.13.5",
"eslint": "^9.17.0",
"eslint-config-prettier": "^10.0.1",
Expand Down
11 changes: 6 additions & 5 deletions resources/js/components/app-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/comp
import { UserMenuContent } from '@/components/user-menu-content';
import { useInitials } from '@/hooks/use-initials';
import { cn } from '@/lib/utils';
import { dashboard } from '@/routes';
import { type BreadcrumbItem, type NavItem, type SharedData } from '@/types';
import { Link, usePage } from '@inertiajs/react';
import { BookOpen, Folder, LayoutGrid, Menu, Search } from 'lucide-react';
Expand All @@ -18,7 +19,7 @@ import AppLogoIcon from './app-logo-icon';
const mainNavItems: NavItem[] = [
{
title: 'Dashboard',
href: '/dashboard',
href: dashboard(),
icon: LayoutGrid,
},
];
Expand Down Expand Up @@ -78,7 +79,7 @@ export function AppHeader({ breadcrumbs = [] }: AppHeaderProps) {
{rightNavItems.map((item) => (
<a
key={item.title}
href={item.href}
href={typeof item.href === 'string' ? item.href : item.href.url}
target="_blank"
rel="noopener noreferrer"
className="flex items-center space-x-2 font-medium"
Expand All @@ -94,7 +95,7 @@ export function AppHeader({ breadcrumbs = [] }: AppHeaderProps) {
</Sheet>
</div>

<Link href="/dashboard" prefetch className="flex items-center space-x-2">
<Link href={dashboard()} prefetch className="flex items-center space-x-2">
<AppLogo />
</Link>

Expand All @@ -108,7 +109,7 @@ export function AppHeader({ breadcrumbs = [] }: AppHeaderProps) {
href={item.href}
className={cn(
navigationMenuTriggerStyle(),
page.url === item.href && activeItemStyles,
page.url === (typeof item.href === 'string' ? item.href : item.href.url) && activeItemStyles,
'h-9 cursor-pointer px-3',
)}
>
Expand All @@ -135,7 +136,7 @@ export function AppHeader({ breadcrumbs = [] }: AppHeaderProps) {
<Tooltip>
<TooltipTrigger>
<a
href={item.href}
href={typeof item.href === 'string' ? item.href : item.href.url}
target="_blank"
rel="noopener noreferrer"
className="group ml-1 inline-flex h-9 w-9 items-center justify-center rounded-md bg-transparent p-0 text-sm font-medium text-accent-foreground ring-offset-background transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50"
Expand Down
5 changes: 3 additions & 2 deletions resources/js/components/app-sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { NavFooter } from '@/components/nav-footer';
import { NavMain } from '@/components/nav-main';
import { NavUser } from '@/components/nav-user';
import { Sidebar, SidebarContent, SidebarFooter, SidebarHeader, SidebarMenu, SidebarMenuButton, SidebarMenuItem } from '@/components/ui/sidebar';
import { dashboard } from '@/routes';
import { type NavItem } from '@/types';
import { Link } from '@inertiajs/react';
import { BookOpen, Folder, LayoutGrid } from 'lucide-react';
Expand All @@ -10,7 +11,7 @@ import AppLogo from './app-logo';
const mainNavItems: NavItem[] = [
{
title: 'Dashboard',
href: '/dashboard',
href: dashboard(),
icon: LayoutGrid,
},
];
Expand All @@ -35,7 +36,7 @@ export function AppSidebar() {
<SidebarMenu>
<SidebarMenuItem>
<SidebarMenuButton size="lg" asChild>
<Link href="/dashboard" prefetch>
<Link href={dashboard()} prefetch>
<AppLogo />
</Link>
</SidebarMenuButton>
Expand Down
4 changes: 2 additions & 2 deletions resources/js/components/delete-user.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { destroy } from '@/actions/App/Http/Controllers/Settings/ProfileController';
import HeadingSmall from '@/components/heading-small';
import InputError from '@/components/input-error';
import { Button } from '@/components/ui/button';
Expand Down Expand Up @@ -31,8 +32,7 @@ export default function DeleteUser() {
</DialogDescription>

<Form
method="delete"
action={route('profile.destroy')}
{...destroy.form()}
options={{
preserveScroll: true,
}}
Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/nav-footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function NavFooter({
asChild
className="text-neutral-600 hover:text-neutral-800 dark:text-neutral-300 dark:hover:text-neutral-100"
>
<a href={item.href} target="_blank" rel="noopener noreferrer">
<a href={typeof item.href === 'string' ? item.href : item.href.url} target="_blank" rel="noopener noreferrer">
{item.icon && <Icon iconNode={item.icon} className="h-5 w-5" />}
<span>{item.title}</span>
</a>
Expand Down
6 changes: 5 additions & 1 deletion resources/js/components/nav-main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ export function NavMain({ items = [] }: { items: NavItem[] }) {
<SidebarMenu>
{items.map((item) => (
<SidebarMenuItem key={item.title}>
<SidebarMenuButton asChild isActive={page.url.startsWith(item.href)} tooltip={{ children: item.title }}>
<SidebarMenuButton
asChild
isActive={page.url.startsWith(typeof item.href === 'string' ? item.href : item.href.url)}
tooltip={{ children: item.title }}
>
<Link href={item.href} prefetch>
{item.icon && <item.icon />}
<span>{item.title}</span>
Expand Down
6 changes: 4 additions & 2 deletions resources/js/components/user-menu-content.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator } from '@/components/ui/dropdown-menu';
import { UserInfo } from '@/components/user-info';
import { useMobileNavigation } from '@/hooks/use-mobile-navigation';
import { logout } from '@/routes';
import { edit } from '@/routes/profile';
import { type User } from '@/types';
import { Link, router } from '@inertiajs/react';
import { LogOut, Settings } from 'lucide-react';
Expand All @@ -27,15 +29,15 @@ export function UserMenuContent({ user }: UserMenuContentProps) {
<DropdownMenuSeparator />
<DropdownMenuGroup>
<DropdownMenuItem asChild>
<Link className="block w-full" href={route('profile.edit')} as="button" prefetch onClick={cleanup}>
<Link className="block w-full" href={edit()} as="button" prefetch onClick={cleanup}>
<Settings className="mr-2" />
Settings
</Link>
</DropdownMenuItem>
</DropdownMenuGroup>
<DropdownMenuSeparator />
<DropdownMenuItem asChild>
<Link className="block w-full" method="post" href={route('logout')} as="button" onClick={handleLogout}>
<Link className="block w-full" href={logout()} as="button" onClick={handleLogout}>
<LogOut className="mr-2" />
Log out
</Link>
Expand Down
3 changes: 2 additions & 1 deletion resources/js/layouts/auth/auth-card-layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import AppLogoIcon from '@/components/app-logo-icon';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
import { home } from '@/routes';
import { Link } from '@inertiajs/react';
import { type PropsWithChildren } from 'react';

Expand All @@ -15,7 +16,7 @@ export default function AuthCardLayout({
return (
<div className="flex min-h-svh flex-col items-center justify-center gap-6 bg-muted p-6 md:p-10">
<div className="flex w-full max-w-md flex-col gap-6">
<Link href={route('home')} className="flex items-center gap-2 self-center font-medium">
<Link href={home()} className="flex items-center gap-2 self-center font-medium">
<div className="flex h-9 w-9 items-center justify-center">
<AppLogoIcon className="size-9 fill-current text-black dark:text-white" />
</div>
Expand Down
3 changes: 2 additions & 1 deletion resources/js/layouts/auth/auth-simple-layout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import AppLogoIcon from '@/components/app-logo-icon';
import { home } from '@/routes';
import { Link } from '@inertiajs/react';
import { type PropsWithChildren } from 'react';

Expand All @@ -14,7 +15,7 @@ export default function AuthSimpleLayout({ children, title, description }: Props
<div className="w-full max-w-sm">
<div className="flex flex-col gap-8">
<div className="flex flex-col items-center gap-4">
<Link href={route('home')} className="flex flex-col items-center gap-2 font-medium">
<Link href={home()} className="flex flex-col items-center gap-2 font-medium">
<div className="mb-1 flex h-9 w-9 items-center justify-center rounded-md">
<AppLogoIcon className="size-9 fill-current text-[var(--foreground)] dark:text-white" />
</div>
Expand Down
5 changes: 3 additions & 2 deletions resources/js/layouts/auth/auth-split-layout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import AppLogoIcon from '@/components/app-logo-icon';
import { home } from '@/routes';
import { type SharedData } from '@/types';
import { Link, usePage } from '@inertiajs/react';
import { type PropsWithChildren } from 'react';
Expand All @@ -15,7 +16,7 @@ export default function AuthSplitLayout({ children, title, description }: PropsW
<div className="relative grid h-dvh flex-col items-center justify-center px-8 sm:px-0 lg:max-w-none lg:grid-cols-2 lg:px-0">
<div className="relative hidden h-full flex-col bg-muted p-10 text-white lg:flex dark:border-r">
<div className="absolute inset-0 bg-zinc-900" />
<Link href={route('home')} className="relative z-20 flex items-center text-lg font-medium">
<Link href={home()} className="relative z-20 flex items-center text-lg font-medium">
<AppLogoIcon className="mr-2 size-8 fill-current text-white" />
{name}
</Link>
Expand All @@ -30,7 +31,7 @@ export default function AuthSplitLayout({ children, title, description }: PropsW
</div>
<div className="w-full lg:p-8">
<div className="mx-auto flex w-full flex-col justify-center space-y-6 sm:w-[350px]">
<Link href={route('home')} className="relative z-20 flex items-center justify-center lg:hidden">
<Link href={home()} className="relative z-20 flex items-center justify-center lg:hidden">
<AppLogoIcon className="h-10 fill-current text-black sm:h-12" />
</Link>
<div className="flex flex-col items-start gap-2 text-left sm:items-center sm:text-center">
Expand Down
13 changes: 8 additions & 5 deletions resources/js/layouts/settings/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,27 @@ import Heading from '@/components/heading';
import { Button } from '@/components/ui/button';
import { Separator } from '@/components/ui/separator';
import { cn } from '@/lib/utils';
import { appearance } from '@/routes';
import { edit as editPassword } from '@/routes/password';
import { edit } from '@/routes/profile';
import { type NavItem } from '@/types';
import { Link } from '@inertiajs/react';
import { type PropsWithChildren } from 'react';

const sidebarNavItems: NavItem[] = [
{
title: 'Profile',
href: '/settings/profile',
href: edit(),
icon: null,
},
{
title: 'Password',
href: '/settings/password',
href: editPassword(),
icon: null,
},
{
title: 'Appearance',
href: '/settings/appearance',
href: appearance(),
icon: null,
},
];
Expand All @@ -41,12 +44,12 @@ export default function SettingsLayout({ children }: PropsWithChildren) {
<nav className="flex flex-col space-y-1 space-x-0">
{sidebarNavItems.map((item, index) => (
<Button
key={`${item.href}-${index}`}
key={`${typeof item.href === 'string' ? item.href : item.href.url}-${index}`}
size="sm"
variant="ghost"
asChild
className={cn('w-full justify-start', {
'bg-muted': currentPath === item.href,
'bg-muted': currentPath === (typeof item.href === 'string' ? item.href : item.href.url),
})}
>
<Link href={item.href} prefetch>
Expand Down
3 changes: 2 additions & 1 deletion resources/js/pages/auth/confirm-password.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { store } from '@/actions/App/Http/Controllers/Auth/ConfirmablePasswordController';
import InputError from '@/components/input-error';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
Expand All @@ -14,7 +15,7 @@ export default function ConfirmPassword() {
>
<Head title="Confirm password" />

<Form method="post" action={route('password.confirm')} resetOnSuccess={['password']}>
<Form {...store.form()} resetOnSuccess={['password']}>
{({ processing, errors }) => (
<div className="space-y-6">
<div className="grid gap-2">
Expand Down
6 changes: 4 additions & 2 deletions resources/js/pages/auth/forgot-password.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// Components
import { store } from '@/actions/App/Http/Controllers/Auth/PasswordResetLinkController';
import { login } from '@/routes';
import { Form, Head } from '@inertiajs/react';
import { LoaderCircle } from 'lucide-react';

Expand All @@ -17,7 +19,7 @@ export default function ForgotPassword({ status }: { status?: string }) {
{status && <div className="mb-4 text-center text-sm font-medium text-green-600">{status}</div>}

<div className="space-y-6">
<Form method="post" action={route('password.email')}>
<Form {...store.form()}>
{({ processing, errors }) => (
<>
<div className="grid gap-2">
Expand All @@ -39,7 +41,7 @@ export default function ForgotPassword({ status }: { status?: string }) {

<div className="space-x-1 text-center text-sm text-muted-foreground">
<span>Or, return to</span>
<TextLink href={route('login')}>log in</TextLink>
<TextLink href={login()}>log in</TextLink>
</div>
</div>
</AuthLayout>
Expand Down
Loading