Skip to content

Commit 9d817d9

Browse files
committed
Create first workable system
React components, templates, layouts and pages added
1 parent e520ea1 commit 9d817d9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+4545
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
declare module 'gatsby-plugin-google-analytics' {
2+
let OutboundLink: (props: any) => JSX.Element;
3+
export { OutboundLink };
4+
}

src/@types/mdx.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
declare module '@mdx-js/react' {
2+
let MDXProvider: (props: any) => JSX.Element;
3+
export { MDXProvider };
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
declare module 'react-anchor-link-smooth-scroll' {
2+
let AnchorLink: (props: any) => JSX.Element;
3+
export default AnchorLink;
4+
}

src/@types/react-typist.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
declare module 'react-typist';

src/components/Button/Button.tsx

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
import { ReactNode } from 'react';
2+
import { motion } from 'framer-motion';
3+
import styled from '../../utils/styled';
4+
import React from 'react';
5+
interface ButtonProps {
6+
primary?: boolean;
7+
secondary?: boolean;
8+
tertiary?: boolean;
9+
white?: boolean;
10+
danger?: boolean;
11+
disabled?: boolean;
12+
children: ReactNode;
13+
onClick?: () => any;
14+
}
15+
16+
const StyledButton = styled(motion.button)<ButtonProps>`
17+
height: 48px;
18+
margin: 0;
19+
border: none;
20+
cursor: pointer;
21+
display: inline-flex;
22+
justify-content: center;
23+
align-items: center;
24+
position: relative;
25+
font-weight: 600;
26+
outline: none;
27+
padding: 0 30px;
28+
border-radius: 4px;
29+
30+
${(p) =>
31+
p.primary
32+
? `
33+
background-color: ${p.theme.colors.blue};
34+
color: ${p.theme.colors.white};
35+
min-width: 150px;
36+
37+
${
38+
p.danger
39+
? `
40+
background-color: ${p.theme.colors.red};
41+
`
42+
: ''
43+
}
44+
45+
${
46+
p.disabled
47+
? `
48+
cursor: not-allowed;
49+
opacity: 0.5;
50+
background-color: ${p.theme.colors.gray};
51+
color: #000000;
52+
&:hover {
53+
transform: none;
54+
}
55+
`
56+
: ''
57+
}
58+
59+
`
60+
: ''};
61+
62+
${(p) =>
63+
p.secondary
64+
? `
65+
background-color: transparent;
66+
color: ${p.theme.colors.blue};
67+
border: 2px solid ${p.theme.colors.blue};
68+
min-width: 150px;
69+
70+
${
71+
p.danger
72+
? `
73+
color: ${p.theme.colors.red};
74+
border-color: ${p.theme.colors.red};
75+
`
76+
: ''
77+
}
78+
79+
${
80+
p.disabled
81+
? `
82+
cursor: not-allowed;
83+
opacity: 0.5;
84+
color: ${p.theme.colors.gray};
85+
border-color: ${p.theme.colors.gray};
86+
&:hover {
87+
transform: none;
88+
}
89+
`
90+
: ''
91+
}
92+
93+
`
94+
: ''};
95+
96+
${(p) =>
97+
p.tertiary
98+
? `
99+
background-color: transparent;
100+
color: ${p.theme.colors.blue};
101+
min-width: inherited;
102+
padding: 0px;
103+
104+
::after {
105+
content: '';
106+
display: block;
107+
position: absolute;
108+
top: 96%;
109+
left: 0;
110+
right: 0;
111+
height: 2px;
112+
background-color: ${p.theme.colors.blue};
113+
transform: scaleX(0);
114+
transition: transform 0.25s ease-in;
115+
transform-origin: right center;
116+
text-decoration: none;
117+
}
118+
119+
&:hover::after {
120+
transform: scale(1);
121+
transform-origin: left center;
122+
}
123+
124+
${
125+
p.danger
126+
? `
127+
color: ${p.theme.colors.red};
128+
::after {
129+
background-color: ${p.theme.colors.red};
130+
}
131+
`
132+
: ''
133+
}
134+
135+
${
136+
p.disabled
137+
? `
138+
opacity: 0.5;
139+
cursor: not-allowed;
140+
color: ${p.theme.colors.gray};
141+
::after {
142+
background-color: ${p.theme.colors.gray};
143+
}
144+
`
145+
: ''
146+
}
147+
`
148+
: ''};
149+
`;
150+
151+
const Button = React.forwardRef(
152+
({ children, ...props }: ButtonProps, ref: React.Ref<HTMLButtonElement>) => {
153+
return (
154+
<StyledButton
155+
whileHover={props.tertiary ? {} : { scale: 0.85 }}
156+
transition={{ duration: 0.1 }}
157+
ref={ref}
158+
{...props}
159+
>
160+
{children}
161+
</StyledButton>
162+
);
163+
}
164+
);
165+
166+
Button.displayName = 'Button';
167+
168+
export { Button };

src/components/Button/LinkButton.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import styled from '../../utils/styled';
2+
3+
const LinkButton = styled('button')`
4+
border-radius: 4px;
5+
padding: 4px 10px;
6+
width: 100%;
7+
height: 40px;
8+
cursor: pointer;
9+
border: none;
10+
background-color: transparent;
11+
outline: none;
12+
transition: 0.4s;
13+
14+
> * {
15+
margin-left: auto;
16+
margin-right: auto;
17+
}
18+
19+
&:hover {
20+
background-color: ${(p) => p.theme.foregroundColor};
21+
}
22+
`;
23+
24+
export { LinkButton };
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { cleanup, render } from '@testing-library/react';
2+
import { ThemeProvider } from 'emotion-theming';
3+
import 'jest-dom/extend-expect';
4+
import React from 'react';
5+
import Button from '../';
6+
import theme from '../../../theme';
7+
8+
describe('Button', () => {
9+
beforeEach(cleanup);
10+
11+
it('renders the primary button', () => {
12+
const component = render(
13+
<ThemeProvider theme={theme.light}>
14+
<Button primary={true}>Test</Button>
15+
</ThemeProvider>
16+
);
17+
expect(component.baseElement).toMatchSnapshot();
18+
});
19+
20+
it('renders the secondary button', () => {
21+
const component = render(
22+
<ThemeProvider theme={theme.light}>
23+
<Button secondary={true}>Test</Button>
24+
</ThemeProvider>
25+
);
26+
expect(component.baseElement).toMatchSnapshot();
27+
});
28+
29+
it('renders the tertiary button', () => {
30+
const component = render(
31+
<ThemeProvider theme={theme.light}>
32+
<Button tertiary={true}>Test</Button>
33+
</ThemeProvider>
34+
);
35+
expect(component.baseElement).toMatchSnapshot();
36+
});
37+
});

0 commit comments

Comments
 (0)