This repository has been archived by the owner on Dec 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 45
/
examples.js
186 lines (167 loc) · 3.44 KB
/
examples.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/**
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import React from 'react';
import ReactDOM from 'react-dom';
import styled from 'styled-components';
import grid from '../src/grid';
const SquareFill = styled.div`
width: 100%;
height: 100%;
opacity: 0.3;
background-color: ${props => props.color || 'red'};
`
const Example = styled.div`
width: 300px;
height: 300px;
margin-top: 5px;
margin-bottom: 5px;
`
const GridOne = styled(grid`
1fr 50px 2fr
`)`
width: 300px;
height: 300px;
`
const ExampleOne = () => (
<Example>
<GridOne>
<SquareFill color="red"/>
<SquareFill color="green"/>
<SquareFill color="blue"/>
</GridOne>
</Example>
);
const GridTwo = styled(grid`
1fr
50px
2fr
`)`
height: 300px;
width: 300px;
`
const ExampleTwo = () => (
<Example>
<GridTwo>
<SquareFill color="red"/>
<SquareFill color="green"/>
<SquareFill color="blue"/>
</GridTwo>
</Example>
);
const PlaidGrid = styled(grid`
1fr 1fr 1fr 1fr 1fr
1fr A,H A,I A,J A,K A,L
1fr B,H B,I B,J B,K B,L
1fr C,H C,I C,J C,K C,L
1fr D,H D,I D,J D,K D,L
1fr E,H E,I E,J E,K E,L
`)`
height: 300px;
width: 300px;
`
const Plaid = () => (
<Example>
<PlaidGrid>
<SquareFill color="red"/>
<SquareFill color="blue"/>
<SquareFill color="red"/>
<SquareFill color="blue"/>
<SquareFill color="red"/>
<SquareFill color="blue"/>
<SquareFill color="red"/>
<SquareFill color="blue"/>
<SquareFill color="red"/>
<SquareFill color="blue"/>
</PlaidGrid>
</Example>
);
const Badge = styled.div`
width: 100%;
height: 100%;
border-radius: 50%;
background-color: red;
color: white;
display: flex;
justify-content: center;
align-items: center;
font-family: 'Roboto', sans-serif;
`
const Button = styled.div`
width: 100%;
height: 100%;
border: 1px solid black;
border-radius: 10px;
color: black;
display: flex;
justify-content: center;
align-items: center;
font-family: 'Roboto', sans-serif;
`
const ButtonGrid = styled(grid`
270px 10px 10px 10px
10px .. B B B
10px A A,B A,B B
10px A A,B A,B B
70px A A A ..
`)`
height: 300px;
width: 300px;
`
const BadgeButton = () => (
<Example>
<ButtonGrid>
<Button item="A">Some Button</Button>
<Badge item="B">1</Badge>
</ButtonGrid>
</Example>
)
const SpacerGrid = styled(grid`
25% 50% 25%
25% .. .. ..
50% .. A ..
25% .. .. ..
`)`
height: 300px;
width: 300px;
border: 1px solid black;
`
const Spacer = () => (
<Example>
<SpacerGrid>
<SquareFill color="red"/>
</SpacerGrid>
</Example>
)
ReactDOM.render(
<ExampleOne />,
document.getElementById('exampleOne')
);
ReactDOM.render(
<ExampleTwo />,
document.getElementById('exampleTwo')
);
ReactDOM.render(
<Plaid />,
document.getElementById('plaid')
);
ReactDOM.render(
<BadgeButton />,
document.getElementById('badgeButton')
);
ReactDOM.render(
<Spacer />,
document.getElementById('spacer')
);