Skip to content

Commit 9e77d90

Browse files
committed
cleanups
1 parent 9938bb1 commit 9e77d90

File tree

13 files changed

+32
-30
lines changed

13 files changed

+32
-30
lines changed

src/App/ContentPortal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useLocation, useOutlet } from 'react-router-dom'
22
import { SwitchTransition, CSSTransition as CST } from 'react-transition-group'
33

4-
import ROUTES from '../ROUTES'
4+
import { ROUTES } from '../routes'
55
import './ContentPortal.scss'
66

77
export default function ContentPortal() {

src/App/NavBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import classnames from 'classnames'
22
import { NavLink } from 'react-router-dom'
33

4-
import ROUTES from '../ROUTES'
4+
import { ROUTES } from '../routes'
55
import './NavBar.scss'
66

77
export default function NavBar() {

src/ROUTES.tsx

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import { ReactNode, RefObject, createRef, lazy } from 'react'
2+
import { createBrowserRouter } from 'react-router-dom'
23

3-
const Home = lazy(() => import('./Home'))
4-
const Projects = lazy(() => import('./Projects'))
5-
const About = lazy(() => import('./About'))
4+
import App from './App'
5+
6+
const Home = lazy(() => import('./pages/Home'))
7+
const Projects = lazy(() => import('./pages/Projects'))
8+
const About = lazy(() => import('./pages/About'))
69

710
interface RouteDef {
811
path: string
@@ -11,7 +14,7 @@ interface RouteDef {
1114
nodeRef: RefObject<HTMLDivElement | null>
1215
}
1316

14-
const ROUTES: RouteDef[] = [
17+
export const ROUTES: RouteDef[] = [
1518
{
1619
path: '/',
1720
routeName: 'Home',
@@ -27,6 +30,19 @@ const ROUTES: RouteDef[] = [
2730
routeName: 'About',
2831
element: <About />,
2932
},
30-
].map((route) => Object.assign(route, { nodeRef: createRef<HTMLDivElement>() }))
33+
].map((route) => ({
34+
...route,
35+
nodeRef: createRef<HTMLDivElement>(),
36+
}))
3137

32-
export default ROUTES
38+
export const ROUTER = createBrowserRouter([
39+
{
40+
path: '/',
41+
element: <App />,
42+
children: ROUTES.map((route) => ({
43+
index: route.path === '/',
44+
path: route.path === '/' ? undefined : route.path,
45+
element: route.element,
46+
})),
47+
},
48+
])

src/index.tsx

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { StrictMode, Suspense } from 'react'
22
import { createRoot } from 'react-dom/client'
3-
import { RouterProvider, createBrowserRouter } from 'react-router-dom'
3+
import { RouterProvider } from 'react-router-dom'
44

5-
import App from './App'
65
import { Loading } from './components'
7-
import ROUTES from './ROUTES'
6+
import { ROUTER } from './routes'
87
import './index.scss'
98

109
const container = window.document.getElementById('root')
@@ -14,19 +13,7 @@ if (!container) {
1413
createRoot(container).render(
1514
<StrictMode>
1615
<Suspense fallback={<Loading />}>
17-
<RouterProvider
18-
router={createBrowserRouter([
19-
{
20-
path: '/',
21-
element: <App />,
22-
children: ROUTES.map((route) => ({
23-
index: route.path === '/',
24-
path: route.path === '/' ? undefined : route.path,
25-
element: route.element,
26-
})),
27-
},
28-
])}
29-
/>
16+
<RouterProvider router={ROUTER} />
3017
</Suspense>
3118
</StrictMode>,
3219
)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Header, Paragraph } from '../components'
1+
import { Header, Paragraph } from '../../components'
22

33
export default function About() {
44
return (
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Header } from '../components'
1+
import { Header } from '../../components'
22

33
export default function Home() {
44
return (
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { ReactNode } from 'react'
22

3-
import ExternalLink from '../components/ExternalLink'
4-
import Header from '../components/Header'
3+
import { ExternalLink, Header } from '../../components'
54

65
interface Props {
76
title: string
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@use "../common";
1+
@use "../../common";
22

33
.Projects {
44
.Project {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ExternalLink, Header, Paragraph } from '../components'
1+
import { ExternalLink, Header, Paragraph } from '../../components'
22

33
import ewitool from './ewitool.png'
44
import nftDemo from './nftDemo.png'

0 commit comments

Comments
 (0)