-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
502 lines (497 loc) · 18.6 KB
/
index.html
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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link rel="icon" href="https://alpinejs.dev/favicon.png"/>
<title>Hyper</title>
<meta name="title" content="Hyper"/>
<meta name="description" content="Frontend-template that helps quickly start projects from scratch"/>
<meta name="keywords" content="front-end responsive utility-classes grid-layout responsive-design frontend-template tailwindcss alpinejs animate-css front-end-template"/>
<meta name="author" content="Ray Chang"/>
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website"/>
<meta property="og:url" content="https://create-alpine-app.netlify.app/intro/"/>
<meta property="og:title" content="Hyper"/>
<meta property="og:description" content="Frontend-template that helps quickly start projects from scratch"/>
<meta property="og:image" content="https://opengraph.githubassets.com/2469fa99cf18457e00fdde599b67f77cc3ff11f3195f336bef9e8b6ae314659d/rayc2045/create-alpine-app"/>
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image"/>
<meta property="twitter:url" content="https://create-alpine-app.netlify.app/intro/"/>
<meta property="twitter:title" content="Hyper"/>
<meta property="twitter:description" content="Frontend-template that helps quickly start projects from scratch"/>
<meta property="twitter:image" content="https://opengraph.githubassets.com/2469fa99cf18457e00fdde599b67f77cc3ff11f3195f336bef9e8b6ae314659d/rayc2045/create-alpine-app"/>
<!-- Noto Sans TC -->
<link rel="preconnect" href="https://fonts.googleapis.com"/>
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin/>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Noto+Sans+TC:400,500,700,900&display=swap"/>
<!-- Libraries -->
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="./src/style.css"/>
<script src="./src/app.js" defer></script>
<script src="https://cdn.jsdelivr.net/npm/@imacrayon/[email protected]/dist/cdn.min.js" defer></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/cdn.min.js" defer></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/purify.min.js" defer></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/gsap.min.js" defer></script>
</head>
<body
x-data="{ BRAND_NAME, prefer, idxDB, ...style, ...utils, overlay, sideMenu, router, shop, cart, user }"
x-init="await shop.loadProducts(); await cart.init();"
class="min-h-dvh flex flex-col tracking-wide bg-gray-100"
:class="overlay.isShow && 'overflow-hidden'"
@dragstart.prevent
>
<nav
class="sticky bg-inherit border-b border-gray-300 z-[1]"
x-data="{
lastScrollTop: 0,
get newScrollTop() {
return document.documentElement.scrollTop;
}
}"
@scroll.document="
setStyle($el, newScrollTop < lastScrollTop
? { top: '0', transition: 'top .5s' }
: { top: '-100vh', transition: 'top 1s' }
);
lastScrollTop = newScrollTop <= 0 ? 0 : newScrollTop;
"
>
<div class="max-w-screen-lg 2xl:max-w-screen-xl mx-auto px-6 md:pl-8 py-2 flex items-center gap-x-2 md:gap-x-4">
<button
class="p-2 md:hidden"
x-html="svg('menu')"
@click="overlay.show(); sideMenu.show()"
></button>
<a
href="#/"
class="py-2 font-bold text-lg text-gray-900"
x-text="BRAND_NAME"
></a>
<ul class="hidden md:flex items-center gap-4 text-sm">
<li>
<a :class="a.nav" href="#/shop"> Shop </a>
</li>
<li>
<div
class="relative"
x-data="{ open: false }"
@mouseleave="open = false"
@scroll.document="open = false"
>
<button
class="inline-flex py-2 items-center hover:text-gray-500 transition"
@click="open = !open"
@click.outside="open = false"
@mouseenter="open = true"
>
Pages
<span
x-html="svg('arrow-down')"
:class="[open && '-rotate-180', prefer.motion && 'transition duration-300']"
></span>
</button>
<div
x-cloak
x-show="open"
x-transition.origin.top.left
class="absolute p-2 min-w-48 max-h-[80dvh] overflow-y-auto whitespace-nowrap rounded-lg bg-gray-100 border border-gray-200 shadow-md"
role="menu"
>
<template x-for="route in router.routes">
<a
:href="`#${route.path.includes(':') ? route.path.split('/').map(p => p.startsWith(':') ? 'dynamic-route' : p).join('/') : route.path}`"
x-text="route.component.split('/').at(-1).split('.html')[0].split('-').map(str => capitalizeFirstLetter(str)).join(' ')"
class="block px-4 py-2 text-sm rounded-lg hover:bg-gray-200"
role="menuitem"
></a>
</template>
</div>
</div>
</li>
<li>
<a :class="a.nav" href="#/posts"> Blog </a>
</li>
<li>
<a :class="a.nav" href="#/about"> About </a>
</li>
</ul>
<div
class="hidden md:flex ml-auto max-w-60 relative"
x-data="{ open: false }"
@scroll.document="select('input', $el).blur()"
>
<label for="search" class="sr-only">Search</label>
<input
id="search"
type="text"
placeholder="Search"
x-model="shop.searchText"
class="w-full pl-2.5 pr-10 py-2.5 sm:text-sm rounded-md bg-inherit border-gray-300 shadow"
@focus="open = true"
@click.outside="open = false"
@scroll.window="open = false"
/>
<span class="absolute inset-y-0 end-0 grid w-10 place-content-center">
<button type="button" class="text-gray-600 hover:text-gray-700">
<span class="sr-only">Search</span>
<span x-html="svg('search')"></span>
</button>
</span>
<div
x-cloak
x-show="open && shop.searchResult.length"
class="absolute top-14 w-72 rounded-lg bg-gray-100 border border-gray-200 shadow-lg"
>
<ul class="p-2 max-h-64 overflow-y-auto space-y-1">
<template
x-for="product in shop.searchResult"
:key="product.name"
>
<li>
<a
class="flex items-center justify-between rounded-md px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-200 focus:bg-gray-50"
:href="`#/shop/${product.category}/${product.name.toLowerCase().replaceAll(' ', '_')}`"
>
<span x-text="product.name"></span>
<span
class="px-1.5 py-0.5 text-xs text-white rounded bg-gray-700"
x-text="product.category"
></span>
</a>
</li>
</template>
</ul>
</div>
</div>
<a
x-show="!user.isLoggedIn"
href="#/login"
class="ml-auto md:ml-0 p-2"
x-html="svg('user')"
></a>
<a
x-cloak
x-show="user.isLoggedIn"
href="#/account"
class="ml-auto md:ml-0"
>
<img
:src="user.profile.avatar"
alt="avatar"
class="size-6 rounded-full object-cover"
/>
</a>
<a
href="#/cart"
x-html="svg('cart')"
x-data="{
get num() {
return cart.items.reduce((acc, cur) => acc + cur.num, 0);
}
}"
class="p-2 relative after:absolute after:rounded-full after:flex after:justify-center after:items-center after:text-xs after:text-gray-100 after:bg-red-600"
:class="`${!num && 'after:hidden'} after:content-['${num}'] after:size-${num >= 100 ? 6 : num >= 10 ? 5 : 4} ${num >= 100 ? 'after:-right-1.5 after:-top-1.5' : num >= 10 ? 'after:-right-0.5 after:-top-0.5' : 'after:right-0 after:top-0'}`"
></a>
</div>
</nav>
<div
id="overlay"
x-cloak
x-show="overlay.isShow"
x-transition.opacity.duration.300ms
class="fixed left-0 top-0 w-full h-full bg-zinc-600/50 z-[1]"
></div>
<aside
id="side-menu"
class="block fixed w-full max-w-80 h-dvh flex flex-col justify-between bg-inherit border-r border-2 shadow-xl select-none z-[1]"
style="display: none"
x-show="sideMenu.isShow"
x-transition:enter="transition ease-gentle duration-300"
x-transition:enter-start="-translate-x-full"
x-transition:enter-end="translate-x-0"
x-transition:leave="transition ease-gentle duration-300"
x-transition:leave-start="translate-x-0"
x-transition:leave-end="-translate-x-full"
@click.outside="sideMenu.hide(); overlay.hide();"
@resize.window="sideMenu.hide(); overlay.hide();"
>
<section class="px-6 py-2 flex gap-x-2 bg-gray-100 border-b border-gray-300">
<button
class="p-2"
x-html="svg('menu')"
@click="sideMenu.hide(); overlay.hide();"
></button>
<a
href="#/"
class="py-2 font-bold text-lg text-gray-900"
x-text="BRAND_NAME"
></a>
</section>
<section class="flex-1 p-4 overflow-y-auto">
<ul class="space-y-1">
<li>
<a
:class="router.currentPath === $el.href.split('#')[1] ? a.sideMenuActive : a.sideMenu"
href="#/"
>
Home
</a>
</li>
<li>
<a
:class="router.currentPath === $el.href.split('#')[1] ? a.sideMenuActive : a.sideMenu"
href="#/shop"
>
Shop
</a>
</li>
<li>
<a
:class="router.currentPath === $el.href.split('#')[1] ? a.sideMenuActive : a.sideMenu"
href="#/posts"
>
Blog
</a>
</li>
</ul>
<hr class="my-4" />
<ul>
<li>
<div x-data="{ open: false }">
<button
class="px-4 py-2 w-full flex items-center text-sm font-medium hover:bg-gray-200 rounded-lg cursor-pointer"
:class="open && 'text-gray-500'"
@click="open = !open"
>
Pages
<span x-html="svg('arrow-down')" class="ml-auto"></span>
</button>
<ul
x-cloak
x-show="open"
x-transition.origin.top
class="mt-2 px-4 space-y-1"
role="menu"
>
<template x-for="route in router.routes">
<li>
<a
:href="`#${route.path.includes(':') ? route.path.split('/').map(p => p.startsWith(':') ? 'dynamic-route' : p).join('/') : route.path}`"
x-text="route.component.split('/').at(-1).split('.html')[0].split('-').map(str => capitalizeFirstLetter(str)).join(' ')"
:class="a.sideMenu"
role="menuitem"
></a>
</li>
</template>
</ul>
</div>
</li>
</ul>
<hr class="my-4" />
<ul class="space-y-1">
<li>
<a
:class="router.currentPath === $el.href.split('#')[1] ? a.sideMenuActive : a.sideMenu"
href="#/about"
>
About
</a>
</li>
<li>
<a
:class="router.currentPath === $el.href.split('#')[1] ? a.sideMenuActive : a.sideMenu"
href="#/contact"
>
Contact Us
</a>
</li>
<li>
<a
:class="router.currentPath === $el.href.split('#')[1] ? a.sideMenuActive : a.sideMenu"
href="#/faq"
>
Faq
</a>
</li>
<li>
<a
:class="router.currentPath === $el.href.split('#')[1] ? a.sideMenuActive : a.sideMenu"
href="#/order-tracking"
>
Order Tracking
</a>
</li>
</ul>
</section>
<section class="p-4 bg-inherit border-t border-gray-200">
<a
x-show="!user.isLoggedIn"
href="#/login"
class="p-4 flex items-center gap-2 text-sm font-medium bg-gray-200 rounded-lg"
>
<span x-html="svg('log-in')"></span>Log in
</a>
<a
x-cloak
x-show="user.isLoggedIn"
href="#/account"
class="p-4 flex items-center gap-2 bg-gray-200 rounded-lg"
>
<img
:src="user.profile.avatar"
alt="avatar"
class="size-10 rounded-full object-cover"
/>
<div>
<p class="text-xs">
<strong
class="block font-medium"
x-text="user.profile.name"
></strong>
<span x-text="user.profile.email"></span>
</p>
</div>
</a>
</section>
</aside>
<section id="announcement" class="bg-gray-200 border-b border-gray-300">
<div class="mx-auto max-w-screen-lg 2xl:max-w-screen-xl px-4 sm:px-6 flex text-sm font-medium">
<a
href="https://github.com/rayc2045/Hyper"
rel="noreferrer"
target="_blank"
class="w-full flex justify-center items-center gap-2 hover:opacity-75 transition"
>
<span x-text="`Enjoy ${BRAND_NAME}? Give it a star on GitHub`"></span>
<span aria-hidden="true" role="img">🎉</span>
</a>
<button
aria-label="Close"
class="p-2 mr-1 text-gray-500"
@click="$el.closest('section').remove()"
>
✕
</button>
</div>
</section>
<main
class="flex-1"
x-init="await router.init()"
@hashchange.window="sideMenu.hide(); overlay.hide(); await scrollToTop(); router.updatePath(); router.renderPage();"
>
<div class="max-w-screen-lg 2xl:max-w-screen-xl mx-auto px-4 sm:px-8 py-12">
<h1
x-show="router.currentRoute.title"
x-text="router.currentRoute.title"
class="mb-12 text-4xl font-bold"
></h1>
<div id="router-view" class="space-y-12"></div>
</div>
</main>
<footer class="border-t border-gray-300">
<div class="max-w-screen-lg 2xl:max-w-screen-xl mx-auto px-4 sm:px-8 py-8 lg:py-12">
<aside class="grid gap-y-8 lg:grid-cols-5">
<section class="lg:col-span-3">
<h4
class="font-medium text-xl text-gray-900 transition"
x-text="BRAND_NAME"
></h4>
<p class="mt-3 max-w-lg text-balance text-pretty leading-relaxed text-gray-700">
A store for people that want to buy less, but better. We offer a unique collection of high end items for every home.
</p>
<ul class="mt-5 flex gap-4 text-lg text-gray-800">
<li>
<a
href="https://www.instagram.com/"
target="_blank"
rel="noopener noreferrer"
x-html="svg('instagram')"
></a>
</li>
<li>
<a
href="https://twitter.com/"
target="_blank"
rel="noopener noreferrer"
x-html="svg('twitter')"
></a>
</li>
<li>
<a
href="https://www.facebook.com/"
target="_blank"
rel="noopener noreferrer"
x-html="svg('facebook')"
></a>
</li>
</ul>
</section>
<div class="grid gap-y-8 sm:flex sm:gap-x-20 lg:col-span-2 lg:gap-x-32">
<section>
<h4 class="mb-4 font-medium">Quick Links</h4>
<ul class="space-y-1">
<li><a :class="a.footer" href="#/about">About</a></li>
<li><a :class="a.footer" href="#/account">My acount</a></li>
<li><a :class="a.footer" href="#/account">My orders</a></li>
</ul>
</section>
<section>
<h4 class="mb-4 font-medium">Customer Care</h4>
<ul class="space-y-1">
<li><a :class="a.footer" href="#/contact">Contact us</a></li>
<li><a :class="a.footer" href="#/faq">FAQs</a></li>
</ul>
</section>
</div>
</aside>
<hr class="mt-6 lg:mt-12 mb-6" />
<div class="lg:flex lg:items-end lg:justify-between tracking-wider">
<ul class="hidden lg:flex gap-4">
<li>
<a class="text-sm text-gray-900 hover:underline" href="#/about">
About
</a>
</li>
<li>
<a class="text-sm text-gray-900 hover:underline" href="#/contact">
Contact Us
</a>
</li>
<li>
<a class="text-sm text-gray-900 hover:underline" href="#/faq">
FAQ
</a>
</li>
<li>
<a
class="text-sm text-gray-900 hover:underline"
href="#/order-tracking"
>
Order Tracking
</a>
</li>
</ul>
<p class="mt-4 text-sm text-gray-700 lg:mt-0">
© <span x-text="new Date().getFullYear()"></span> Created by
<a
href="https://github.com/rayc2045"
target="_blank"
rel="noreferrer"
class="text-gray-900 hover:underline"
>
Ray C
</a>
</p>
</div>
</div>
</footer>
<span
id="breakpoint"
class="fixed right-6 bottom-6 text-xl text-[indianred] font-bold pointer-events-none"
x-text="getBreakpointName()"
@resize.window="$el.textContent = getBreakpointName()"
></span>
</body>
</html>