@xingwangzhe/stalux 1.21.3 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xingwangzhe/stalux",
3
- "version": "1.21.3",
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",
@@ -140,17 +140,20 @@ const navs = navsConfig?.items ?? [];
140
140
  if (!navList || !btnLeft || !btnRight) return;
141
141
 
142
142
  function updateButtons() {
143
- const maxScrollLeft = Math.max(0, navList.scrollWidth - navList.clientWidth);
144
- const hasOverflow = maxScrollLeft > 4;
145
- const scrollLeft = Math.min(Math.max(navList.scrollLeft, 0), maxScrollLeft);
146
-
147
- if (navList.scrollLeft !== scrollLeft) {
148
- navList.scrollLeft = scrollLeft;
149
- }
150
-
151
- navList.toggleAttribute("data-overflow", hasOverflow);
152
- btnLeft.classList.toggle("visible", hasOverflow && scrollLeft > 4);
153
- btnRight.classList.toggle("visible", hasOverflow && scrollLeft < maxScrollLeft - 4);
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", () => {
@@ -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,4 +1,10 @@
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%;
@@ -13,30 +19,22 @@
13
19
  gap: 2rem;
14
20
  align-items: center;
15
21
  justify-content: center;
22
+ transform: scale(var(--nav-scale, 1));
23
+ transform-origin: center;
16
24
  min-width: 0;
17
25
  max-width: 100%;
18
26
  box-sizing: border-box;
19
27
  transition: transform 0.3s ease;
20
28
  /* 当导航项总宽度超过视口时允许横向滚动,防止右侧项被裁剪 */
21
- overflow-x: auto;
22
- scroll-behavior: smooth;
23
- -webkit-overflow-scrolling: touch;
24
- /* 隐藏滚动条但保留滚动功能 */
25
- scrollbar-width: none;
26
- -ms-overflow-style: none;
27
- }
28
-
29
- .navList[data-overflow] {
30
- justify-content: flex-start;
31
- padding-inline: 44px;
32
- }
33
-
34
- .navList::-webkit-scrollbar {
35
- display: none;
29
+ flex-wrap: wrap;
30
+ width: 100%;
31
+ overflow: visible;
32
+ justify-content: center;
36
33
  }
37
34
 
38
35
  /* 滚动按钮 — 仅当内容溢出时显示 */
39
36
  .scrollBtn {
37
+ display: none;
40
38
  position: absolute;
41
39
  top: 50%;
42
40
  transform: translateY(-50%);
@@ -49,7 +47,6 @@
49
47
  backdrop-filter: blur(8px);
50
48
  color: var(--white-full);
51
49
  cursor: pointer;
52
- display: flex;
53
50
  align-items: center;
54
51
  justify-content: center;
55
52
  opacity: 0;
@@ -63,7 +60,7 @@
63
60
  background: var(--black-50p);
64
61
  }
65
62
 
66
- .scrollBtn.visible {
63
+ .scrollBtn[data-visible] {
67
64
  opacity: 1;
68
65
  pointer-events: auto;
69
66
  }
@@ -77,7 +74,7 @@
77
74
  }
78
75
 
79
76
  /* 导航容器 hover 时显示滚动按钮 */
80
- .navContainer:hover .scrollBtn.visible {
77
+ .navContainer:hover .scrollBtn[data-visible] {
81
78
  opacity: 1;
82
79
  }
83
80
 
@@ -183,20 +180,16 @@
183
180
  }
184
181
  }
185
182
 
186
- /* 较窄屏幕:隐藏文字,只显示图标 */
183
+ /* 中小屏幕:保留文字,通过横向滚动展示完整导航 */
187
184
  @media (max-width: 900px) {
188
- .navText {
189
- display: none;
190
- }
191
-
192
185
  .navItem {
193
- font-size: 1em;
194
- margin-right: 0.5em;
195
- margin-left: 0.5em;
186
+ font-size: 0.95em;
187
+ margin-right: 0.25em;
188
+ margin-left: 0.25em;
196
189
  }
197
190
 
198
191
  .navList {
199
- gap: 0.75rem;
192
+ gap: 0.5rem;
200
193
  }
201
194
  }
202
195
 
@@ -204,12 +197,19 @@
204
197
  @media (max-width: 600px) {
205
198
  .navToggle {
206
199
  display: block;
200
+ position: fixed;
201
+ top: 0.75rem;
202
+ left: 0.75rem;
207
203
  }
208
204
 
209
205
  .navContainer {
210
206
  overflow: visible;
211
207
  }
212
208
 
209
+ nav {
210
+ width: auto;
211
+ }
212
+
213
213
  .navList {
214
214
  position: fixed;
215
215
  top: 0;
@@ -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;