feat: Introduce NavLink component to refactor Navbar navigation, update authentication button labels, and rename news route to news.index.
This commit is contained in:
parent
861aff3c78
commit
7fec6751de
15
resources/js/pages/home/components/NavLink.jsx
Normal file
15
resources/js/pages/home/components/NavLink.jsx
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import { Button } from "@mui/material";
|
||||||
|
import { router } from "@inertiajs/react";
|
||||||
|
|
||||||
|
export default function NavLink({ label, href }) {
|
||||||
|
return (
|
||||||
|
<Button
|
||||||
|
variant="text"
|
||||||
|
size="small"
|
||||||
|
color={window.location.pathname === href ? 'secondary' : ''}
|
||||||
|
onClick={() => router.get(href)}
|
||||||
|
>
|
||||||
|
{label}
|
||||||
|
</Button >
|
||||||
|
)
|
||||||
|
}
|
||||||
@ -13,7 +13,7 @@ import MenuIcon from '@mui/icons-material/Menu';
|
|||||||
import CloseRoundedIcon from '@mui/icons-material/CloseRounded';
|
import CloseRoundedIcon from '@mui/icons-material/CloseRounded';
|
||||||
import ColorModeIconDropdown from '../../theme/ColorModeIconDropdown';
|
import ColorModeIconDropdown from '../../theme/ColorModeIconDropdown';
|
||||||
import Logo from './Logo';
|
import Logo from './Logo';
|
||||||
import { router } from '@inertiajs/react';
|
import NavLink from './NavLink';
|
||||||
|
|
||||||
const StyledToolbar = styled(Toolbar)(({ theme }) => ({
|
const StyledToolbar = styled(Toolbar)(({ theme }) => ({
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
@ -31,13 +31,22 @@ const StyledToolbar = styled(Toolbar)(({ theme }) => ({
|
|||||||
padding: '8px 12px',
|
padding: '8px 12px',
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export default function Navbar() {
|
export default function Navbar({ currentRoute }) {
|
||||||
const [open, setOpen] = React.useState(false);
|
const [open, setOpen] = React.useState(false);
|
||||||
|
|
||||||
const toggleDrawer = (newOpen) => () => {
|
const toggleDrawer = (newOpen) => () => {
|
||||||
setOpen(newOpen);
|
setOpen(newOpen);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const navItems = [
|
||||||
|
{ label: 'Berita', href: '/news' },
|
||||||
|
{ label: 'Testimonials', href: '/testimonials' },
|
||||||
|
{ label: 'Highlights', href: '/highlights' },
|
||||||
|
{ label: 'Pricing', href: '/pricing' },
|
||||||
|
{ label: 'FAQ', href: '/faq' },
|
||||||
|
{ label: 'Blog', href: '/blog' },
|
||||||
|
]
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AppBar
|
<AppBar
|
||||||
position="fixed"
|
position="fixed"
|
||||||
@ -54,29 +63,13 @@ export default function Navbar() {
|
|||||||
<Box sx={{ flexGrow: 1, display: 'flex', alignItems: 'center', px: 0 }}>
|
<Box sx={{ flexGrow: 1, display: 'flex', alignItems: 'center', px: 0 }}>
|
||||||
<Logo />
|
<Logo />
|
||||||
<Box sx={{ display: { xs: 'none', md: 'flex' } }}>
|
<Box sx={{ display: { xs: 'none', md: 'flex' } }}>
|
||||||
<Button
|
{navItems.map((item) => (
|
||||||
variant="text"
|
<NavLink
|
||||||
color="info"
|
key={item.label}
|
||||||
size="small"
|
label={item.label}
|
||||||
onClick={() => router.get('/news')}
|
href={item.href}
|
||||||
>
|
/>
|
||||||
Berita
|
))}
|
||||||
</Button>
|
|
||||||
<Button variant="text" color="info" size="small">
|
|
||||||
Testimonials
|
|
||||||
</Button>
|
|
||||||
<Button variant="text" color="info" size="small">
|
|
||||||
Highlights
|
|
||||||
</Button>
|
|
||||||
<Button variant="text" color="info" size="small">
|
|
||||||
Pricing
|
|
||||||
</Button>
|
|
||||||
<Button variant="text" color="info" size="small" sx={{ minWidth: 0 }}>
|
|
||||||
FAQ
|
|
||||||
</Button>
|
|
||||||
<Button variant="text" color="info" size="small" sx={{ minWidth: 0 }}>
|
|
||||||
Blog
|
|
||||||
</Button>
|
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
<Box
|
<Box
|
||||||
@ -87,10 +80,10 @@ export default function Navbar() {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Button color="primary" variant="text" size="small">
|
<Button color="primary" variant="text" size="small">
|
||||||
Sign in
|
Masuk
|
||||||
</Button>
|
</Button>
|
||||||
<Button color="primary" variant="contained" size="small">
|
<Button color="primary" variant="contained" size="small">
|
||||||
Sign up
|
Daftar
|
||||||
</Button>
|
</Button>
|
||||||
<ColorModeIconDropdown />
|
<ColorModeIconDropdown />
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@ -5,4 +5,4 @@
|
|||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
Route::get('/', [HomepageController::class, 'index'])->name('homepage');
|
Route::get('/', [HomepageController::class, 'index'])->name('homepage');
|
||||||
Route::get('/news', [NewsController::class, 'index'])->name('news');
|
Route::get('/news', [NewsController::class, 'index'])->name('news.index');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user