Skip to content

Commit 57dbc10

Browse files
author
Eugene
committed
integrate react-router-dom
1 parent 4b8da20 commit 57dbc10

21 files changed

Lines changed: 181 additions & 47 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"node-sass": "4.14.1",
1010
"react": "^17.0.2",
1111
"react-dom": "^17.0.2",
12+
"react-router-dom": "^6.2.1",
1213
"react-scripts": "4.0.3",
1314
"typescript": "^4.4.4"
1415
},

public/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
work correctly both with client-side routing and a non-root public URL.
2525
Learn how to configure a non-root public URL by running `npm run build`.
2626
-->
27-
<title>React App</title>
27+
<title>Module Art</title>
2828
</head>
2929
<body>
3030
<noscript>You need to enable JavaScript to run this app.</noscript>

src/assets/scss/variables.scss

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
1-
// colors
2-
$accent-color-pale: #EDC9FD;
3-
$accent-color: #AA14F0;
1+
// color
2+
$accent-color: #0070f3;
3+
$accent-color-mid: #a7cefb;
4+
$accent-color-pale: #dfedfe;
45
$second-color: #aaa;
56

6-
// durations
7+
// duration
78
$transition-duration: 0.25s;
89
$animation-duration: 0.5s;
910

10-
//opacity
11+
// opacity
1112
$disabled-opacity: 0.5;
13+
14+
// size
15+
$size-sm: 4px; // small
16+
$size-md: 8px; // medium
17+
$size-lg: 16px; // large
18+
$size-xl: 32px; // extra large
19+
20+
// shadow
21+
$shadow-md: 0 4px 8px 0 rgba(0, 0, 0, 0.1); // medium
22+
$shadow-lg: 0 8px 16px 0 rgba(0, 0, 0, 0.2); // large
23+

src/components/App/index.scss

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
@import "../../assets/scss/variables.scss";
2+
13
.app {
24
max-width: 632px;
35
margin: 0 auto;
46
display: flex;
57
flex-direction: column;
68
min-height: 100vh;
79
justify-content: space-between;
8-
padding: 0 16px;
9-
}
10+
padding: 0 $size-lg;
11+
}

src/components/App/index.tsx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,31 @@
1+
import { FunctionComponent } from "react";
2+
import { Routes, Route } from "react-router-dom";
3+
4+
import MainConfig from "../../config/Main";
15
import Header from "../Header";
2-
import ProjectList from "../ProjectsList";
36
import Footer from "../Footer";
4-
import { FunctionComponent } from "react";
7+
import HomePage from "../../pages/HomePage";
8+
import ProjectPage from "../../pages/ProjectPage";
9+
import NotFoundPage from "../../pages/NotFoundPage";
510
import "./index.scss";
6-
import MainConfig from "../../config/Main";
711

812
const App: FunctionComponent = () => {
913
return (
1014
<div className="app">
1115
<Header />
12-
<ProjectList projects={MainConfig.projects} />
16+
<Routes>
17+
<Route path="*" element={<NotFoundPage />} />
18+
<Route path="/" element={<HomePage />} />
19+
{MainConfig.projects.map((project, projectIndex) => {
20+
return (
21+
<Route
22+
key={projectIndex}
23+
path="/quick-picture-viewer"
24+
element={<ProjectPage project={project} />}
25+
/>
26+
);
27+
})}
28+
</Routes>
1329
<Footer />
1430
</div>
1531
);

src/components/Footer/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const Footer: FunctionComponent = () => {
55
return (
66
<footer className="footer">
77
<span className="footer__copyright">
8-
Copyright © 2021 Connection Beats. All rights reserved.
8+
Copyright © 2022 Module Art. All rights reserved.
99
</span>
1010
</footer>
1111
);

src/components/Header/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ const Header: FunctionComponent = () => {
88
<h1 className="header__logo">Module Art</h1>
99
<ul className="header__links">
1010
<li className="header__link">
11-
<Link text="Quick Picture Viewer" href="" />
11+
<Link text="About" href="/about" internal />
1212
</li>
1313
<li className="header__link">
14-
<Link text="GitHub" href="" />
14+
<Link text="GitHub" href="https://github.com/ModuleArt" />
1515
</li>
1616
</ul>
1717
</header>

src/components/Link/Props.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
interface Props {
22
text: string;
33
href: string;
4+
internal?: boolean;
45
}
56

67
export default Props;

src/components/Link/index.scss

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,20 @@
99
&::before {
1010
content: "";
1111
position: absolute;
12-
top: 100%;
12+
top: 50%;
1313
left: 0;
14-
width: 0;
15-
height: 2px;
16-
background: $accent-color;
17-
transition: width $animation-duration;
14+
width: 100%;
15+
height: 0;
16+
background: $accent-color-pale;
17+
transition: height $transition-duration, top $transition-duration;;
18+
z-index: -1;
19+
border-radius: $size-md;
1820
}
1921

2022
&:hover {
2123
&::before {
22-
width: 100%;
24+
top: 0;
25+
height: 100%;
2326
}
2427
}
2528
}

src/components/Link/index.tsx

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
import "./index.scss";
22
import { FunctionComponent } from "react";
33
import Props from "./Props";
4+
import { Link as RouterLink } from "react-router-dom";
45

5-
const Link: FunctionComponent<Props> = ({ text, href }) => {
6-
return (
7-
<a className="link" href={href}>
8-
{text}
9-
</a>
10-
);
6+
const Link: FunctionComponent<Props> = ({ text, href, internal = false }) => {
7+
if (internal) {
8+
return (
9+
<RouterLink className="link link--internal" to={href}>
10+
{text}
11+
</RouterLink>
12+
);
13+
} else {
14+
return (
15+
<a className="link" href={href}>
16+
{text}
17+
</a>
18+
);
19+
}
1120
};
1221

1322
export default Link;

0 commit comments

Comments
 (0)