Skip to content

Commit 2dc657e

Browse files
committed
redesign preparation: Rewrite to TypeScript, fetch Github stars
1 parent ab1e112 commit 2dc657e

27 files changed

+314
-162
lines changed
File renamed without changes.

components/container.js renamed to components/container.tsx

+9-17
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
11
import React from 'react';
22
import styled from 'styled-components';
33
import {motion, useReducedMotion} from 'framer-motion';
4-
import PropTypes from 'prop-types';
54

65
import Header from './header';
76
import Nav from './nav';
87
import NavLink from './navlink';
98

10-
const Wrapper = styled.div`
11-
display: flex;
12-
flex-direction: column;
13-
flex-wrap: wrap;
14-
margin: 0 auto 30px;
15-
padding-left: 3em;
16-
padding-right: 20px;
9+
interface Props {
10+
children: React.ReactNode;
11+
}
1712

18-
@media (min-width: 320px) and (max-width: 480px) {
19-
padding-left: 20px;
20-
}
13+
const Wrapper = styled.div`
14+
display: flex;
15+
flex-direction: column;
16+
flex-wrap: wrap;
2117
`;
2218

23-
const Container = props => {
19+
const Container = ({children}: Props): JSX.Element => {
2420
const shouldReduceMotion = useReducedMotion();
2521

2622
const config = {
@@ -51,13 +47,9 @@ const Container = props => {
5147
<NavLink title="Projects" href="/projects"/>
5248
<NavLink title="Contact" href="/contact"/>
5349
</Nav>
54-
{props.children}
50+
{children}
5551
</Wrapper>
5652
);
5753
};
5854

59-
Container.propTypes = {
60-
children: PropTypes.node.isRequired
61-
};
62-
6355
export default Container;
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import styled from 'styled-components';
22

3-
const Box = styled.details`
3+
const Details = styled.details`
44
cursor: pointer;
55
`;
66

7-
export default Box;
7+
export default Details;
File renamed without changes.
File renamed without changes.

components/mail.js renamed to components/mail.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const shake = keyframes`
1616
}
1717
`;
1818

19+
/* eslint-disable @typescript-eslint/no-base-to-string */
1920
const Animated = styled.div`
2021
&:hover {
2122
animation: ${shake} 0.82s cubic-bezier(.36,.07,.19,.97) both;
@@ -24,6 +25,7 @@ const Animated = styled.div`
2425
perspective: 1000px;
2526
}
2627
`;
28+
/* eslint-enable @typescript-eslint/no-base-to-string */
2729

2830
const Wrapper = styled.a`
2931
text-align: center;
@@ -32,7 +34,7 @@ const Wrapper = styled.a`
3234
font-size: 25px;
3335
`;
3436

