starlight-theme-bejamas 0.1.15 → 0.1.16

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # starlight-theme-bejamas
2
2
 
3
+ ## 0.1.16
4
+
5
+ ### Patch Changes
6
+
7
+ - [#78](https://github.com/bejamas/ui/pull/78) [`a2d6526`](https://github.com/bejamas/ui/commit/a2d6526f3c6e205d1ccd219665afef299263db9c) Thanks [@thomkrupa](https://github.com/thomkrupa)! - improve mobile design
8
+
3
9
  ## 0.1.15
4
10
 
5
11
  ### Patch Changes
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "starlight-theme-bejamas",
3
3
  "author": "Bejamas",
4
- "version": "0.1.15",
4
+ "version": "0.1.16",
5
5
  "license": "MIT",
6
6
  "description": "A Starlight theme using bejamas/ui",
7
7
  "type": "module",
@@ -46,7 +46,7 @@ const shouldRenderNav = options.nav && options.nav.length > 0;
46
46
  <div class="sl-flex sl-bejamas-header-search sl-justify-end print:hidden">
47
47
  {shouldRenderSearch && <Search />}
48
48
  </div>
49
- <div class="sl-hidden md:sl-flex print:hidden right-group">
49
+ <div class="header-desktop-right print:hidden right-group">
50
50
  <div class="sl-flex social-icons">
51
51
  <SocialIcons />
52
52
  </div>
@@ -81,10 +81,18 @@ const shouldRenderNav = options.nav && options.nav.length > 0;
81
81
  display: none;
82
82
  }
83
83
 
