Skip to content

Commit 60e2ba7

Browse files
author
Eugene
committed
add WidthLimiter component
1 parent 57dbc10 commit 60e2ba7

20 files changed

Lines changed: 204 additions & 65 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"react-dom": "^17.0.2",
1212
"react-router-dom": "^6.2.1",
1313
"react-scripts": "4.0.3",
14+
"react-slotify": "^0.1.7",
1415
"typescript": "^4.4.4"
1516
},
1617
"scripts": {

src/assets/images/icons/github.svg

Lines changed: 1 addition & 0 deletions
Loading

src/assets/scss/animations.scss

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
1-
@keyframes anim-appear {
2-
from {
3-
opacity: 0;
4-
transform: translateY(-32px);
5-
}
6-
to {
7-
opacity: 1;
8-
transform: translateY(0);
9-
}
10-
}
11-
121
@keyframes lds-dual-ring {
132
0% {
143
transform: rotate(0deg);

src/components/App/index.scss

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
@import "../../assets/scss/variables.scss";
22

33
.app {
4-
max-width: 632px;
5-
margin: 0 auto;
6-
display: flex;
7-
flex-direction: column;
8-
min-height: 100vh;
9-
justify-content: space-between;
10-
padding: 0 $size-lg;
4+
&__container {
5+
display: flex;
6+
flex-direction: column;
7+
min-height: 100vh;
8+
justify-content: space-between;
9+
}
10+
11+
&__page {
12+
flex: 1;
13+
}
1114
}

src/components/App/index.tsx

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,33 @@ import Footer from "../Footer";
77
import HomePage from "../../pages/HomePage";
88
import ProjectPage from "../../pages/ProjectPage";
99
import NotFoundPage from "../../pages/NotFoundPage";
10+
import WidthLimiter, { WidthLimiterSlot } from "../../components/WidthLimiter";
1011
import "./index.scss";
1112

1213
const App: FunctionComponent = () => {
1314
return (
1415
<div className="app">
15-
<Header />
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>
29-
<Footer />
16+
<WidthLimiter className="app__container">
17+
<WidthLimiterSlot>
18+
<Header />
19+
<div className="app__page">
20+
<Routes>
21+
<Route path="*" element={<NotFoundPage />} />
22+
<Route path="/" element={<HomePage />} />
23+
{MainConfig.projects.map((project, projectIndex) => {
24+
return (
25+
<Route
26+
key={projectIndex}
27+
path={project.href}
28+
element={<ProjectPage project={project} />}
29+
/>
30+
);
31+
})}
32+
</Routes>
33+
</div>
34+
<Footer />
35+
</WidthLimiterSlot>
36+
</WidthLimiter>
3037
</div>
3138
);
3239
};

src/components/Header/index.scss

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,18 @@
22

33
.header {
44
text-align: center;
5-
padding: 32px 0;
5+
padding: $size-xl 0;
66

77
&__logo {
88
font: 42px/150% Pacifico;
99
color: $accent-color;
10+
text-decoration: none;
11+
12+
&--link {
13+
&:hover {
14+
text-decoration: underline;
15+
}
16+
}
1017
}
1118

1219
&__links {

src/components/Header/index.tsx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,33 @@
1-
import "./index.scss";
21
import { FunctionComponent } from "react";
2+
import { useLocation } from "react-router-dom";
3+
import { Link as RouterLink } from "react-router-dom";
4+
5+
import MainConfig from "../../config/Main";
36
import Link from "../Link";
7+
import "./index.scss";
48

59
const Header: FunctionComponent = () => {
10+
const location = useLocation();
11+
12+
console.log(location);
13+
614
return (
715
<header className="header">
8-
<h1 className="header__logo">Module Art</h1>
16+
{location.pathname === "/" ? (
17+
<h1 className="header__logo">
18+
{MainConfig.title}
19+
</h1>
20+
) : (
21+
<RouterLink to="/" className="header__logo header__logo--link">
22+
{MainConfig.title}
23+
</RouterLink>
24+
)}
925
<ul className="header__links">
1026
<li className="header__link">
11-
<Link text="About" href="/about" internal />
27+
<Link text="GitHub" href="https://github.com/ModuleArt" />
1228
</li>
1329
<li className="header__link">
14-
<Link text="GitHub" href="https://github.com/ModuleArt" />
30+
<Link text="About" href="/about" internal />
1531
</li>
1632
</ul>
1733
</header>

src/components/Link/Props.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
interface Props {
2+
className?: string;
23
text: string;
34
href: string;
45
internal?: boolean;

src/components/Link/index.tsx

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,38 @@
1-
import "./index.scss";
21
import { FunctionComponent } from "react";
3-
import Props from "./Props";
42
import { Link as RouterLink } from "react-router-dom";
3+
import cn from "classnames";
4+
5+
import Props from "./Props";
6+
import "./index.scss";
57

6-
const Link: FunctionComponent<Props> = ({ text, href, internal = false }) => {
8+
const Link: FunctionComponent<Props> = ({
9+
className = "",
10+
text,
11+
href,
12+
internal = false,
13+
}) => {
714
if (internal) {
815
return (
9-
<RouterLink className="link link--internal" to={href}>
16+
<RouterLink
17+
className={cn({
18+
link: true,
19+
"link--internal": true,
20+
[className]: true,
21+
})}
22+
to={href}
23+
>
1024
{text}
1125
</RouterLink>
1226
);
1327
} else {
1428
return (
15-
<a className="link" href={href}>
29+
<a
30+
className={cn({
31+
link: true,
32+
[className]: true,
33+
})}
34+
href={href}
35+
>
1636
{text}
1737
</a>
1838
);

src/components/ProjectCard/Props.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Platform from "../../enums/Platform";
33
interface Props {
44
className: string;
55
title: string;
6-
href: string;
6+
href?: string;
77
image: string;
88
platform: Platform
99
}

0 commit comments

Comments
 (0)