Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
116 lines (112 loc) · 5.02 KB
/
Copy pathindex.html
File metadata and controls
116 lines (112 loc) · 5.02 KB
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
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>大糖的表情包</title>
<meta name="description" content="群里收来的表情包,随手翻。">
<link rel="icon" href="thumbs/动画表情-c71a456f.webp">
<style>
:root{--bg:#fbf8f3;--ink:#2d2a26;--muted:#857b71;--line:#eae3d9;--accent:#d98a6a}
*{box-sizing:border-box}
body{margin:0;background:var(--bg);color:var(--ink);
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans CJK SC","Source Han Sans SC","Microsoft YaHei",sans-serif;
-webkit-font-smoothing:antialiased}
header{position:sticky;top:0;z-index:5;background:rgba(251,248,243,.94);backdrop-filter:blur(6px);
border-bottom:1px solid var(--line)}
.bar{max-width:1120px;margin:0 auto;padding:14px 18px;display:flex;align-items:baseline;gap:14px;flex-wrap:wrap}
h1{font-size:18px;margin:0;letter-spacing:.5px}
.count{color:var(--muted);font-size:13px}
.note{margin-left:auto;color:var(--muted);font-size:12.5px}
.note a{color:inherit}
main{max-width:1120px;margin:0 auto;padding:18px 18px 60px}
.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(132px,1fr));gap:8px}
.cell{position:relative;background:#fff;border:1px solid var(--line);border-radius:10px;overflow:hidden;
aspect-ratio:1/1;cursor:zoom-in;transition:transform .12s,box-shadow .12s}
.cell img{width:100%;height:100%;object-fit:contain;display:block;background:#fff}
.cell:hover{transform:translateY(-1px);box-shadow:0 6px 18px rgba(120,100,80,.12)}
footer{border-top:1px solid var(--line);padding:22px 18px 40px;text-align:center;color:var(--muted);font-size:12.5px}
/* lightbox */
.lb{position:fixed;inset:0;background:rgba(30,26,22,.86);display:none;align-items:center;justify-content:center;z-index:20}
.lb.on{display:flex}
.lb img{max-width:88vw;max-height:78vh;border-radius:12px;background:#fff}
.lb .meta{position:absolute;bottom:18px;color:#e8e0d6;font-size:13px}
.lb button{position:absolute;background:rgba(255,255,255,.14);color:#fff;border:none;border-radius:50%;
width:44px;height:44px;font-size:20px;cursor:pointer}
.lb button:hover{background:rgba(255,255,255,.28)}
.lb .prev{left:16px;top:50%;transform:translateY(-50%)}
.lb .next{right:16px;top:50%;transform:translateY(-50%)}
.lb .close{right:16px;top:16px;width:38px;height:38px;font-size:18px}
</style>
</head>
<body>
<header>
<div class="bar">
<h1>大糖的表情包</h1>
<span class="count" id="count">载入中…</span>
<span class="note">都是群里攒的 · <a href="https://luarobot.github.io/">回到博客</a></span>
</div>
</header>
<main>
<div class="grid" id="grid"></div>
</main>
<footer>图是群友的,我只是收着玩 · 每天自动更新一次</footer>
<div class="lb" id="lb">
<button class="close" id="lbclose" aria-label="关闭">✕</button>
<button class="prev" id="lbprev" aria-label="上一张">‹</button>
<button class="next" id="lbnext" aria-label="下一张">›</button>
<img id="lbimg" alt="">
<div class="meta" id="lbmeta"></div>
</div>
<script>
(async function(){
const res = await fetch('index.json', {cache:'no-cache'});
const data = await res.json();
const items = data.items;
document.getElementById('count').textContent = items.length + ' 张';
const grid = document.getElementById('grid');
const frag = document.createDocumentFragment();
items.forEach(function(it, i){
const a = document.createElement('div');
a.className = 'cell';
a.dataset.i = i;
a.title = it.kb + ' KB';
const img = document.createElement('img');
img.loading = 'lazy';
img.src = 'thumbs/' + encodeURIComponent(it.f);
img.alt = '';
img.width = it.w; img.height = it.h;
a.appendChild(img);
frag.appendChild(a);
});
grid.appendChild(frag);
const lb = document.getElementById('lb');
const lbimg = document.getElementById('lbimg');
const lbmeta = document.getElementById('lbmeta');
let cur = 0;
function show(i){
cur = (i + items.length) % items.length;
const it = items[cur];
lbimg.src = 'thumbs/' + encodeURIComponent(it.f);
lbmeta.textContent = (cur + 1) + ' / ' + items.length + ' · ' + it.w + '×' + it.h + ' · ' + it.kb + ' KB';
}
grid.addEventListener('click', function(e){
const cell = e.target.closest('.cell');
if (!cell) return;
show(parseInt(cell.dataset.i, 10));
lb.classList.add('on');
});
document.getElementById('lbclose').onclick = function(){ lb.classList.remove('on'); };
document.getElementById('lbprev').onclick = function(e){ e.stopPropagation(); show(cur - 1); };
document.getElementById('lbnext').onclick = function(e){ e.stopPropagation(); show(cur + 1); };
lb.onclick = function(e){ if (e.target === lb) lb.classList.remove('on'); };
document.addEventListener('keydown', function(e){
if (!lb.classList.contains('on')) return;
if (e.key === 'Escape') lb.classList.remove('on');
if (e.key === 'ArrowLeft') show(cur - 1);
if (e.key === 'ArrowRight') show(cur + 1);
});
})();
</script>
</body>
</html>