Skip to content

Commit

Permalink
feat: add clsx
Browse files Browse the repository at this point in the history
  • Loading branch information
tonykhaov committed Mar 3, 2022
1 parent 03c19de commit 7a5d069
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"preview": "vite preview"
},
"dependencies": {
"clsx": "^1.1.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-query": "^3.34.16",
Expand Down
26 changes: 21 additions & 5 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,33 @@
import { Routes, Route, Link } from 'react-router-dom'
import { Routes, Route, Link, useLocation } from 'react-router-dom'
import Homepage from '@pages/homepage'
import About from '@pages/about'
import clsx from 'clsx'

function App() {
const { pathname } = useLocation()
return (
<>
<nav>
<ul className="flex justify-center gap-8">
<li className="border border-black p-8">
<Link to="/">Go to homepage</Link>
<li>
<Link
to="/"
className={clsx('hover:text-blue-500', {
'border-b-4 border-blue-400 text-blue-700': pathname === '/',
})}
>
Go to homepage
</Link>
</li>
<li className="border border-black p-8">
<Link to="/about">Go to about</Link>
<li>
<Link
to="/about"
className={clsx('hover:text-blue-500', {
'border-b-4 border-blue-400 text-blue-700': pathname === '/about',
})}
>
Go to about
</Link>
</li>
</ul>
</nav>
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,11 @@ clone@^1.0.2:
resolved "https://registry.yarnpkg.com/clone/-/clone-1.0.4.tgz#da309cc263df15994c688ca902179ca3c7cd7c7e"
integrity sha1-2jCcwmPfFZlMaIypAheco8fNfH4=

clsx@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/clsx/-/clsx-1.1.1.tgz#98b3134f9abbdf23b2663491ace13c5c03a73188"
integrity sha512-6/bPho624p3S2pMyvP5kKBPXnI3ufHLObBFCfgx+LkeR5lg2XYy2hqZqUf45ypD8COn2bhgGJSUE+l5dhNBieA==

color-convert@^1.9.0:
version "1.9.3"
resolved "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz"
Expand Down

0 comments on commit 7a5d069

Please sign in to comment.