-
Notifications
You must be signed in to change notification settings - Fork 172
/
sprig.js
282 lines (279 loc) · 8.77 KB
/
sprig.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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
import CardModel from './card-model'
import { Box, Flex, Grid, Image, Link, Text } from 'theme-ui'
import Buttons from './button'
import styled from '@emotion/styled'
import RelativeTime from 'react-relative-time'
/** @jsxImportSource theme-ui */
function Game({ game, gameImage, gameImage1, ...props }) {
return (
<Box
as="div"
sx={{
position: 'relative',
display: 'flex',
flexDirection: 'column',
width: '14rem',
background: 'rgba(54, 66, 85, 0.75)',
borderStyle: 'solid',
borderWidth: '4px',
boxSizing: 'border-box',
borderImageRepeat: 'stretch',
borderImageSlice: '3',
borderImageWidth: '3',
borderImageSource: `url('data:image/svg+xml;utf8,<?xml version="1.0" encoding="UTF-8" ?><svg version="1.1" width="8" height="8" xmlns="http://www.w3.org/2000/svg"><path d="M3 1 h1 v1 h-1 z M4 1 h1 v1 h-1 z M2 2 h1 v1 h-1 z M5 2 h1 v1 h-1 z M1 3 h1 v1 h-1 z M6 3 h1 v1 h-1 z M1 4 h1 v1 h-1 z M6 4 h1 v1 h-1 z M2 5 h1 v1 h-1 z M5 5 h1 v1 h-1 z M3 6 h1 v1 h-1 z M4 6 h1 v1 h-1 z" fill="rgb(118, 118, 143)" /></svg>')`,
borderImageOutset: '2',
boxShadow: '0 8px 8px rgba(0, 0, 0, 0.2)',
'&:hover': {
transform: 'scale(1.05)',
background: 'rgba(77, 90, 114, 0.8)'
}
}}
{...props}
>
<Box
as="a"
href={`https://editor.sprig.hackclub.com/?file=https://raw.githubusercontent.com/hackclub/sprig/main/games/${game?.filename}.js`}
target="_blank"
rel="noopener noreferrer"
sx={{
borderStyle: 'solid',
borderWidth: '4px',
padding: '0.6rem 0.6rem 0 0.6rem',
borderImageRepeat: 'stretch',
borderImageSlice: '3',
borderImageWidth: '3',
borderImageSource: `url('data:image/svg+xml;utf8,<?xml version="1.0" encoding="UTF-8" ?><svg version="1.1" width="8" height="8" xmlns="http://www.w3.org/2000/svg"><path d="M3 1 h1 v1 h-1 z M4 1 h1 v1 h-1 z M2 2 h1 v1 h-1 z M5 2 h1 v1 h-1 z M1 3 h1 v1 h-1 z M6 3 h1 v1 h-1 z M1 4 h1 v1 h-1 z M6 4 h1 v1 h-1 z M2 5 h1 v1 h-1 z M5 5 h1 v1 h-1 z M3 6 h1 v1 h-1 z M4 6 h1 v1 h-1 z" fill="rgb(167, 171, 185)" /></svg>')`,
borderImageOutset: '2',
height: '100%',
textDecoration: 'none'
}}
>
{/* <Box
sx={{
width: '100%',
height: '65%',
paddingBottom: 'calc(100%-8px)',
border: '4px solid rgb(118, 118, 143)',
margin: 0,
position: 'relative',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
background: 'white',
boxShadow: '0 4px 0px rgba(0, 0, 0, 0.1)',
'&:after': {
content: '""',
position: 'absolute',
top: 0,
height: '100%',
width: '8px',
backgroundImage:
'linear-gradient(rgb(167, 171, 185) 5px, rgb(167, 171, 185) 5px)',
backgroundSize: '8px 8px',
backgroundPosition: 'top center',
backgroundRepeat: 'no-repeat',
zIndex: 2,
left: 0
},
'&:before': {
content: '""',
position: 'absolute',
top: 0,
height: '100%',
width: '8px',
backgroundImage:
'linear-gradient(rgb(167, 171, 185) 5px, rgb(167, 171, 185) 5px)',
backgroundSize: '8px 8px',
backgroundPosition: 'bottom center',
backgroundRepeat: 'no-repeat',
zIndex: 2,
right: 0
}
}}
>
<img
src={gameImage || gameImage1}
alt="game preview"
sx={{
position: 'absolute',
top: 0,
bottom: 0,
left: 0,
objectFit: 'contain',
objectPosition: 'center',
imageRendering: 'pixelated',
width: '100%',
height: '100%',
margin: 0,
padding: 0,
background: 'white'
}}
/>
</Box> */}
<Box sx={{ display: 'flex', flex: '60% 40%', flexWrap: 'wrap' }}>
<Text
as="h3"
sx={{
textTransform: 'lowercase',
textOverflow: 'ellipsis',
width: '100%',
overflow: 'hidden',
color: 'white',
whiteSpace: 'nowrap',
margin: '0.8rem 0 0.8rem 0',
fontSize: '1.4rem',
fontWeight: '400',
my: 0,
lineHeight: '1.4rem'
}}
>
{game?.title}
</Text>
<Text
as="h4"
sx={{
fontWeight: '300',
fontSize: '1.1rem',
color: 'rgb(151, 166, 187)',
padding: 0,
textOverflow: 'ellipsis',
width: '100%',
overflow: 'hidden',
whiteSpace: 'nowrap',
mt: 0,
lineHeight: '1rem'
}}
>
by {game?.author}
</Text>
<Text
as="span"
sx={{
fontWeight: '300',
fontSize: '0.8rem',
color: 'snow',
padding: 0,
opacity: 0.3,
mb: 1
}}
>
<RelativeTime value={game['addedOn']} titleFormat="YYYY-MM-DD" />
</Text>
</Box>
</Box>
</Box>
)
}
export default function Sprig({ stars, game, gameImage, gameImage1 }) {
return (
<CardModel
github_link="https://github.com/hackclub/sprig/"
color="white"
stars={stars}
highlight="#FFDE4D"
sx={{ backgroundColor: '#0C0C16' }}
image="/home/sprig-bg.webp"
>
<Image
src="/home/sprig-logo.webp"
sx={{
width: ['150px', '180px', '220px'],
zIndex: 3,
position: 'relative',
fontSize: ['36px', 4, 5],
color: 'white'
}}
alt="Sprig"
/>
<Grid columns={[1, 2]}>
<Box>
<Text
as="p"
variant="subtitle"
sx={{ zIndex: 2, position: 'relative' }}
>
Draw, make music, and craft games in our web-based JavaScript game
editor, which has been used by 7k+ makers around the world.
</Text>
<Flex sx={{ flexDirection: 'column', mt: [3, 3, 4] }}>
<Buttons
content="click here to get started in our editor"
id="6"
icon="emoji"
link="https://editor.sprig.hackclub.com"
primary="#FFDE4D"
sx={{ color: 'black' }}
>
Build a Sprig game
</Buttons>
<Buttons
content="learn more on our github"
id="8"
link="https://github.com/hackclub/sprig"
>
Review games / build the engine
</Buttons>
<Buttons
// content="we're all hanging out in #sprig on Slack"
id="9"
icon="friend"
link="/slack"
>
Connect with other game devs
</Buttons>
</Flex>
</Box>
<Box sx={{ mt: [0, -4, -4] }}>
<Text
sx={{
fontStyle: 'italic',
fontSize: [1, '14px', '16px'],
position: 'relative'
}}
>
New from{' '}
<Link
href="https://sprig.hackclub.com/gallery"
sx={{ textDecoration: 'none', color: 'inherit' }}
>
the gallery
</Link>
...
</Text>
<Grid
columns={[1, 1, 1, 2]}
sx={{
// height: ['250px', '80%', '80%'],
ml: [0, 4, 0],
gap: '20px',
mt: [2, 0, 3],
ml: [1, 0, 0],
mb: [1, 0, 0],
width: ['100%', '90%', '90%']
}}
>
<Game
game={game[0]}
// gameImage={gameImage}
/>
<Game
game={game[1]}
// gameImage1={gameImage1}
sx={{ display: ['none', 'flex', 'flex'] }}
/>
<Game
game={game[2]}
// gameImage={gameImage}
sx={{ display: ['none', 'none', 'flex'] }}
/>
<Game
game={game[3]}
// gameImage1={gameImage1}
sx={{ display: ['none', 'none', 'none', 'flex'] }}
/>
</Grid>
</Box>
</Grid>
</CardModel>
)
}