Skip to content

Commit 9608b69

Browse files
committed
add disable link
1 parent 24e0265 commit 9608b69

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

src/components/Navbar/Navbar.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ export default function Navbar() {
2222

2323
const mainLinks = [
2424
{ name: '2D Plot', href: '/', id: '2d-plot-link' },
25-
{ name: 'Matrix', href: '/matrix', id: 'matrix-link' },
26-
{ name: 'Signal-to-noise', href: '/noise', id: 'noise-link' },
25+
{ name: 'Matrix', href: '/matrix', id: 'matrix-link', disabled: true },
26+
{ name: 'Signal-to-noise', href: '/noise', id: 'noise-link', disabled: true },
2727
]
28-
2928
// const settingsLink = { name: 'Settings', href: '#', id: 'settings-link' }
3029

3130
return (
@@ -56,9 +55,11 @@ export default function Navbar() {
5655
{mainLinks.map((item) => (
5756
<a
5857
key={item.id}
59-
href={item.href}
58+
href={item.disabled ? '#' : item.href}
59+
onClick={item.disabled ? (e) => e.preventDefault() : undefined}
60+
className={`text-sm/6 font-semibold ${item.disabled ? 'text-gray-400 cursor-not-allowed' : 'text-gray-900'
61+
}`}
6062
id={item.id}
61-
className="text-sm/6 font-semibold text-gray-900"
6263
>
6364
{item.name}
6465
</a>
@@ -116,12 +117,14 @@ export default function Navbar() {
116117
href="#"
117118
onClick={(e) => {
118119
e.preventDefault()
120+
if (item.disabled) return
119121
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
120122
item.id === 'settings-link'
121123
? handleSettingsClick()
122124
: setMobileMenuOpen(false)
123125
}}
124-
className="-mx-3 block rounded-lg px-3 py-2 text-base/7 font-semibold text-gray-900 hover:bg-gray-50"
126+
className={`-mx-3 block rounded-lg px-3 py-2 text-base/7 font-semibold ${item.disabled ? 'text-gray-400 cursor-not-allowed' : 'text-gray-900 hover:bg-gray-50'
127+
}`}
125128
>
126129
{item.name}
127130
</a>

0 commit comments

Comments
 (0)