@astronox/core 0.4.15 → 0.4.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/package.json +1 -1
- package/src/components/actions/ScrollToTop/scrollToTopController.ts +6 -4
- package/src/layouts/BaseLayout.astro +14 -2
- package/src/layouts/contracts.ts +1 -0
- package/src/layouts/index.ts +1 -0
- package/src/patterns/Combobox/comboboxController.ts +3 -3
- package/src/patterns/Modal/Modal.css +2 -5
- package/src/styles/base.css +39 -12
package/package.json
CHANGED
|
@@ -4,7 +4,9 @@ const noop = (): void => undefined;
|
|
|
4
4
|
export function initScrollToTop(control: HTMLButtonElement): () => void {
|
|
5
5
|
if (control.getAttribute(initializedAttribute) === 'true') return noop;
|
|
6
6
|
|
|
7
|
-
const scrollRoot = document.
|
|
7
|
+
const scrollRoot = document.querySelector<HTMLElement>(
|
|
8
|
+
'[data-site-scroll-root]',
|
|
9
|
+
);
|
|
8
10
|
if (!scrollRoot) return noop;
|
|
9
11
|
|
|
10
12
|
control.setAttribute(initializedAttribute, 'true');
|
|
@@ -15,16 +17,16 @@ export function initScrollToTop(control: HTMLButtonElement): () => void {
|
|
|
15
17
|
};
|
|
16
18
|
|
|
17
19
|
const scrollToTop = (): void => {
|
|
18
|
-
|
|
20
|
+
scrollRoot.scrollTo({ top: 0, behavior: 'auto' });
|
|
19
21
|
};
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
scrollRoot.addEventListener('scroll', sync, { passive: true });
|
|
22
24
|
document.addEventListener('fullscreenchange', sync);
|
|
23
25
|
control.addEventListener('click', scrollToTop);
|
|
24
26
|
sync();
|
|
25
27
|
|
|
26
28
|
return () => {
|
|
27
|
-
|
|
29
|
+
scrollRoot.removeEventListener('scroll', sync);
|
|
28
30
|
document.removeEventListener('fullscreenchange', sync);
|
|
29
31
|
control.removeEventListener('click', scrollToTop);
|
|
30
32
|
control.removeAttribute(initializedAttribute);
|
|
@@ -12,6 +12,7 @@ import Breadcrumbs from '../components/navigation/Breadcrumbs/Breadcrumbs.astro'
|
|
|
12
12
|
import ScrollToTop from '../components/actions/ScrollToTop/ScrollToTop.astro';
|
|
13
13
|
import ThemeBootstrap from '../components/feedback/ThemeBootstrap/ThemeBootstrap.astro';
|
|
14
14
|
import { defaultThemeStorageKey } from '../theme/storage';
|
|
15
|
+
import type { SiteScrollMode } from './contracts';
|
|
15
16
|
|
|
16
17
|
type Props = HTMLAttributes<'html'> & {
|
|
17
18
|
meta: PageMeta;
|
|
@@ -22,6 +23,7 @@ type Props = HTMLAttributes<'html'> & {
|
|
|
22
23
|
breadcrumbLabel: string;
|
|
23
24
|
breadcrumbTone?: Tone;
|
|
24
25
|
scrollToTopLabel?: string;
|
|
26
|
+
scrollMode?: SiteScrollMode;
|
|
25
27
|
structuredData?: readonly JsonLdNode[];
|
|
26
28
|
tone?: Tone;
|
|
27
29
|
themeStorageKey?: string;
|
|
@@ -36,6 +38,7 @@ const {
|
|
|
36
38
|
meta,
|
|
37
39
|
pageSurfaceAttributes,
|
|
38
40
|
scrollToTopLabel,
|
|
41
|
+
scrollMode = 'shell',
|
|
39
42
|
site,
|
|
40
43
|
structuredData,
|
|
41
44
|
tone,
|
|
@@ -47,7 +50,13 @@ const resolvedTone = tone ?? dataTone;
|
|
|
47
50
|
---
|
|
48
51
|
|
|
49
52
|
<!doctype html>
|
|
50
|
-
<html
|
|
53
|
+
<html
|
|
54
|
+
{...htmlAttrs}
|
|
55
|
+
lang={lang}
|
|
56
|
+
data-site-scroll-mode={scrollMode}
|
|
57
|
+
data-site-scroll-root={scrollMode === 'document' ? true : undefined}
|
|
58
|
+
data-tone={resolvedTone}
|
|
59
|
+
>
|
|
51
60
|
<head>
|
|
52
61
|
<meta charset="utf-8" />
|
|
53
62
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
@@ -62,7 +71,10 @@ const resolvedTone = tone ?? dataTone;
|
|
|
62
71
|
<slot name="head" />
|
|
63
72
|
</head>
|
|
64
73
|
<body>
|
|
65
|
-
<div
|
|
74
|
+
<div
|
|
75
|
+
class="site-shell"
|
|
76
|
+
data-site-scroll-root={scrollMode === 'shell' ? true : undefined}
|
|
77
|
+
>
|
|
66
78
|
<slot name="skip-link" />
|
|
67
79
|
<slot name="header" />
|
|
68
80
|
<div class="site-viewport" data-site-viewport>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type SiteScrollMode = 'document' | 'shell';
|
package/src/layouts/index.ts
CHANGED
|
@@ -503,11 +503,11 @@ export function initCombobox(root: HTMLElement): () => void {
|
|
|
503
503
|
const target = event.target;
|
|
504
504
|
if (target instanceof Node && panel.contains(target)) return;
|
|
505
505
|
|
|
506
|
-
const
|
|
507
|
-
'[data-site-
|
|
506
|
+
const siteScrollRoot = document.querySelector<HTMLElement>(
|
|
507
|
+
'[data-site-scroll-root]',
|
|
508
508
|
);
|
|
509
509
|
const isSiteScroll =
|
|
510
|
-
target ===
|
|
510
|
+
target === siteScrollRoot || target === document || target === window;
|
|
511
511
|
if (isSiteScroll && window.matchMedia(compactViewportQuery).matches) {
|
|
512
512
|
close();
|
|
513
513
|
blurFocusedDescendant();
|
package/src/styles/base.css
CHANGED
|
@@ -44,42 +44,50 @@
|
|
|
44
44
|
|
|
45
45
|
html {
|
|
46
46
|
min-width: 320px;
|
|
47
|
+
height: 100%;
|
|
47
48
|
min-height: 100%;
|
|
48
|
-
|
|
49
|
-
scrollbar-gutter: stable;
|
|
49
|
+
overflow: hidden;
|
|
50
50
|
background: var(--nox-page-background);
|
|
51
51
|
color: var(--nox-text);
|
|
52
52
|
font-family: var(--nox-font-body);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
body {
|
|
56
|
+
height: 100%;
|
|
56
57
|
min-height: 100%;
|
|
57
58
|
margin: 0;
|
|
59
|
+
overflow: hidden;
|
|
58
60
|
background: var(--nox-page-background);
|
|
59
61
|
}
|
|
60
62
|
|
|
61
|
-
@media (hover: hover) and (pointer: fine) {
|
|
62
|
-
body {
|
|
63
|
-
border-inline-end: var(--nox-border-width) solid var(--nox-border);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
63
|
.site-shell {
|
|
68
64
|
display: grid;
|
|
69
65
|
width: 100%;
|
|
66
|
+
height: 100vh;
|
|
70
67
|
min-height: 100vh;
|
|
71
68
|
grid-template-rows: auto minmax(0, 1fr);
|
|
72
|
-
overflow-x:
|
|
73
|
-
overflow-y:
|
|
69
|
+
overflow-x: hidden;
|
|
70
|
+
overflow-y: auto;
|
|
71
|
+
scroll-padding-block-start: var(--nox-site-header-responsive-height);
|
|
72
|
+
scrollbar-gutter: stable;
|
|
74
73
|
background: var(--nox-page-background);
|
|
74
|
+
overscroll-behavior-y: contain;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
@supports (
|
|
77
|
+
@supports (height: 100svh) {
|
|
78
78
|
.site-shell {
|
|
79
|
+
height: 100svh;
|
|
79
80
|
min-height: 100svh;
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
83
|
|
|
84
|
+
@media (width >= 48rem) {
|
|
85
|
+
.site-shell {
|
|
86
|
+
height: 100vh;
|
|
87
|
+
min-height: 100vh;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
83
91
|
a {
|
|
84
92
|
color: var(--nox-content-link-color);
|
|
85
93
|
font-weight: var(--nox-content-link-font-weight);
|
|
@@ -135,7 +143,26 @@ p {
|
|
|
135
143
|
min-height: 0;
|
|
136
144
|
overflow: visible;
|
|
137
145
|
background: var(--nox-page-background);
|
|
138
|
-
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
html[data-site-scroll-mode='document'] {
|
|
149
|
+
height: auto;
|
|
150
|
+
overflow-x: hidden;
|
|
151
|
+
overflow-y: auto;
|
|
152
|
+
scroll-padding-block-start: var(--nox-site-header-responsive-height);
|
|
153
|
+
scrollbar-gutter: stable;
|
|
154
|
+
overscroll-behavior-y: contain;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
html[data-site-scroll-mode='document'] body {
|
|
158
|
+
height: auto;
|
|
159
|
+
overflow: visible;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
html[data-site-scroll-mode='document'] .site-shell {
|
|
163
|
+
height: auto;
|
|
164
|
+
grid-template-rows: auto auto;
|
|
165
|
+
overflow: visible;
|
|
139
166
|
}
|
|
140
167
|
|
|
141
168
|
.site-main {
|