/
Section.tsx
68 lines (60 loc) · 1.39 KB
/
Section.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import React, { ReactNode } from 'react';
import styled from 'styled-components';
import { Section } from 'react-scroll-section';
import { Heading } from 'rebass/styled-components';
import { Slide } from 'react-awesome-reveal';
import Link from './Link';
type ContainerProps = {
id: string;
children: ReactNode;
Background?: () => JSX.Element;
};
const Container = ({
id,
children,
Background = DefaultBackground,
}: ContainerProps) => (
<Section id={id} style={{ position: 'relative' }}>
<Background />
<SectionContainer>{children}</SectionContainer>
</Section>
);
type HeaderProps = {
name: string;
icon?: string;
label?: string;
};
const Header = ({ name, icon, label }: HeaderProps) => (
<Slide direction="left" triggerOnce>
<Heading color="text" mb={4}>
<Link selected>
{name}
{icon && (
<span role="img" aria-label={label} style={{ marginLeft: '10px' }}>
{icon}
</span>
)}
</Link>
</Heading>
</Slide>
);
const SectionContainer = styled.div`
min-height: 100vh;
min-width: 320px;
max-width: 1366px;
display: flex;
margin: auto;
flex: 0 1 auto;
flex-direction: column;
justify-content: center;
padding: 5em 1em;
scroll-behavior: smooth;
@media (max-width: 400px) {
padding: 2em 1em;
}
`;
const DefaultBackground = () => <div />;
export default {
Container,
Header,
};