-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
-
39
-
40
-
41
-
42
-
43
-
44
-
45
-
46
-
47
-
48
-
49
-
50
-
51
-
52
-
53
-
54
-
55
-
56
-
57
-
58
-
59
-
60
-
61
-
62
-
63
-
64
-
65
-
66
-
67
-
68
-
69
-
70
-
71
-
72
-
73
-
74
-
75
-
76
-
77
-
78
-
79
-
80
-
81
-
82
-
83
-
84
-
85
-
86
-
87
-
88
-
89
-
90
-
91
-
92
-
93
-
94
-
95
-
96
-
97
-
98
-
99
-
100
-
101
-
102
-
103
-
104
-
105
-
106
-
107
-
108
-
109
-
110
-
111
-
112
-
113
-
114
-
115
-
116
-
117
-
118
-
119
-
120
-
121
-
122
-
123
-
124
-
125
-
126
-
127
-
128
-
129
-
130
-
131
-
132
-
133
-
134
-
135
-
136
-
137
-
138
-
139
-
140
-
141
-
142
-
143
-
144
-
145
-
146
-
147
-
148
-
149
-
150
-
151
-
152
-
153
-
154
-
155
-
156
-
157
-
158
-
159
-
160
-
161
-
162
-
163
-
164
-
165
-
166
-
167
-
168
-
169
-
170
-
171
-
172
-
173
-
174
-
175
-
176
-
177
-
178
-
179
-
180
-
181
-
182
-
183
-
184
-
185
-
186
-
187
-
188
-
189
-
190
-
191
-
192
-
193
-
194
-
195
-
196
-
197
-
198
-
199
-
200
-
201
-
202
-
203
-
204
-
205
-
206
-
207
-
208
-
209
-
210
-
211
-
212
-
213
-
214
-
215
// SPDX-FileCopyrightText: 2024 Shota FUJI <pockawoooh@gmail.com>
//
// SPDX-License-Identifier: Apache-2.0
/** @jsx h */
import { h } from "../../../../deps/deno.land/x/nano_jsx/mod.ts";
import { type Document } from "../../../../types.ts";
import { usePathResolver } from "../../contexts/path_resolver.tsx";
import { css } from "../../css.ts";
const enum C {
Layout = "t-sl--root",
HeaderBg = "t-sl--headbg",
Header = "t-sl--head",
Logo = "t-sl--lg",
LogoLink = "t-sl--ll",
Nav = "t-sl--nav",
NavInner = "t-sl--nav-i",
FooterBg = "t-sl--fbg",
Footer = "t-sl--foot",
Main = "t-sl--main",
Aside = "t-sl--aside",
AsideInner = "t-sl--aside-i",
}
export const styles = css`
.${C.Layout} {
--_ends-shadow-color: hsl(0deg 0% 0% / 0.03);
display: grid;
grid-template-columns: minmax(100vw, 1fr);
min-height: 100vh;
}
.${C.Layout} > * {
padding: calc(var(--baseline) * 1rem) 16px;
}
.${C.Layout} > * > :first-child {
margin-block-start: 0;
}
.${C.HeaderBg}, .${C.Header} {
padding: calc(var(--baseline) * 0.5rem) 16px;
}
.${C.HeaderBg} {
position: sticky;
top: calc(var(--baseline) * -1rem);
grid-row: 1;
grid-column: 1 / -1;
margin-block-end: calc(var(--baseline) * 2rem);
border-block-end: 1px solid var(--_ends-shadow-color);
background-color: var(--color-bg-accent);
}
.${C.Header} {
grid-row: 1;
grid-column: 1;
margin-block-end: calc(var(--baseline) * 2rem);
display: flex;
position: sticky;
top: calc(var(--baseline) * -0.5rem);
}
.${C.LogoLink} {
display: flex;
border-radius: 4px;
}
.${C.LogoLink}:hover {
background-color: var(--color-subtle-overlay);
}
.${C.Logo} {
padding: 4px;
}
.${C.Nav} {
grid-column: 1;
}
.${C.NavInner}, .${C.AsideInner} {
position: sticky;
top: calc(var(--baseline) * 1rem);
opacity: 0.7;
transition: opacity 8s ease;
}
.${C.NavInner}:hover,
.${C.NavInner}:focus-within,
.${C.AsideInner}:hover,
.${C.AsideInner}:focus-within {
opacity: 1;
transition-duration: 0.2s;
}
.${C.Main} {
grid-column: 1 / -1;
}
.${C.Aside} {
grid-column: 1 / -1;
}
.${C.FooterBg} {
grid-row: 999;
grid-column: 1 / -1;
margin-block-start: calc(var(--baseline) * 2rem);
border-block-start: 1px solid var(--_ends-shadow-color);
background-color: var(--color-bg-accent);
}
.${C.Footer} {
grid-row: 999;
grid-column: 1;
margin-block-start: calc(var(--baseline) * 2rem);
color: var(--color-fg-sub);
}
@media (min-width: 700px) {
.${C.Layout} {
grid-template-columns: 200px minmax(0, 1fr);
}
.${C.Header}, .${C.Footer} {
grid-column: 1 / -1;
}
}
@media (min-width: 1000px) {
.${C.Layout} {
grid-template-columns: 1fr min(700px, 100%) 1fr;
}
.${C.Main}, .${C.Header}, .${C.Footer} {
grid-column: 2;
}
.${C.Aside} {
grid-column: 3;
}
.${C.NavInner}, .${C.AsideInner} {
margin-inline-start: auto;
margin-inline-end: 0;
max-width: 400px;
}
}
`;
export interface ViewProps {
children: JSX.ElementChildrenAttribute["children"];
nav: JSX.ElementChildrenAttribute["children"];
aside?: JSX.ElementChildrenAttribute["children"];
footer: JSX.ElementChildrenAttribute["children"];
logoImage?: readonly string[];
logoSize?: number;
defaultDocument: Document;
}
export function View(
{ children, nav, aside, footer, logoImage, logoSize = 32, defaultDocument }:
ViewProps,
) {
const path = usePathResolver();
return (
<div className={C.Layout}>
<div className={C.HeaderBg} />
{logoImage && (
<header className={C.Header}>
<a
className={C.LogoLink}
href={path.resolve([...defaultDocument.path, ""])}
title={defaultDocument.metadata.title}
lang={defaultDocument.metadata.language}
>
<img
className={C.Logo}
src={path.resolve(logoImage)}
width={logoSize}
height={logoSize}
/>
</a>
</header>
)}
<nav className={C.Nav}>
<div className={C.NavInner}>{nav}</div>
</nav>
<main className={C.Main}>{children}</main>
{aside && (
<aside className={C.Aside}>
<div className={C.AsideInner}>{aside}</div>
</aside>
)}
<div className={C.FooterBg} />
<footer className={C.Footer}>{footer}</footer>
</div>
);
}