This repository has been archived by the owner on Mar 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Layout.js
103 lines (93 loc) · 2.47 KB
/
Layout.js
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// @flow
import { invariant } from '@adeira/js';
import Head from 'next/head';
import * as React from 'react';
import sx from '@adeira/sx';
import { Heading } from '@adeira/sx-design';
import LayoutFooter from './LayoutFooter';
import LayoutNavigation from './LayoutNavigation';
type Props =
| {
+children: React.Node,
+title: React.Node,
+subtitle?: React.Node,
+withFullWidth?: boolean,
+withHiddenTitle?: false,
}
| {
+children: React.Node,
+title?: React.Node,
+subtitle?: React.Node,
+withFullWidth?: boolean,
+withHiddenTitle: true,
};
export default function Layout(props: Props): React.Node {
if (props.withHiddenTitle === true) {
invariant(props.title == null, 'Cannot use `title` together with `withHiddenTitle` property.');
invariant(
props.subtitle == null,
'Cannot use `subtitle` together with `withHiddenTitle` property.',
);
}
return (
<>
<Head>
<title>KOCHKA café · {props.title}</title>
</Head>
<div className={styles('wrapper')}>
<LayoutNavigation />
{props.withHiddenTitle === true ? null : (
<div className={styles('heading')}>
<Heading>{props.title}</Heading>
<div className={styles('subtitle')}>{props.subtitle}</div>
</div>
)}
<main id="main" className={styles('main', props.withFullWidth && 'mainFullWidth')}>
{props.children}
</main>
<footer className={styles('footer')}>
<LayoutFooter />
</footer>
</div>
</>
);
}
const styles = sx.create({
wrapper: {
padding: 0,
margin: 0,
},
main: {
color: 'rgba(var(--font-color-dark))',
maxWidth: '45rem',
margin: '0 auto',
minHeight: '40vh',
paddingTop: '5vw',
paddingBottom: '5vw',
},
mainFullWidth: {
maxWidth: '100%',
paddingLeft: 0,
paddingRight: 0,
},
heading: {
'display': 'flex',
'flexDirection': 'column',
'alignItems': 'center',
'paddingTop': '2rem',
'paddingBottom': '2rem',
'backgroundColor': 'rgba(var(--secondary-color))',
'backgroundImage': 'url(/plus-pattern.svg)',
'backgroundPosition': '15px 15px',
'backgroundSize': '20px',
'--sx-foreground': 'rgba(var(--font-color-light))', // overwrite SX Design colors
},
subtitle: {
color: 'lightgray',
},
footer: {
color: 'rgba(var(--font-color-dark))',
paddingLeft: '1rem',
paddingRight: '1rem',
},
});