84
- @media (min-width: 50rem) {
84
+ .header-desktop-right {
85
+ display: none;
86
+ }
87
+
88
+ @media (min-width: 64rem) {
85
89
  .sl-bejamas-main-nav {
86
90
  display: block;
87
91
  }
92
+
93
+ .header-desktop-right {
94
+ display: flex;
95
+ }
88
96
  }
89
97
 
90
98
  .sl-justify-end {
@@ -3,17 +3,22 @@ import MobileMenuToggle from "virtual:starlight/components/MobileMenuToggle";
3
3
 
4
4
  const { hasSidebar } = Astro.locals.starlightRoute;
5
5
  const { template } = Astro.locals.starlightRoute.entry.data;
6
+
7
+ // Splash templates disable Starlight's sidebar by default, but we still want
8
+ // the mobile menu toggle there to expose docs/components navigation.
9
+ const shouldRenderSidebarNav = hasSidebar || template === "splash";
10
+ const isSplashTemplate = template === "splash";
6
11
  ---
7
12
 
8
- <div class="page sl-flex">
13
+ <div class:list={["page sl-flex", shouldRenderSidebarNav && "page-has-sidebar-nav"]}>
9
14
  <header class="header">
10
15
  <slot name="header" />
11
16
  <div class="fade"></div>
12
17
  </header>
13
18
  {
14
- hasSidebar && (
19
+ shouldRenderSidebarNav && (
15
20
  <nav
16
- class="sidebar print:hidden"
21
+ class:list={["sidebar print:hidden", isSplashTemplate && "sidebar-splash"]}
17
22
  aria-label={Astro.locals.t("sidebarNav.accessibleLabel")}
18
23
  >
19
24
  <MobileMenuToggle />
@@ -26,6 +31,74 @@ const { template } = Astro.locals.starlightRoute.entry.data;
26
31
  )
27
32
  }
28
33
 
34
+ {
35
+ isSplashTemplate && (
36
+ <script is:inline>
37
+ (() => {
38
+ const installReset = () => {
39
+ const nav = document.querySelector("nav.sidebar-splash");
40
+ if (!(nav instanceof HTMLElement)) return () => {};
41
+
42
+ const pane = nav.querySelector("#starlight__sidebar");
43
+ const toggle = nav.querySelector("starlight-menu-button");
44
+
45
+ if (!(pane instanceof HTMLElement)) return () => {};
46
+
47
+ const resetToTop = () => {
48
+ pane.scrollTop = 0;
49
+ };
50
+
51
+ // Avoid opening splash menus at a persisted offset.
52
+ resetToTop();
53
+
54
+ if (!(toggle instanceof HTMLElement)) return () => {};
55
+
56
+ const onToggleChange = () => {
57
+ if (toggle.getAttribute("aria-expanded") === "true") {
58
+ requestAnimationFrame(resetToTop);
59
+ }
60
+ };
61
+
62
+ const onToggleClick = () => {
63
+ requestAnimationFrame(onToggleChange);
64
+ };
65
+
66
+ toggle.addEventListener("click", onToggleClick);
67
+
68
+ const observer = new MutationObserver(onToggleChange);
69
+ observer.observe(toggle, {
70
+ attributes: true,
71
+ attributeFilter: ["aria-expanded"],
72
+ });
73
+
74
+ return () => {
75
+ toggle.removeEventListener("click", onToggleClick);
76
+ observer.disconnect();
77
+ };
78
+ };
79
+
80
+ let cleanup = installReset();
81
+
82
+ const onAstroPageLoad = () => {
83
+ cleanup();
84
+ cleanup = installReset();
85
+ };
86
+
87
+ document.addEventListener("astro:page-load", onAstroPageLoad);
88
+
89
+ addEventListener(
90
+ "pagehide",
91
+ () => {
92
+ cleanup();
93
+ document.removeEventListener("astro:page-load", onAstroPageLoad);
94
+ },
95
+ { once: true },
96
+ );
97
+ })();
98
+ </script>
99
+ )
100
+ }
101
+
29
102
  <div class="main-frame">
30
103
  {
31
104
  template === "splash" ? (
@@ -89,13 +162,14 @@ const { template } = Astro.locals.starlightRoute.entry.data;
89
162
  background-color: var(--background);
90
163
  }
91
164
 
92
- @media (min-width: 72rem) {
165
+ @media (min-width: 64rem) {
93
166
  .header {
94
167
  background-color: transparent;
95
168
  }
96
169
  }
97
170
 
98
- :global([data-has-sidebar]) .header {
171
+ :global([data-has-sidebar]) .header,
172
+ .page-has-sidebar-nav .header {
99
173
  padding-inline-end: calc(
100
174
  var(--sl-nav-gap) + var(--sl-nav-pad-x) + var(--sl-menu-button-size)
101
175
  );
@@ -109,8 +183,17 @@ const { template } = Astro.locals.starlightRoute.entry.data;
109
183
  inset-inline-start: 0;
110
184
  width: 100%;
111
185
  background-color: var(--background);
112
- overflow-y: auto;
186
+ height: 100svh;
187
+ overflow: scroll;
188
+ overflow-y: scroll;
189
+ overflow-x: hidden;
113
190
  scrollbar-width: none;
191
+ scroll-behavior: auto;
192
+ -webkit-overflow-scrolling: touch;
193
+ overscroll-behavior: contain;
194
+ overscroll-behavior-y: contain;
195
+ top: 0;
196
+ padding-top: calc(var(--spacing) * 18);
114
197
  }
115
198
 
116
199
  :global([aria-expanded="true"]) ~ .sidebar-pane {
@@ -155,7 +238,7 @@ const { template } = Astro.locals.starlightRoute.entry.data;
155
238
  }
156
239
  }
157
240
 
158
- .main-frame-inner::before,
241
+ /* .main-frame-inner::before,
159
242
  .main-frame-inner::after {
160
243
  content: "";
161
244
  position: absolute;
@@ -175,10 +258,11 @@ const { template } = Astro.locals.starlightRoute.entry.data;
175
258
 
176
259
  .main-frame-inner::after {
177
260
  right: -1px;
178
- }
261
+ } */
179
262
 
180
- @media (min-width: 50rem) {
181
- :global([data-has-sidebar]) .header {
263
+ @media (min-width: 64rem) {
264
+ :global([data-has-sidebar]) .header,
265
+ .page-has-sidebar-nav .header {
182
266
  padding-inline-end: var(--sl-nav-pad-x);
183
267
  }
184
268
  .sidebar-pane {
@@ -187,6 +271,11 @@ const { template } = Astro.locals.starlightRoute.entry.data;
187
271
  background-color: var(--sl-color-bg-sidebar);
188
272
  border-inline-end: 1px solid var(--sl-color-hairline-shade);
189
273
  }
274
+
275
+ /* Keep splash templates desktop layout unchanged; only mobile gets menu panel. */
276
+ .sidebar-splash .sidebar-pane {
277
+ display: none;
278
+ }
190
279
  }
191
280
  }
192
281
  </style>
@@ -4,12 +4,23 @@ import SidebarPersister from "@astrojs/starlight/components/SidebarPersister.ast
4
4
  import SidebarSublist from "@astrojs/starlight/components/SidebarSublist.astro";
5
5
 
6
6
  const { sidebar } = Astro.locals.starlightRoute;
7
+ const { template } = Astro.locals.starlightRoute.entry.data;
8
+ const isSplashTemplate = template === "splash";
7
9
  ---
8
10
 
9
- <SidebarPersister>
10
- <div class="fade"></div>
11
- <SidebarSublist sublist={sidebar} />
12
- </SidebarPersister>
11
+ {
12
+ isSplashTemplate ? (
13
+ <>
14
+ <div class="fade"></div>
15
+ <SidebarSublist sublist={sidebar} />
16
+ </>
17
+ ) : (
18
+ <SidebarPersister>
19
+ <div class="fade"></div>
20
+ <SidebarSublist sublist={sidebar} />
21
+ </SidebarPersister>
22
+ )
23
+ }
13
24
 
14
25
  <div class="md:sl-hidden">
15
26
  <MobileMenuFooter />
@@ -3,17 +3,36 @@
3
3
  @import "@fontsource-variable/inter/index.css";
4
4
 
5
5
  @layer bejamas {
6
- @media (min-width: 50rem) {
6
+ html {
7
+ background-color: var(--sl-page-background);
8
+ }
9
+
10
+ @media (min-width: 64rem) {
7
11
  :root::after {
8
12
  content: "";
9
13
  position: fixed;
10
14
  inset: 0;
11
15
  right: calc(var(--spacing) * 6);
12
- background: linear-gradient(
13
- var(--sl-page-background) 49.99%,
14
- var(--sl-main-frame-inner-background) 50%
15
- );
16
+ background:
17
+ linear-gradient(
18
+ to bottom,
19
+ transparent 50%,
20
+ var(--sl-main-frame-inner-border) 50%
21
+ )
22
+ left / 1px 100% no-repeat,
23
+ linear-gradient(
24
+ to bottom,
25
+ transparent 50%,
26
+ var(--sl-main-frame-inner-border) 50%
27
+ )
28
+ right / 1px 100% no-repeat,
29
+ linear-gradient(
30
+ to bottom,
31
+ var(--sl-page-background) 49.99%,
32
+ var(--sl-main-frame-inner-background) 50%
33
+ );
16
34
  z-index: -1;
35
+ left: var(--sl-sidebar-width);
17
36
  }
18
37
  }
19
38
 
@@ -107,12 +126,12 @@
107
126
  --sl-main-frame-inner-background: color-mix(
108
127
  in oklab,
109
128
  var(--muted) 30%,
110
- transparent
129
+ var(--background)
111
130
  );
112
131
  --sl-main-frame-inner-border: color-mix(
113
132
  in oklab,
114
133
  var(--border) 50%,
115
- transparent
134
+ var(--background)
116
135
  );
117
136
  }
118
137
  }
@@ -199,6 +218,32 @@
199
218
  margin-bottom: 1px;
200
219
  }
201
220
 
221
+ @media (max-width: 49.99rem) {
222
+ .sidebar-pane .sidebar-content {
223
+ --sl-sidebar-item-padding-inline: 0.5rem;
224
+ padding-top: calc(var(--spacing) * 3);
225
+ }
226
+
227
+ .sidebar-content::before {
228
+ display: none;
229
+ }
230
+
231
+ .sidebar-content .large {
232
+ font-size: var(--sl-text-xl);
233
+ line-height: 1.25;
234
+ }
235
+
236
+ .sidebar-content ul ul a > span {
237
+ font-size: var(--sl-text-lg);
238
+ line-height: 1.35;
239
+ }
240
+
241
+ .sidebar-content .group-label > span {
242
+ font-size: var(--sl-text-sm);
243
+ font-weight: 500;
244
+ }
245
+ }
246
+
202
247
  .right-sidebar-container {
203
248
  max-width: 20rem;
204
249
  margin-right: 0;
@@ -691,6 +736,16 @@
691
736
  font-size: calc(var(--spacing) * 8);
692
737
  }
693
738
 
739
+ @media (min-width: 50rem) and (max-width: calc(64rem - 0.01rem)) {
740
+ starlight-menu-button button {
741
+ display: flex;
742
+ }
743
+
744
+ [data-mobile-menu-expanded] {
745
+ overflow: hidden;
746
+ }
747
+ }
748
+
694
749
  #starlight__on-this-page--mobile {
695
750
  /* border-top: 1px solid var(--border); */
696
751
  border-bottom: 0;