starlight-theme-bejamas 0.1.15 → 0.1.17

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,19 @@
1
1
  # starlight-theme-bejamas
2
2
 
3
+ ## 0.1.17
4
+
5
+ ### Patch Changes
6
+
7
+ - [#80](https://github.com/bejamas/ui/pull/80) [`c3f2b3a`](https://github.com/bejamas/ui/commit/c3f2b3a2f94f8c60657e33bab49320a5d5258e11) Thanks [@thomkrupa](https://github.com/thomkrupa)! - fix shared splash layout bg
8
+
9
+ - [#82](https://github.com/bejamas/ui/pull/82) [`043d0fa`](https://github.com/bejamas/ui/commit/043d0faa76a34f25620f7ad8bc30d8aa9be8e3be) Thanks [@thomkrupa](https://github.com/thomkrupa)! - fix sidebar margin
10
+
11
+ ## 0.1.16
12
+
13
+ ### Patch Changes
14
+
15
+ - [#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
16
+
3
17
  ## 0.1.15
4
18
 
5
19
  ### 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.17",
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 {
@@ -115,6 +123,11 @@ const shouldRenderNav = options.nav && options.nav.length > 0;
115
123
  :global(:root[data-has-sidebar]) {
116
124
  --__sidebar-pad: calc(2 * var(--sl-nav-pad-x));
117
125
  }
126
+ :global(.page-mobile-sidebar-only) .header {
127
+ --__sidebar-pad: 0rem;
128
+ display: flex;
129
+ grid-template-columns: none;
130
+ }
118
131
  :global(:root:not([data-has-toc])) {
119
132
  --__toc-width: 0rem;
120
133
  }
@@ -3,17 +3,28 @@ 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
14
+ class:list={[
15
+ "page sl-flex",
16
+ shouldRenderSidebarNav && "page-has-sidebar-nav",
17
+ isSplashTemplate && "page-mobile-sidebar-only",
18
+ ]}
19
+ >
9
20
  <header class="header">
10
21
  <slot name="header" />
11
22
  <div class="fade"></div>
12
23
  </header>
13
24
  {
14
- hasSidebar && (
25
+ shouldRenderSidebarNav && (
15
26
  <nav
16
- class="sidebar print:hidden"
27
+ class:list={["sidebar print:hidden", isSplashTemplate && "sidebar-splash"]}
17
28
  aria-label={Astro.locals.t("sidebarNav.accessibleLabel")}
18
29
  >
19
30
  <MobileMenuToggle />
@@ -26,7 +37,75 @@ const { template } = Astro.locals.starlightRoute.entry.data;
26
37
  )
27
38
  }
28
39
 
29
- <div class="main-frame">
40
+ {
41
+ isSplashTemplate && (
42
+ <script is:inline>
43
+ (() => {
44
+ const installReset = () => {
45
+ const nav = document.querySelector("nav.sidebar-splash");
46
+ if (!(nav instanceof HTMLElement)) return () => {};
47
+
48
+ const pane = nav.querySelector("#starlight__sidebar");
49
+ const toggle = nav.querySelector("starlight-menu-button");
50
+
51
+ if (!(pane instanceof HTMLElement)) return () => {};
52
+
53
+ const resetToTop = () => {
54
+ pane.scrollTop = 0;
55
+ };
56
+
57
+ // Avoid opening splash menus at a persisted offset.
58
+ resetToTop();
59
+
60
+ if (!(toggle instanceof HTMLElement)) return () => {};
61
+
62
+ const onToggleChange = () => {
63
+ if (toggle.getAttribute("aria-expanded") === "true") {
64
+ requestAnimationFrame(resetToTop);
65
+ }
66
+ };
67
+
68
+ const onToggleClick = () => {
69
+ requestAnimationFrame(onToggleChange);
70
+ };
71
+
72
+ toggle.addEventListener("click", onToggleClick);
73
+
74
+ const observer = new MutationObserver(onToggleChange);
75
+ observer.observe(toggle, {
76
+ attributes: true,
77
+ attributeFilter: ["aria-expanded"],
78
+ });
79
+
80
+ return () => {
81
+ toggle.removeEventListener("click", onToggleClick);
82
+ observer.disconnect();
83
+ };
84
+ };
85
+
86
+ let cleanup = installReset();
87
+
88
+ const onAstroPageLoad = () => {
89
+ cleanup();
90
+ cleanup = installReset();
91
+ };
92
+
93
+ document.addEventListener("astro:page-load", onAstroPageLoad);
94
+
95
+ addEventListener(
96
+ "pagehide",
97
+ () => {
98
+ cleanup();
99
+ document.removeEventListener("astro:page-load", onAstroPageLoad);
100
+ },
101
+ { once: true },
102
+ );
103
+ })();
104
+ </script>
105
+ )
106
+ }
107
+
108
+ <div class:list={["main-frame", isSplashTemplate && "main-frame-splash"]}>
30
109
  {
31
110
  template === "splash" ? (
32
111
  <slot />
@@ -89,13 +168,14 @@ const { template } = Astro.locals.starlightRoute.entry.data;
89
168
  background-color: var(--background);
90
169
  }
91
170
 
92
- @media (min-width: 72rem) {
171
+ @media (min-width: 64rem) {
93
172
  .header {
94
173
  background-color: transparent;
95
174
  }
96
175
  }
97
176
 
98
- :global([data-has-sidebar]) .header {
177
+ :global([data-has-sidebar]) .header,
178
+ .page-has-sidebar-nav .header {
99
179
  padding-inline-end: calc(
100
180
  var(--sl-nav-gap) + var(--sl-nav-pad-x) + var(--sl-menu-button-size)
101
181
  );
@@ -109,8 +189,17 @@ const { template } = Astro.locals.starlightRoute.entry.data;
109
189
  inset-inline-start: 0;
110
190
  width: 100%;
111
191
  background-color: var(--background);
112
- overflow-y: auto;
192
+ height: 100svh;
193
+ overflow: scroll;
194
+ overflow-y: scroll;
195
+ overflow-x: hidden;
113
196
  scrollbar-width: none;
197
+ scroll-behavior: auto;
198
+ -webkit-overflow-scrolling: touch;
199
+ overscroll-behavior: contain;
200
+ overscroll-behavior-y: contain;
201
+ top: 0;
202
+ padding-top: calc(var(--spacing) * 18);
114
203
  }
115
204
 
116
205
  :global([aria-expanded="true"]) ~ .sidebar-pane {
@@ -130,6 +219,11 @@ const { template } = Astro.locals.starlightRoute.entry.data;
130
219
  content: "";
131
220
  padding-bottom: 1px;
132
221
  }
222
+
223
+ .sidebar-pane {
224
+ padding-top: 0;
225
+ margin-top: margin-top: calc(var(--spacing) * 18);
226
+ }
133
227
  }
134
228
 
135
229
  .main-frame {
@@ -137,6 +231,18 @@ const { template } = Astro.locals.starlightRoute.entry.data;
137
231
  /* padding-inline-start: var(--sl-content-inline-start); */
138
232
  }
139
233
 
234
+ .main-frame-splash {
235
+ position: relative;
236
+ isolation: isolate;
237
+ --sl-splash-frame-top: calc(var(--spacing) * 8);
238
+ --sl-splash-frame-inline: 0;
239
+ }
240
+
241
+ .main-frame-splash > * {
242
+ position: relative;
243
+ z-index: 1;
244
+ }
245
+
140
246
  .main-frame-inner {
141
247
  position: relative;
142
248
  background-color: var(--sl-main-frame-inner-background);
@@ -155,7 +261,28 @@ const { template } = Astro.locals.starlightRoute.entry.data;
155
261
  }
156
262
  }
157
263
 
158
- .main-frame-inner::before,
264
+ @media (min-width: 48rem) {
265
+ .main-frame-splash::before {
266
+ content: "";
267
+ position: absolute;
268
+ inset-inline: var(--sl-splash-frame-inline);
269
+ inset-block-start: var(--sl-splash-frame-top);
270
+ inset-block-end: 0;
271
+ border: 1px solid var(--sl-main-frame-inner-border);
272
+ border-bottom: 0;
273
+ border-radius: calc(var(--radius) + 12px) calc(var(--radius) + 12px) 0 0;
274
+ background-color: var(--sl-main-frame-inner-background);
275
+ pointer-events: none;
276
+ z-index: 0;
277
+ }
278
+
279
+ /* Pages with their own local splash frame keep full control. */
280
+ :global(.main-frame-splash:has(.page-bg))::before {
281
+ content: none;
282
+ }
283
+ }
284
+
285
+ /* .main-frame-inner::before,
159
286
  .main-frame-inner::after {
160
287
  content: "";
161
288
  position: absolute;
@@ -175,10 +302,16 @@ const { template } = Astro.locals.starlightRoute.entry.data;
175
302
 
176
303
  .main-frame-inner::after {
177
304
  right: -1px;
178
- }
305
+ } */
179
306
 
180
- @media (min-width: 50rem) {
181
- :global([data-has-sidebar]) .header {
307
+ @media (min-width: 64rem) {
308
+ .page-mobile-sidebar-only {
309
+ --sl-sidebar-width: 0;
310
+ --sl-content-inline-start: 0;
311
+ }
312
+
313
+ :global([data-has-sidebar]) .header,
314
+ .page-has-sidebar-nav .header {
182
315
  padding-inline-end: var(--sl-nav-pad-x);
183
316
  }
184
317
  .sidebar-pane {
@@ -187,6 +320,11 @@ const { template } = Astro.locals.starlightRoute.entry.data;
187
320
  background-color: var(--sl-color-bg-sidebar);
188
321
  border-inline-end: 1px solid var(--sl-color-hairline-shade);
189
322
  }
323
+
324
+ /* Keep splash templates desktop layout unchanged; only mobile gets menu panel. */
325
+ .sidebar-splash .sidebar-pane {
326
+ display: none;
327
+ }
190
328
  }
191
329
  }
192
330
  </style>
@@ -12,6 +12,7 @@ const isRtl = dir === "rtl";
12
12
  class:list={[
13
13
  "sl-bejamas-docs-title",
14
14
  entry.data.template === "splash" && "mt-10",
15
+ entry.data.template === "splash" && "px-0 sm:px-6 md:px-8",
15
16
  ]}
16
17
  >
17
18
  <div class="flex items-center">
@@ -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,44 @@
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: calc(var(--spacing) * 6);
36
+ }
37
+
38
+ :root[data-has-sidebar]::after {
39
+ left: var(--sl-sidebar-width);
40
+ }
41
+
42
+ :root[data-has-sidebar]:has(.page-mobile-sidebar-only)::after {
43
+ left: calc(var(--spacing) * 6);
17
44
  }
18
45
  }
19
46
 
@@ -107,12 +134,12 @@
107
134
  --sl-main-frame-inner-background: color-mix(
108
135
  in oklab,
109
136
  var(--muted) 30%,
110
- transparent
137
+ var(--background)
111
138
  );
112
139
  --sl-main-frame-inner-border: color-mix(
113
140
  in oklab,
114
141
  var(--border) 50%,
115
- transparent
142
+ var(--background)
116
143
  );
117
144
  }
118
145
  }
@@ -199,6 +226,32 @@
199
226
  margin-bottom: 1px;
200
227
  }
201
228
 
229
+ @media (max-width: 49.99rem) {
230
+ .sidebar-pane .sidebar-content {
231
+ --sl-sidebar-item-padding-inline: 0.5rem;
232
+ padding-top: calc(var(--spacing) * 3);
233
+ }
234
+
235
+ .sidebar-content::before {
236
+ display: none;
237
+ }
238
+
239
+ .sidebar-content .large {
240
+ font-size: var(--sl-text-xl);
241
+ line-height: 1.25;
242
+ }
243
+
244
+ .sidebar-content ul ul a > span {
245
+ font-size: var(--sl-text-lg);
246
+ line-height: 1.35;
247
+ }
248
+
249
+ .sidebar-content .group-label > span {
250
+ font-size: var(--sl-text-sm);
251
+ font-weight: 500;
252
+ }
253
+ }
254
+
202
255
  .right-sidebar-container {
203
256
  max-width: 20rem;
204
257
  margin-right: 0;
@@ -691,6 +744,16 @@
691
744
  font-size: calc(var(--spacing) * 8);
692
745
  }
693
746
 
747
+ @media (min-width: 50rem) and (max-width: calc(64rem - 0.01rem)) {
748
+ starlight-menu-button button {
749
+ display: flex;
750
+ }
751
+
752
+ [data-mobile-menu-expanded] {
753
+ overflow: hidden;
754
+ }
755
+ }
756
+
694
757
  #starlight__on-this-page--mobile {
695
758
  /* border-top: 1px solid var(--border); */
696
759
  border-bottom: 0;