-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
135 lines (120 loc) · 4.52 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>CSS projects by wendko</title>
<link href="style.css" rel="stylesheet">
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🍕</text></svg>">
</head>
<body>
<header>
<h1>wendko's CSS projects</h1>
<ul id="socials" class="socials"></ul>
<br/>
<script type='text/javascript' src='https://ko-fi.com/widgets/widget_2.js'></script>
<script type='text/javascript'>kofiwidget2.init('Support Me on Ko-fi', '#c01690', 'H2H31LGQ1');kofiwidget2.draw();</script>
</header>
<main>
<div id="collection"></div>
</main>
<script type="module">
import { html, render } from 'https://unpkg.com/htm/preact/standalone.module.js';
// data
const collection = [
'tortoise-loader',
'unown-sprites',
'gsap-penguin',
'bunny-blowing-bubbles',
'mask',
'edamame-loader',
'single-div-pokemon-sprites',
'single-div-pikachu',
'pufferfish',
'deno',
'structural-pseudocats',
'sakura',
'nihongo-ref',
'nihongo-practise',
'css-named-beach',
'css-named-colors',
'snake',
'cny-lion-2020',
'inktober-2019',
'drink-more-water',
'durian-radio',
'toggle-day-night',
'durian-react',
'durian',
'tapir',
'awkward-pikachu',
'background-gradient',
'avatar',
'100-dots',
'async-defer',
'KLCC',
'dancing-macaron',
'box-shadow-sketch',
'css-masonry',
'dad-joke',
'dev-doctor',
'emoji-selector',
'fruit-veggies-spectrum',
'gameboy-color',
'gravity-planets',
'kl-react-centered',
'kl-react-right',
'slack',
];
const drafts = [
'pokemon-badges',
'async-defer-anim',
'google',
'malaysian-states',
'mamak',
]
const socials = [
{ link: 'https://codepen.io/wendko', label: 'codepen' },
{ link: 'https://twitter.com/wendko', label: 'twitter' },
{ link: 'https://github.com/wendko/codepen', label: 'github' },
{ link: 'https://wendko.com', label: 'about' },
]
const getLink = (item) => {
const currentUrl = window.location.href;
return currentUrl.match('/index.html') ? currentUrl.replace('/index.html', `/pens/${item}/index.html`)
: `${currentUrl}/pens/${item}`;
}
const dekebab = (item) => {
if (!item) return ''
return item
.split('-')
.map(x => `${x.charAt(0).toUpperCase()}${x.slice(1)}`)
.join(' ');
}
const assetsPath = './assets/preview-images';
const PenItem = (item) => html`
<a class="pen__link" href="${getLink(item)}">
<figure class="pen__container">
<video loop muted playsinline class="pen__preview"
onmouseleave=${(e) => e.target.pause()}
onmouseover=${(e) => e.target.play()}>
<source src="${assetsPath}/${item}.webm" type="video/webm" />
<source src="${assetsPath}/${item}.mp4" type="video/mp4" />
</video>
<figcaption class="pen__caption">${dekebab(item)}</figcaption>
</figure>
</a>
`
const PenList = (collection) => html`<ol class="pens__list">
${collection.map(item => html`<li class="pen__list-item">${PenItem(item)}</li>`)}
</ol>`;
const renderCollectionHtml = PenList(collection);
render(renderCollectionHtml, document.getElementById('collection'));
const renderSocialsHtml = socials.map(s => html`<li class="socials__list-item">
<a class="socials__link" href="${s.link}">${s.label}</a>
</li>`);
render(renderSocialsHtml, document.getElementById('socials'));
</script>
</body>
</html>