Skip to content

Commit e1bed97

Browse files
author
Adam Plesnik
committed
Tune nav, change item styling, tune switch, github icon
1 parent a00896c commit e1bed97

File tree

4 files changed

+30
-40
lines changed

4 files changed

+30
-40
lines changed

docs/src/components/DarkModeSwitch.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ const DarkModeSwitch = () => {
1616

1717
return (
1818
<div
19-
className="flex size-8 cursor-pointer flex-col overflow-hidden rounded-full transition-colors hover:bg-white/40 dark:hover:bg-slate-500/60"
19+
className="flex size-7 cursor-pointer flex-col overflow-hidden text-zinc-900 opacity-70 transition-opacity duration-200 hover:opacity-100 dark:text-zinc-100"
2020
onClick={switchMode}
2121
>
2222
<motion.div
23-
initial={{ y: !darkMode ? 0 : '-2rem' }}
24-
animate={{ y: !darkMode ? 0 : '-2rem' }}
23+
initial={{ y: darkMode ? 0 : '-1.75rem' }}
24+
animate={{ y: darkMode ? 0 : '-1.75rem' }}
2525
transition={{ ease: [0.65, 0.05, 0.17, 0.99], duration: 0.5, delay: 0.2 }}
2626
className="group flex flex-col"
2727
>
28-
<Sun className="size-8 p-1 transition-transform duration-700 ease-line group-hover:rotate-[22deg]" />
29-
<Moon className="size-8 p-1 transition-transform duration-700 ease-line group-hover:-rotate-[22deg]" />
28+
<Moon className="size-7 p-1 transition-transform duration-700 ease-line group-hover:rotate-[22deg]" />
29+
<Sun className="size-7 p-1 transition-transform duration-700 ease-line group-hover:rotate-[22deg]" />
3030
</motion.div>
3131
</div>
3232
)
+11-16
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
1-
import { PropsWithChildren } from 'react'
2-
import { NavLink } from 'react-router-dom'
1+
import { HTMLAttributes, PropsWithChildren } from 'react'
2+
import { NavLink, NavLinkProps } from 'react-router-dom'
3+
import { addWithSpace } from '../utils/addWithSpace'
34

4-
const HeaderNavAnchor = ({
5-
children,
6-
to: href,
7-
className = '',
8-
external = false,
9-
}: PropsWithChildren<HeaderNavAnchorProps>) => {
5+
const HeaderNavAnchor = ({ children, to, className, external = false }: HeaderNavAnchorProps) => {
106
return (
117
<NavLink
12-
to={href}
8+
to={to}
139
className={({ isActive }) =>
14-
'flex items-center justify-center rounded-full px-2 text-sm font-medium transition-colors duration-200 md:min-w-12 ' +
15-
'hover:bg-fuchsia-400/40 dark:hover:bg-slate-500/60 ' +
16-
(isActive ? 'bg-fuchsia-400/30 dark:bg-slate-500/50 ' : '') +
17-
(className != '' ? ` ${className}` : '')
10+
'flex items-center justify-center text-sm font-medium text-zinc-900 transition-opacity duration-200 hover:opacity-100 dark:text-zinc-100 ' +
11+
(isActive ? 'opacity-100 ' : 'opacity-70 ') +
12+
addWithSpace(className)
1813
}
1914
target={external ? '_blank' : ''}
2015
>
@@ -23,10 +18,10 @@ const HeaderNavAnchor = ({
2318
)
2419
}
2520

26-
export interface HeaderNavAnchorProps {
21+
export type HeaderNavAnchorProps = {
2722
children: PropsWithChildren
2823
to: string
29-
className?: string | undefined
3024
external?: boolean
31-
}
25+
} & HTMLAttributes<NavLinkProps>
26+
3227
export default HeaderNavAnchor

docs/src/partials/Nav.tsx

+13-18
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,27 @@
11
import { Github } from 'lucide-react'
2-
import { NavLink } from 'react-router-dom'
32
import DarkModeSwitch from '../components/DarkModeSwitch.tsx'
43
import HeaderNavAnchor from '../components/HeaderNavAnchor.tsx'
54
import Logo from '../components/Logo.tsx'
65

76
const Nav = () => {
87
return (
9-
<div className="sticky top-0 z-20 flex w-full items-stretch justify-center bg-white/20 text-zinc-800 shadow-xl shadow-black/5 backdrop-blur-sm dark:border-b-slate-600/50 dark:bg-slate-800/60 dark:text-zinc-300">
10-
<div className="flex w-full max-w-screen-lg items-stretch gap-2 px-8 py-3 md:px-16 lg:px-20">
11-
<NavLink
12-
className="mr-2 flex items-center gap-1 self-center text-sm font-medium text-zinc-950 dark:text-zinc-50"
13-
to="/"
14-
>
8+
<div className="sticky top-0 z-20 flex w-full items-stretch justify-center bg-white/20 text-zinc-700 shadow-xl shadow-black/5 backdrop-blur-sm dark:border-b-slate-600/50 dark:bg-slate-800/60 dark:text-zinc-400">
9+
<div className="flex w-full max-w-screen-lg items-stretch gap-6 px-8 py-3 md:px-16 lg:px-20">
10+
<HeaderNavAnchor className="flex items-center gap-1 self-center text-sm font-medium" to="/">
1511
<Logo />
1612
<span className="mr-2 hidden sm:block">scrolldriven.dev</span>
17-
</NavLink>
18-
<HeaderNavAnchor to="/">How To</HeaderNavAnchor>
13+
</HeaderNavAnchor>
1914
<HeaderNavAnchor to="/docs">Docs</HeaderNavAnchor>
2015
<HeaderNavAnchor to="/tech">Tech</HeaderNavAnchor>
21-
<div className="flex-1" />
22-
<DarkModeSwitch />
23-
<a
24-
href="https://github.com/adamplesnik/tailwindcss-scroll-driven-animations"
25-
target="_blank"
26-
className="group flex size-8 items-center justify-center self-center rounded-full p-1.5 transition-colors duration-200 hover:bg-white/40 dark:hover:bg-slate-500/60"
27-
>
28-
<Github className="group-hover:animate-bounce-bottom" />
29-
</a>
16+
<div className="flex flex-1 items-center justify-end gap-2">
17+
<DarkModeSwitch />
18+
<HeaderNavAnchor
19+
to="https://github.com/adamplesnik/tailwindcss-scroll-driven-animations"
20+
external
21+
>
22+
<Github className="p-0.5 hover:animate-bounce-bottom" />
23+
</HeaderNavAnchor>
24+
</div>
3025
</div>
3126
</div>
3227
)

docs/src/utils/addWithSpace.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export const addWithSpace = (value: string) => {
1+
export const addWithSpace = (value: string | undefined) => {
22
return value ? ` ${value}` : ''
33
}

0 commit comments

Comments
 (0)