35-
const Mail = () => (
37+
const Mail = (): JSX.Element => (
3638
<Animated>
3739
<Wrapper href="mailto:a@kepinski.me">
3840
a@kepinski.me

components/main.js renamed to components/main.ts

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ const Main = styled.main`
44
display: flex;
55
align-items: flex-start;
66
flex-wrap: wrap;
7+
8+
@media (min-width: 320px) and (max-width: 480px) {
9+
align-items: center;
10+
justify-content: center;
11+
}
712
`;
813

914
export default Main;

components/me.js renamed to components/me.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@ import imagePlaceholder from '../public/images/me-placeholder.svg';
99
const Wrapper = styled.div`
1010
border: 10px solid #212121;
1111
transform: rotate(2deg);
12+
margin-bottom: 1em;
1213
`;
1314

14-
const Me = () => (
15+
const Me = (): JSX.Element => (
1516
<Tilt>
1617
<Wrapper>
18+
{/*
19+
// @ts-ignore */}
1720
<SimpleImg src={imageSrc} placeholder={imagePlaceholder} draggable={false} width="18em" height="auto" alt="Me"/>
1821
</Wrapper>
1922
</Tilt>
File renamed without changes.

components/navlink.js renamed to components/navlink.tsx

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import React from 'react';
22
import Link from 'next/link';
33
import styled from 'styled-components';
4-
import PropTypes from 'prop-types';
4+
5+
interface Props {
6+
title: string;
7+
href: string;
8+
}
59

610
const Wrapper = styled.a`
711
color: #fafff7;
@@ -19,16 +23,10 @@ const Wrapper = styled.a`
1923
}
2024
`;
2125

22-
const NavLink = ({title, href}) => (
26+
const NavLink = ({title, href}: Props): JSX.Element => (
2327
<Link scroll={false} href={href}>
24-
{/* eslint-disable-next-line react/jsx-no-comment-textnodes */}
2528
<Wrapper>//{title}</Wrapper>
2629
</Link>
2730
);
2831

29-
NavLink.propTypes = {
30-
title: PropTypes.string.isRequired,
31-
href: PropTypes.string.isRequired
32-
};
33-
3432
export default NavLink;

components/projects/data.json

+37-30
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,37 @@
11
[
2+
{
3+
"id": "node-fetch",
4+
"name": "Node Fetch",
5+
"description": "A light-weight module that brings window.fetch to Node.js",
6+
"url": "https://github.com/node-fetch/node-fetch",
7+
"tags": [
8+
"Node.js"
9+
]
10+
},
11+
{
12+
"id": "oji",
13+
"name": "Oji",
14+
"description": "Easily create text emoticons from your terminal",
15+
"url": "https://github.com/xxczaki/oji",
16+
"tags": [
17+
"CLI",
18+
"Node.js"
19+
]
20+
},
221
{
22+
"id": "pizzaql",
323
"name": "PizzaQL",
4-
"description": "Modern order placement & management system for pizza restaurants.",
24+
"description": "Modern order placement & management system for pizza restaurants",
525
"url": "https://github.com/xxczaki/pizzaql",
626
"tags": [
727
"React",
828
"Next.js",
929
"GraphQL",
1030
"Prisma"
1131
]
12-
},
13-
{
14-
"name": "Quick Air",
15-
"description": "Check air quality near you quickly, using Airly API.",
16-
"url": "https://quick-air.now.sh",
17-
"tags": [
18-
"React",
19-
"Next.js"
20-
]
2132
},
2233
{
23-
"name": "Welding Toolbox 2",
24-
"description": "An app containing a set of useful welding tools, written in React Native",
25-
"url": "https://play.google.com/store/apps/details?id=me.kepinski.weldingtoolbox2",
26-
"tags": [
27-
"React Native"
28-
]
29-
},
30-
{
31-
"name": "Cash CLI",
32-
"description": "Convert currency rates directly from your terminal!",
33-
"url": "https://github.com/xxczaki/cash-cli/",
34-
"tags": [
35-
"CLI",
36-
"Node.js"
37-
]
38-
},
39-
{
34+
"id": "cashify",
4035
"name": "Cashify",
4136
"description": "Lightweight currency conversion library, successor of money.js",
4237
"url": "https://github.com/xxczaki/cashify",
@@ -46,9 +41,21 @@
4641
]
4742
},
4843
{
49-
"name": "odc",
50-
"description": "Update npm dependencies easily!",
51-
"url": "https://github.com/xxczaki/odc",
44+
"id": "styled-react-boilerplate",
45+
"name": "Styled Boilerplate",
46+
"description": "Minimal & modern boilerplate for building apps with React & styled-components",
47+
"url": "https://github.com/xxczaki/styled-react-boilerplate",
48+
"tags": [
49+
"React",
50+
"Styled Components",
51+
"Webpack"
52+
]
53+
},
54+
{
55+
"id": "cash-cli",
56+
"name": "Cash CLI",
57+
"description": "Convert currency rates directly from your terminal",
58+
"url": "https://github.com/xxczaki/cash-cli/",
5259
"tags": [
5360
"CLI",
5461
"Node.js"

components/projects/index.js renamed to components/projects/index.tsx

+47-23
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,43 @@ import React from 'react';
22
import styled from 'styled-components';
33
import {SimpleImg} from 'react-simple-img';
44

5+
import {Response} from '../../utils/fetcher';
6+
57
import imageSrc from '../../public/images/open.svg';
68
import data from './data.json';
79

10+
interface Props {
11+
stars: Response | undefined;
12+
}
13+
14+
interface Project {
15+
id: string;
16+
name: string;
17+
description: string;
18+
url: string;
19+
tags: string[];
20+
}
21+
822
const Wrapper = styled.div`
923
display: grid;
1024
grid-template-columns: repeat(auto-fill, minmax(20em, 1fr));
1125
gap: 17px;
1226
padding-top: 2em;
27+
max-width: 70em;
28+
29+
@media (min-width: 320px) and (max-width: 480px) {
30+
max-width: 100%;
31+
}
1332
`;
1433

1534
const Element = styled.a`
16-
box-shadow: #212121 0px 10px 30px -15px;
35+
box-shadow: #232527 0px 10px 30px -15px;
1736
display: flex;
1837
justify-content: space-between;
1938
flex-direction: column;
2039
align-items: flex-start;
2140
position: relative;
22-
background-color: #212121;
41+
background-color: #232527;
2342
padding: 2rem 1.75rem;
2443
border-radius: 3px;
2544
transition: all 0.25s cubic-bezier(0.645, 0.045, 0.355, 1) 0s;
@@ -74,28 +93,33 @@ const Tag = styled.li`
7493
margin-right: 15px;
7594
`;
7695

77-
const Projects = () => (
96+
const Projects = ({stars}: Props): JSX.Element => (
7897
<Wrapper>
79-
{data.map(element => (
80-
<Element key={element.name} href={element.url} target="_blank" rel="noopener noreferrer">
81-
<header>
82-
<Top>
83-
<Header>{element.name}</Header>
84-
<Img src={imageSrc} placeholder="black" width="1.3em" height="1.3em" alt="Open"/>
85-
</Top>
86-
<Description>
87-
{element.description}
88-
</Description>
89-
</header>
90-
<footer>
91-
<Tags>
92-
{element.tags.map(name => (
93-
<Tag key={name}>{name}</Tag>
94-
))}
95-
</Tags>
96-
</footer>
97-
</Element>
98-
))}
98+
{data.map((element: Project) => {
99+
const starCount = stars?.repositoryOwner.repositories.nodes.filter(data => element.id === data.name).map(element => element.stargazers.totalCount);
100+
101+
return (
102+
<Element key={element.name} href={element.url} target="_blank" rel="noopener noreferrer">
103+
<header>
104+
<Top>
105+
<Header>{element.name}</Header>
106+
<Img src={imageSrc} placeholder="black" width="1.3em" height="1.3em" alt="Open"/>
107+
</Top>
108+
{stars ? <p>🟊 {starCount}</p> : ''}
109+
<Description>
110+
{element.description}
111+
</Description>
112+
</header>
113+
<footer>
114+
<Tags>
115+
{element.tags.map(name => (
116+
<Tag key={name}>{name}</Tag>
117+
))}
118+
</Tags>
119+
</footer>
120+
</Element>
121+
);
122+
})}
99123
</Wrapper>
100124
);
101125

components/skills.js renamed to components/skills.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const Element = styled.li`
2727
}
2828
`;
2929

30-
const Skills = () => (
30+
const Skills = (): JSX.Element => (
3131
<List>
3232
<Element>JavaScript (ES6+)</Element>
3333
<Element>React</Element>
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import React from 'react';
22
import {AnimatePresence, motion, useReducedMotion} from 'framer-motion';
3-
import PropTypes from 'prop-types';
43

5-
const Transition = props => {
4+
interface Props {
5+
children: React.ReactNode;
6+
id: string;
7+
}
8+
9+
const Transition = ({children, id}: Props) => {
610
const shouldReduceMotion = useReducedMotion();
711

812
const spring = {
@@ -16,23 +20,17 @@ const Transition = props => {
1620
<AnimatePresence exitBeforeEnter>
1721
<div className="page-transition-wrapper">
1822
<motion.div
19-
key={props.id}
23+
key={id}
2024
transition={spring}
21-
initial={shouldReduceMotion ? {opacity: 0} : {x: 300, opacity: 0}}
22-
animate={shouldReduceMotion ? {opacity: 1} : {x: 0, opacity: 1}}
23-
exit={shouldReduceMotion ? {opacity: 0} : {x: -300, opacity: 0}}
25+
initial={shouldReduceMotion ? {opacity: 0} : {y: 100, opacity: 0}}
26+
animate={shouldReduceMotion ? {opacity: 1} : {y: 0, opacity: 1}}
2427
id="page-transition-container"
2528
>
26-
{props.children}
29+
{children}
2730
</motion.div>
2831
</div>
2932
</AnimatePresence>
3033
);
3134
};
3235

33-
Transition.propTypes = {
34-
children: PropTypes.node.isRequired,
35-
id: PropTypes.string.isRequired
36-
};
37-
3836
export default Transition;

next-env.d.ts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/// <reference types="next" />
2+
/// <reference types="next/types/global" />
3+
4+
declare module '*.woff';
5+
declare module '*.woff2';
6+
declare module '*.jpg';
7+
declare module '*.svg';

0 commit comments

Comments
 (0)