Skip to content

Commit 70889d7

Browse files
committed
refactor: remove unused code
- clean up code
1 parent eccc077 commit 70889d7

File tree

11 files changed

+41
-284
lines changed

11 files changed

+41
-284
lines changed

β€Žnext.config.jsβ€Ž

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ module.exports = {
2121
stitches: computePath('./src/styles/stitches.config.ts'),
2222
stores: computePath('./src/stores/'),
2323
styles: computePath('./src/styles'),
24-
theme: computePath('./src/theme/'),
2524
types: computePath('./src/types/'),
2625
utils: computePath('./src/utils'),
2726
}

β€Žsrc/components/atoms/Link/DynamicLink.tsxβ€Ž

Lines changed: 0 additions & 32 deletions
This file was deleted.

β€Žsrc/components/atoms/Link/StaticLink.tsxβ€Ž

Lines changed: 0 additions & 35 deletions
This file was deleted.
Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,37 @@
1-
export { Link } from './StaticLink'
2-
export { DynamicLink } from './DynamicLink'
1+
import NextLink from 'next/link'
2+
import { useRouter } from 'next/router'
3+
import type { Routes } from 'routes'
4+
import { routes } from 'routes'
5+
import type { CSS } from 'stitches'
6+
7+
import { Styled } from './styles'
8+
import { handleKeyPress } from './utils'
9+
10+
type Props = {
11+
route: keyof Routes
12+
label: string
13+
param?: string
14+
css?: CSS
15+
isActive?: (pathname: string) => boolean
16+
}
17+
18+
function Link({ route, label, param, isActive, ...rest }: Props) {
19+
const { pathname } = useRouter()
20+
const href = param ? `${routes[route]}/${param}` : routes[route]
21+
22+
return (
23+
<NextLink href={href}>
24+
<Styled.Root
25+
href={href}
26+
active={isActive?.(pathname) ?? href === pathname}
27+
tabIndex={0}
28+
onKeyPress={handleKeyPress}
29+
{...rest}
30+
>
31+
{label}
32+
</Styled.Root>
33+
</NextLink>
34+
)
35+
}
36+
37+
export { Link }

β€Žsrc/pagesContent/users/index.tsxβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Button } from 'components/atoms/Button'
2-
import { DynamicLink } from 'components/atoms/Link'
2+
import { Link } from 'components/atoms/Link'
33
import { Text } from 'components/atoms/Text'
44
import { useStore } from 'stores/someStore'
55
import type { User } from 'types/user'
@@ -13,7 +13,7 @@ function RenderUsers({ users }: Props) {
1313
const updateCount = useStore(s => s.updateCount)
1414

1515
const links = users.map(({ id, name }) => (
16-
<DynamicLink
16+
<Link
1717
key={id}
1818
css={{
1919
display: 'block',

β€Žsrc/routes.tsβ€Ž

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,7 @@ const routes = {
33
users: '/users',
44
} as const
55

6-
const dynamicRoutes = {
7-
users: '/users',
8-
} as const
9-
10-
function getRouteDetails(route: keyof DynamicRoutes): DynamicRoutesDetail {
11-
switch (route) {
12-
case 'users':
13-
return { basePath: dynamicRoutes[route], paramBracket: '[id]' }
14-
}
15-
}
16-
17-
type DynamicRoutesDetail = {
18-
basePath: string
19-
paramBracket: string
20-
}
21-
226
type Routes = typeof routes
23-
type DynamicRoutes = typeof dynamicRoutes
247

25-
export { routes, getRouteDetails }
26-
export type { DynamicRoutesDetail, DynamicRoutes, Routes }
8+
export { routes }
9+
export type { Routes }

β€Žsrc/theme/get.tsβ€Ž

Lines changed: 0 additions & 26 deletions
This file was deleted.

β€Žsrc/theme/index.tsβ€Ž

Lines changed: 0 additions & 129 deletions
This file was deleted.

β€Žsrc/theme/types.tsβ€Ž

Lines changed: 0 additions & 8 deletions
This file was deleted.

β€Žsrc/theme/utils.tsβ€Ž

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
Β (0)