/
grid.tsx
72 lines (67 loc) · 2.6 KB
/
grid.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
69
70
71
72
import React from "react";
import { RootContainer, SEOContainer } from "~containers";
import { Main, Hero, Image, RadioGroup, RadioOption } from "~components";
export default function GridPage() {
const [state, setState] = React.useState({
layout: "exciting",
src: "https://source.unsplash.com/featured/400x600",
});
const handleChange: React.ChangeEventHandler<HTMLInputElement> = ({ target }) =>
setState((prevState) => ({ ...prevState, [target.name]: target.value }));
return (
<RootContainer>
<Main style={{ gridTemplate: '"hero" "controls" "grid"' }}>
<Hero
title="Your grid layout does not have to be boring, why don't you try thinking...you know...a little bit outside the box"
codeLink="https://github.com/mrozilla/mrozilla.cz/blob/master/src/pages/lab/grid.tsx"
/>
<section
style={{ gridArea: "controls", display: "grid", gridTemplateColumns: "repeat(4, 1fr)" }}
>
<RadioGroup name="layout" value={state.layout} label="Layout" onChange={handleChange}>
<RadioOption value="exciting" label="Exciting" />
<RadioOption value="boring" label="Boring" />
</RadioGroup>
<RadioGroup name="src" value={state.src} label="Images" onChange={handleChange}>
<RadioOption value="https://source.unsplash.com/featured/400x600" label="Real photos" />
<RadioOption value="broken.jpg" label="Placeholders" />
</RadioGroup>
</section>
<section style={{ gridArea: "grid" }}>
<ul
style={{
listStyle: "none",
display: "grid",
gap: "4rem 2rem",
gridTemplateColumns: "1fr 1fr",
}}
>
{["4rem 0 0 0", "0 8rem 0 0", "0 0 0 8rem", "6rem"].map((padding) => (
<li
key={padding}
style={{
padding: state.layout === "exciting" ? padding : "",
transition: "padding 250ms",
}}
>
<Image src={state.src} alt="a random photo" zoom={1.5} />
<p>What a great photo</p>
<p style={{ lineHeight: "2rem" }}>€4.99</p>
</li>
))}
</ul>
</section>
</Main>
</RootContainer>
);
}
export const Head = () => {
return (
<SEOContainer
title="Grid playground"
description="Your grid layout does not have to be boring, why don't you try thinking...you know...a little bit outside the box"
permalink="/lab/grid"
ogImage="/assets/og.png"
/>
);
};