@xingwangzhe/stalux 1.21.2 → 1.21.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -2
- package/src/components/stalux/layout/navs.astro +18 -12
- package/src/i18n/en.json +1 -0
- package/src/i18n/zh-CN.json +1 -0
- package/src/pages/index.astro +1 -1
- package/src/styles/components/layout/navs.module.css +33 -23
- package/src/styles/components/links/socialLinks.module.css +11 -0
- package/src/styles/pages/home.module.css +10 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xingwangzhe/stalux",
|
|
3
|
-
"version": "1.21.
|
|
3
|
+
"version": "1.21.5",
|
|
4
4
|
"description": "A powerful, modern Astro blog theme — use as template or install as plugin",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"astro",
|
|
@@ -84,7 +84,6 @@
|
|
|
84
84
|
"@waline/client": "^3.15.2",
|
|
85
85
|
"@xingwangzhe/satteri-mermaid": "0.7.3",
|
|
86
86
|
"@xingwangzhe/satteri-photoswipe": "^0.2.2",
|
|
87
|
-
"@xingwangzhe/stalux": "1.21.0",
|
|
88
87
|
"@xingwangzhe/tags-cloud": "^1.2.5",
|
|
89
88
|
"animejs": "^4.5.0",
|
|
90
89
|
"astro-expressive-code": "^0.44.1",
|
|
@@ -15,7 +15,7 @@ const { t } = createTranslator(siteConfig.lang || "zh-CN");
|
|
|
15
15
|
const navs = navsConfig?.items ?? [];
|
|
16
16
|
---
|
|
17
17
|
|
|
18
|
-
<nav aria-label="
|
|
18
|
+
<nav aria-label={t("nav.main")} transition:persist-props>
|
|
19
19
|
<!-- 汉堡菜单按钮 (仅窄屏显示) -->
|
|
20
20
|
<button
|
|
21
21
|
data-ref="stalux-nav-toggle"
|
|
@@ -140,17 +140,20 @@ const navs = navsConfig?.items ?? [];
|
|
|
140
140
|
if (!navList || !btnLeft || !btnRight) return;
|
|
141
141
|
|
|
142
142
|
function updateButtons() {
|
|
143
|
-
const
|
|
144
|
-
const
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
143
|
+
const navWidth = navList.clientWidth;
|
|
144
|
+
const itemCount = navList.children.length;
|
|
145
|
+
const baseFontSize = Number.parseFloat(getComputedStyle(navList).fontSize) || 16;
|
|
146
|
+
const minFontSize = 12;
|
|
147
|
+
const gap = Number.parseFloat(getComputedStyle(navList).gap) || 0;
|
|
148
|
+
const estimatedWidth = [...navList.children].reduce(
|
|
149
|
+
(total, item) => total + item.getBoundingClientRect().width,
|
|
150
|
+
0,
|
|
151
|
+
) + gap * Math.max(0, itemCount - 1);
|
|
152
|
+
const scale = estimatedWidth > navWidth ? Math.max(minFontSize / baseFontSize, navWidth / estimatedWidth) : 1;
|
|
153
|
+
navList.style.setProperty("--nav-scale", String(scale));
|
|
154
|
+
navList.removeAttribute("data-overflow");
|
|
155
|
+
btnLeft.removeAttribute("data-visible");
|
|
156
|
+
btnRight.removeAttribute("data-visible");
|
|
154
157
|
}
|
|
155
158
|
|
|
156
159
|
btnLeft.addEventListener("click", () => {
|
|
@@ -167,6 +170,9 @@ const navs = navsConfig?.items ?? [];
|
|
|
167
170
|
// 用 ResizeObserver 监听容器尺寸变化(窗口缩窄/变宽时重新判断)
|
|
168
171
|
const ro = new ResizeObserver(updateButtons);
|
|
169
172
|
ro.observe(navList);
|
|
173
|
+
if (navList.parentElement) ro.observe(navList.parentElement);
|
|
174
|
+
window.addEventListener("resize", updateButtons, { passive: true });
|
|
175
|
+
window.addEventListener("load", updateButtons, { once: true });
|
|
170
176
|
|
|
171
177
|
// 初始检测
|
|
172
178
|
updateButtons();
|
package/src/i18n/en.json
CHANGED
package/src/i18n/zh-CN.json
CHANGED
package/src/pages/index.astro
CHANGED
|
@@ -19,10 +19,10 @@ import { getSiteData, getAuthorData, getHeadData, getNavsData, getLinksData, get
|
|
|
19
19
|
|
|
20
20
|
<Stalux title={siteTitle} description={siteDescription} fontSubsetId="home">
|
|
21
21
|
<div class={styles.homeBody}>
|
|
22
|
-
<h1 class={styles.homeTitle}>{siteTitle}</h1>
|
|
23
22
|
<div class={styles.homeNavs}>
|
|
24
23
|
<Navs />
|
|
25
24
|
</div>
|
|
25
|
+
<h1 class={styles.homeTitle}>{siteTitle}</h1>
|
|
26
26
|
<h2 class="sr-only" style="position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;">{t("ai.about")}</h2>
|
|
27
27
|
<Author />
|
|
28
28
|
<TextType />
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
/* 导航容器 — 相对定位,为滚动按钮提供锚点 */
|
|
2
|
+
nav {
|
|
3
|
+
width: 100%;
|
|
4
|
+
min-width: 0;
|
|
5
|
+
max-width: 100%;
|
|
6
|
+
}
|
|
7
|
+
|
|
2
8
|
.navContainer {
|
|
3
9
|
position: relative;
|
|
4
10
|
width: 100%;
|
|
11
|
+
min-width: 0;
|
|
5
12
|
max-width: 100%;
|
|
6
13
|
overflow: hidden;
|
|
14
|
+
box-sizing: border-box;
|
|
7
15
|
}
|
|
8
16
|
|
|
9
17
|
.navList {
|
|
@@ -11,22 +19,22 @@
|
|
|
11
19
|
gap: 2rem;
|
|
12
20
|
align-items: center;
|
|
13
21
|
justify-content: center;
|
|
22
|
+
transform: scale(var(--nav-scale, 1));
|
|
23
|
+
transform-origin: center;
|
|
24
|
+
min-width: 0;
|
|
25
|
+
max-width: 100%;
|
|
26
|
+
box-sizing: border-box;
|
|
14
27
|
transition: transform 0.3s ease;
|
|
15
28
|
/* 当导航项总宽度超过视口时允许横向滚动,防止右侧项被裁剪 */
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
scrollbar-width: none;
|
|
21
|
-
-ms-overflow-style: none;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.navList::-webkit-scrollbar {
|
|
25
|
-
display: none;
|
|
29
|
+
flex-wrap: wrap;
|
|
30
|
+
width: 100%;
|
|
31
|
+
overflow: visible;
|
|
32
|
+
justify-content: center;
|
|
26
33
|
}
|
|
27
34
|
|
|
28
35
|
/* 滚动按钮 — 仅当内容溢出时显示 */
|
|
29
36
|
.scrollBtn {
|
|
37
|
+
display: none;
|
|
30
38
|
position: absolute;
|
|
31
39
|
top: 50%;
|
|
32
40
|
transform: translateY(-50%);
|
|
@@ -39,7 +47,6 @@
|
|
|
39
47
|
backdrop-filter: blur(8px);
|
|
40
48
|
color: var(--white-full);
|
|
41
49
|
cursor: pointer;
|
|
42
|
-
display: flex;
|
|
43
50
|
align-items: center;
|
|
44
51
|
justify-content: center;
|
|
45
52
|
opacity: 0;
|
|
@@ -53,7 +60,7 @@
|
|
|
53
60
|
background: var(--black-50p);
|
|
54
61
|
}
|
|
55
62
|
|
|
56
|
-
.scrollBtn
|
|
63
|
+
.scrollBtn[data-visible] {
|
|
57
64
|
opacity: 1;
|
|
58
65
|
pointer-events: auto;
|
|
59
66
|
}
|
|
@@ -67,7 +74,7 @@
|
|
|
67
74
|
}
|
|
68
75
|
|
|
69
76
|
/* 导航容器 hover 时显示滚动按钮 */
|
|
70
|
-
.navContainer:hover .scrollBtn
|
|
77
|
+
.navContainer:hover .scrollBtn[data-visible] {
|
|
71
78
|
opacity: 1;
|
|
72
79
|
}
|
|
73
80
|
|
|
@@ -173,20 +180,16 @@
|
|
|
173
180
|
}
|
|
174
181
|
}
|
|
175
182
|
|
|
176
|
-
/*
|
|
183
|
+
/* 中小屏幕:保留文字,通过横向滚动展示完整导航 */
|
|
177
184
|
@media (max-width: 900px) {
|
|
178
|
-
.navText {
|
|
179
|
-
display: none;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
185
|
.navItem {
|
|
183
|
-
font-size:
|
|
184
|
-
margin-right: 0.
|
|
185
|
-
margin-left: 0.
|
|
186
|
+
font-size: 0.95em;
|
|
187
|
+
margin-right: 0.25em;
|
|
188
|
+
margin-left: 0.25em;
|
|
186
189
|
}
|
|
187
190
|
|
|
188
191
|
.navList {
|
|
189
|
-
gap: 0.
|
|
192
|
+
gap: 0.5rem;
|
|
190
193
|
}
|
|
191
194
|
}
|
|
192
195
|
|
|
@@ -194,17 +197,24 @@
|
|
|
194
197
|
@media (max-width: 600px) {
|
|
195
198
|
.navToggle {
|
|
196
199
|
display: block;
|
|
200
|
+
position: fixed;
|
|
201
|
+
top: 0.75rem;
|
|
202
|
+
left: 0.75rem;
|
|
197
203
|
}
|
|
198
204
|
|
|
199
205
|
.navContainer {
|
|
200
206
|
overflow: visible;
|
|
201
207
|
}
|
|
202
208
|
|
|
209
|
+
nav {
|
|
210
|
+
width: auto;
|
|
211
|
+
}
|
|
212
|
+
|
|
203
213
|
.navList {
|
|
204
214
|
position: fixed;
|
|
205
215
|
top: 0;
|
|
206
216
|
right: 0;
|
|
207
|
-
width: 220px;
|
|
217
|
+
width: min(220px, calc(100vw - 1rem));
|
|
208
218
|
height: 100vh;
|
|
209
219
|
background: var(--black-20p);
|
|
210
220
|
backdrop-filter: blur(20px);
|
|
@@ -13,10 +13,21 @@
|
|
|
13
13
|
display: inline-flex;
|
|
14
14
|
align-items: center;
|
|
15
15
|
justify-content: center;
|
|
16
|
+
text-align: center;
|
|
16
17
|
border-radius: 50%;
|
|
17
18
|
background-color: var(--white-15p);
|
|
18
19
|
box-sizing: border-box;
|
|
19
20
|
overflow: hidden;
|
|
20
21
|
}
|
|
22
|
+
a,
|
|
23
|
+
.icon-container,
|
|
24
|
+
.custom-icon {
|
|
25
|
+
display: inline-flex;
|
|
26
|
+
align-items: center;
|
|
27
|
+
justify-content: center;
|
|
28
|
+
width: 100%;
|
|
29
|
+
height: 100%;
|
|
30
|
+
line-height: 1;
|
|
31
|
+
}
|
|
21
32
|
}
|
|
22
33
|
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
align-items: center;
|
|
5
5
|
min-height: 100vh;
|
|
6
6
|
padding-bottom: var(--space-3xl);
|
|
7
|
+
position: relative;
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
.homeTitle {
|
|
@@ -16,6 +17,11 @@
|
|
|
16
17
|
|
|
17
18
|
.homeNavs {
|
|
18
19
|
display: flex;
|
|
20
|
+
width: 100%;
|
|
21
|
+
order: -1;
|
|
22
|
+
min-width: 0;
|
|
23
|
+
max-width: 100%;
|
|
24
|
+
justify-content: center;
|
|
19
25
|
}
|
|
20
26
|
|
|
21
27
|
#showPostList {
|
|
@@ -44,6 +50,10 @@
|
|
|
44
50
|
align-items: center;
|
|
45
51
|
gap: 0.5em;
|
|
46
52
|
}
|
|
53
|
+
|
|
54
|
+
.homeNavs :global(nav) {
|
|
55
|
+
width: 100%;
|
|
56
|
+
}
|
|
47
57
|
#showPostList {
|
|
48
58
|
margin-top: 2em;
|
|
49
59
|
font-size: 1.1em;
|