@hyvor/design 2.0.19 → 2.1.0
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/dist/cloud/CloudContext/CloudContext.svelte +0 -9
- package/dist/components/ColorPicker/ColorPicker.svelte.d.ts +1 -1
- package/dist/components/Loader/Loader.svelte.d.ts +1 -1
- package/dist/marketing/Docs/Docs.svelte +371 -15
- package/dist/marketing/Docs/Docs.svelte.d.ts +5 -2
- package/dist/marketing/Docs/{Content/DocsImage.svelte → DocsImage.svelte} +1 -1
- package/dist/marketing/Docs/NavItem.svelte +96 -0
- package/dist/marketing/Docs/{Nav/NavItem.svelte.d.ts → NavItem.svelte.d.ts} +5 -2
- package/dist/marketing/Docs/OpenApi/OpenApi.svelte +144 -0
- package/dist/marketing/Docs/OpenApi/OpenApi.svelte.d.ts +7 -0
- package/dist/marketing/Docs/OpenApi/Operation.svelte +147 -0
- package/dist/marketing/Docs/OpenApi/Operation.svelte.d.ts +9 -0
- package/dist/marketing/Docs/OpenApi/ParamsTable.svelte +57 -0
- package/dist/marketing/Docs/OpenApi/ParamsTable.svelte.d.ts +8 -0
- package/dist/marketing/Docs/OpenApi/SchemaFields.svelte +141 -0
- package/dist/marketing/Docs/OpenApi/SchemaFields.svelte.d.ts +9 -0
- package/dist/marketing/Docs/OpenApi/openapi.d.ts +106 -0
- package/dist/marketing/Docs/OpenApi/openapi.js +267 -0
- package/dist/marketing/Docs/Sidebar/Sidebar.svelte +1 -3
- package/dist/marketing/Docs/fulldocs.d.ts +17 -0
- package/dist/marketing/Docs/fulldocs.js +106 -0
- package/dist/marketing/Docs/types.d.ts +23 -0
- package/dist/marketing/Docs/types.js +1 -0
- package/dist/marketing/index.d.ts +3 -6
- package/dist/marketing/index.js +2 -6
- package/package.json +2 -3
- package/dist/marketing/Docs/Content/Content.svelte +0 -181
- package/dist/marketing/Docs/Content/Content.svelte.d.ts +0 -6
- package/dist/marketing/Docs/Nav/Nav.svelte +0 -156
- package/dist/marketing/Docs/Nav/Nav.svelte.d.ts +0 -6
- package/dist/marketing/Docs/Nav/NavCategory.svelte +0 -49
- package/dist/marketing/Docs/Nav/NavCategory.svelte.d.ts +0 -9
- package/dist/marketing/Docs/Nav/NavItem.svelte +0 -39
- package/dist/marketing/track/track.d.ts +0 -22
- package/dist/marketing/track/track.js +0 -70
- /package/dist/marketing/Docs/{Content/DocsImage.svelte.d.ts → DocsImage.svelte.d.ts} +0 -0
|
@@ -5,8 +5,6 @@
|
|
|
5
5
|
setCloudContext,
|
|
6
6
|
type CloudContext as CloudContextType
|
|
7
7
|
} from './cloudContextState.svelte.js';
|
|
8
|
-
import { onMount } from 'svelte';
|
|
9
|
-
import { track } from '../../marketing/index.js';
|
|
10
8
|
|
|
11
9
|
interface Props {
|
|
12
10
|
context: CloudContextType;
|
|
@@ -23,13 +21,6 @@
|
|
|
23
21
|
incrementCloudContextId();
|
|
24
22
|
}
|
|
25
23
|
});
|
|
26
|
-
|
|
27
|
-
onMount(() => {
|
|
28
|
-
track.identify(context.user.id.toString(), {
|
|
29
|
-
name: context.user.name ?? undefined,
|
|
30
|
-
avatar: context.user.picture_url ?? undefined
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
24
|
</script>
|
|
34
25
|
|
|
35
26
|
<div transition:fade={{ duration: 200 }} {style}>
|
|
@@ -26,6 +26,6 @@ declare const ColorPicker: $$__sveltets_2_IsomorphicComponent<Props, {
|
|
|
26
26
|
change: CustomEvent<string>;
|
|
27
27
|
} & {
|
|
28
28
|
[evt: string]: CustomEvent<any>;
|
|
29
|
-
}, {}, {}, "
|
|
29
|
+
}, {}, {}, "show" | "color">;
|
|
30
30
|
type ColorPicker = InstanceType<typeof ColorPicker>;
|
|
31
31
|
export default ColorPicker;
|
|
@@ -11,6 +11,6 @@ interface Props {
|
|
|
11
11
|
children?: import('svelte').Snippet;
|
|
12
12
|
[key: string]: any;
|
|
13
13
|
}
|
|
14
|
-
declare const Loader: import("svelte").Component<Props, {}, "size" | "
|
|
14
|
+
declare const Loader: import("svelte").Component<Props, {}, "size" | "padding" | "state" | "color" | "colorTrack">;
|
|
15
15
|
type Loader = ReturnType<typeof Loader>;
|
|
16
16
|
export default Loader;
|
|
@@ -1,34 +1,390 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import NavItem from './NavItem.svelte';
|
|
2
3
|
import Sidebar from './Sidebar/Sidebar.svelte';
|
|
4
|
+
import { getSubSectionPathForSlug, getFirstPageSlug } from './fulldocs.js';
|
|
5
|
+
import type { NavPageConfig, NavSectionConfig } from './types.js';
|
|
6
|
+
import { clickOutside } from '../../components/index.js';
|
|
7
|
+
import IconList from '@hyvor/icons/IconList';
|
|
8
|
+
|
|
3
9
|
interface Props {
|
|
4
|
-
|
|
5
|
-
|
|
10
|
+
basepath: string;
|
|
11
|
+
rootName?: string;
|
|
12
|
+
sections: NavSectionConfig[];
|
|
13
|
+
page: NavPageConfig;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
let { basepath = '/', rootName = 'Docs', sections, page }: Props = $props();
|
|
17
|
+
|
|
18
|
+
const subSectionPath = $derived(getSubSectionPathForSlug(sections, page.slug) ?? []);
|
|
19
|
+
|
|
20
|
+
const currentSections = $derived(
|
|
21
|
+
subSectionPath.length > 0 ? subSectionPath[subSectionPath.length - 1].sections : sections
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
// mobile nav is collapsed behind a toggle button; close it whenever the
|
|
25
|
+
// active page changes (e.g. after clicking a nav link on mobile)
|
|
26
|
+
let mobileNavOpen = $state(false);
|
|
27
|
+
$effect(() => {
|
|
28
|
+
void page.slug;
|
|
29
|
+
mobileNavOpen = false;
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
let contentEl: HTMLElement | undefined = $state();
|
|
33
|
+
|
|
34
|
+
// adds a clickable anchor link to each heading that has an id, so
|
|
35
|
+
// readers can link directly to a section of the page
|
|
36
|
+
function linkifyHeadings() {
|
|
37
|
+
if (!contentEl) return;
|
|
38
|
+
|
|
39
|
+
const headings = contentEl.querySelectorAll<HTMLElement>('h2[id], h3[id], h4[id]');
|
|
40
|
+
for (const h of headings) {
|
|
41
|
+
const icon = document.createElement('a');
|
|
42
|
+
icon.className = 'heading-anchor-link';
|
|
43
|
+
icon.innerHTML =
|
|
44
|
+
'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" class="bi bi-link-45deg" viewBox="0 0 16 16"><path d="M4.715 6.542 3.343 7.914a3 3 0 1 0 4.243 4.243l1.828-1.829A3 3 0 0 0 8.586 5.5L8 6.086a1.002 1.002 0 0 0-.154.199 2 2 0 0 1 .861 3.337L6.88 11.45a2 2 0 1 1-2.83-2.83l.793-.792a4.018 4.018 0 0 1-.128-1.287z"/><path d="M6.586 4.672A3 3 0 0 0 7.414 9.5l.775-.776a2 2 0 0 1-.896-3.346L9.12 3.55a2 2 0 1 1 2.83 2.83l-.793.792c.112.42.155.855.128 1.287l1.372-1.372a3 3 0 1 0-4.243-4.243L6.586 4.672z"/></svg>';
|
|
45
|
+
icon.tabIndex = -1;
|
|
46
|
+
h.appendChild(icon);
|
|
47
|
+
|
|
48
|
+
const id = h.getAttribute('id');
|
|
49
|
+
const link = document.createElement('a');
|
|
50
|
+
link.className = 'heading-anchor';
|
|
51
|
+
link.setAttribute('href', '#' + id);
|
|
52
|
+
link.innerHTML = h.innerHTML;
|
|
53
|
+
h.innerHTML = link.outerHTML;
|
|
54
|
+
}
|
|
6
55
|
}
|
|
7
56
|
|
|
8
|
-
|
|
57
|
+
$effect(() => {
|
|
58
|
+
void page.slug;
|
|
59
|
+
linkifyHeadings();
|
|
60
|
+
});
|
|
9
61
|
</script>
|
|
10
62
|
|
|
11
|
-
<div class="docs">
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
63
|
+
<div class="wrap docs">
|
|
64
|
+
<div class="nav-wrap">
|
|
65
|
+
<button
|
|
66
|
+
class="mobile-toggle hds-box"
|
|
67
|
+
onclick={(e) => {
|
|
68
|
+
e.stopPropagation();
|
|
69
|
+
mobileNavOpen = !mobileNavOpen;
|
|
70
|
+
}}
|
|
71
|
+
>
|
|
72
|
+
<div class="mobile-toggle-label">
|
|
73
|
+
{#if subSectionPath.length > 0}
|
|
74
|
+
<span class="category">{subSectionPath[subSectionPath.length - 1].name}</span>
|
|
75
|
+
<span class="sep">»</span>
|
|
76
|
+
{/if}
|
|
77
|
+
<span class="name">{page.name}</span>
|
|
78
|
+
</div>
|
|
79
|
+
<IconList size={18} />
|
|
80
|
+
</button>
|
|
81
|
+
|
|
82
|
+
<nav
|
|
83
|
+
class="hds-box"
|
|
84
|
+
class:open={mobileNavOpen}
|
|
85
|
+
use:clickOutside={{ callback: () => (mobileNavOpen = false) }}
|
|
86
|
+
>
|
|
87
|
+
<div class="breadcrumb">
|
|
88
|
+
<a class="breadcrumb-item" href={basepath + '/' + (getFirstPageSlug(sections) ?? '')}>
|
|
89
|
+
{rootName}
|
|
90
|
+
</a>
|
|
91
|
+
{#each subSectionPath as sub}
|
|
92
|
+
<span class="breadcrumb-sep"></span>
|
|
93
|
+
<a class="breadcrumb-item" href={basepath + '/' + (getFirstPageSlug(sub.sections) ?? '')}>
|
|
94
|
+
{sub.name}
|
|
95
|
+
</a>
|
|
96
|
+
{/each}
|
|
97
|
+
</div>
|
|
98
|
+
|
|
99
|
+
{#each currentSections as section}
|
|
100
|
+
<div class="section">
|
|
101
|
+
{#if section.name}
|
|
102
|
+
<div class="section-name">
|
|
103
|
+
{section.name}
|
|
104
|
+
</div>
|
|
105
|
+
{/if}
|
|
106
|
+
|
|
107
|
+
{#each section.navs as nav}
|
|
108
|
+
<NavItem {nav} {basepath} currentSlug={page.slug} />
|
|
109
|
+
{/each}
|
|
110
|
+
</div>
|
|
111
|
+
{/each}
|
|
112
|
+
</nav>
|
|
113
|
+
</div>
|
|
114
|
+
|
|
115
|
+
<div class="content-wrap hds-box">
|
|
116
|
+
<content class:wide={page.wide} bind:this={contentEl}>
|
|
117
|
+
<page.content />
|
|
118
|
+
</content>
|
|
119
|
+
</div>
|
|
120
|
+
|
|
121
|
+
{#if !page.wide}
|
|
122
|
+
<Sidebar />
|
|
123
|
+
{/if}
|
|
15
124
|
</div>
|
|
16
125
|
|
|
17
126
|
<style>
|
|
18
|
-
.
|
|
127
|
+
.wrap {
|
|
19
128
|
display: flex;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
129
|
+
padding: 15px;
|
|
130
|
+
gap: 15px;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.nav-wrap {
|
|
134
|
+
flex-shrink: 0;
|
|
135
|
+
height: calc(100vh - var(--header-height) - 30px);
|
|
136
|
+
position: sticky;
|
|
137
|
+
top: calc(var(--header-height, 0) + 15px);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.mobile-toggle {
|
|
141
|
+
display: none;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
nav {
|
|
145
|
+
width: 280px;
|
|
146
|
+
height: 100%;
|
|
147
|
+
padding: 15px 0;
|
|
148
|
+
overflow-y: auto;
|
|
149
|
+
flex-shrink: 0;
|
|
26
150
|
}
|
|
27
151
|
|
|
28
152
|
@media (max-width: 992px) {
|
|
29
|
-
.
|
|
153
|
+
.wrap {
|
|
30
154
|
flex-direction: column;
|
|
31
155
|
width: 100%;
|
|
156
|
+
padding: 15px 0;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.nav-wrap {
|
|
160
|
+
width: 100%;
|
|
161
|
+
padding: 0 15px;
|
|
162
|
+
order: 1;
|
|
163
|
+
height: auto;
|
|
164
|
+
position: static;
|
|
165
|
+
top: auto;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.content-wrap {
|
|
169
|
+
order: 2;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.mobile-toggle {
|
|
173
|
+
display: flex;
|
|
174
|
+
align-items: center;
|
|
175
|
+
width: 100%;
|
|
176
|
+
padding: 10px 20px;
|
|
177
|
+
cursor: pointer;
|
|
178
|
+
}
|
|
179
|
+
.mobile-toggle:hover {
|
|
180
|
+
background-color: var(--hover);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.mobile-toggle-label {
|
|
184
|
+
flex: 1;
|
|
185
|
+
text-align: left;
|
|
186
|
+
}
|
|
187
|
+
.category,
|
|
188
|
+
.sep {
|
|
189
|
+
color: var(--text-light);
|
|
190
|
+
}
|
|
191
|
+
.sep {
|
|
192
|
+
margin: 0 4px;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
nav {
|
|
196
|
+
display: none;
|
|
197
|
+
position: absolute;
|
|
198
|
+
width: calc(100% - 30px);
|
|
199
|
+
height: auto;
|
|
200
|
+
max-height: 500px;
|
|
201
|
+
margin-top: 8px;
|
|
202
|
+
padding: 15px 0;
|
|
203
|
+
z-index: 100;
|
|
204
|
+
}
|
|
205
|
+
nav.open {
|
|
206
|
+
display: block;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
.breadcrumb {
|
|
211
|
+
display: flex;
|
|
212
|
+
align-items: center;
|
|
213
|
+
flex-wrap: wrap;
|
|
214
|
+
gap: 6px;
|
|
215
|
+
padding: 0 25px 12px;
|
|
216
|
+
font-size: 13px;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
.breadcrumb-item {
|
|
220
|
+
color: var(--text-light);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
.breadcrumb-item:last-child {
|
|
224
|
+
color: inherit;
|
|
225
|
+
font-weight: 600;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.breadcrumb-item:not(:last-child):hover {
|
|
229
|
+
text-decoration: underline;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
.breadcrumb-sep {
|
|
233
|
+
color: var(--text-light);
|
|
234
|
+
position: relative;
|
|
235
|
+
width: 4px;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
.breadcrumb-sep::before {
|
|
239
|
+
content: '';
|
|
240
|
+
width: 4px;
|
|
241
|
+
height: 4px;
|
|
242
|
+
border-right: 1px solid var(--text-light);
|
|
243
|
+
border-bottom: 1px solid var(--text-light);
|
|
244
|
+
position: absolute;
|
|
245
|
+
top: 50%;
|
|
246
|
+
left: 50%;
|
|
247
|
+
transform: translate(-50%, -40%) rotate(-45deg);
|
|
248
|
+
margin-left: -1px;
|
|
249
|
+
opacity: 0.5;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.section-name {
|
|
253
|
+
font-weight: 600;
|
|
254
|
+
padding: 0 25px;
|
|
255
|
+
margin-top: 20px;
|
|
256
|
+
margin-bottom: 8px;
|
|
257
|
+
font-size: 14px;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
.content-wrap {
|
|
261
|
+
flex: 1;
|
|
262
|
+
padding: 30px 45px;
|
|
263
|
+
min-width: 0;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
content {
|
|
267
|
+
display: block;
|
|
268
|
+
margin: auto;
|
|
269
|
+
width: 650px;
|
|
270
|
+
max-width: 100%;
|
|
271
|
+
}
|
|
272
|
+
content.wide {
|
|
273
|
+
width: 100%;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/* content styles */
|
|
277
|
+
|
|
278
|
+
content :global(p),
|
|
279
|
+
content :global(li) {
|
|
280
|
+
line-height: var(--line-height-content);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
content :global(h1:first-child) {
|
|
284
|
+
margin-top: 0;
|
|
285
|
+
font-size: 36px;
|
|
286
|
+
font-weight: 600;
|
|
287
|
+
letter-spacing: -0.03em;
|
|
288
|
+
margin: 0 0 30px;
|
|
289
|
+
position: relative;
|
|
290
|
+
display: table;
|
|
291
|
+
&:after {
|
|
292
|
+
position: absolute;
|
|
293
|
+
content: '';
|
|
294
|
+
bottom: -13px;
|
|
295
|
+
left: 0px;
|
|
296
|
+
width: 30%;
|
|
297
|
+
height: 3px;
|
|
298
|
+
background: var(--accent);
|
|
299
|
+
margin-top: 10px;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
content :global(a:not(.no-link-color a)) {
|
|
303
|
+
color: var(--link);
|
|
304
|
+
text-decoration: underline;
|
|
305
|
+
}
|
|
306
|
+
content :global(li) {
|
|
307
|
+
margin-bottom: 8px;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
content :global(ul) {
|
|
311
|
+
margin-top: 8px;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
content :global(.table) {
|
|
315
|
+
margin: 20px 0;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
content :global(code) {
|
|
319
|
+
font-size: 14px;
|
|
320
|
+
padding: 0.2em 0.4em;
|
|
321
|
+
display: inline-block;
|
|
322
|
+
background-color: #f4f2f0;
|
|
323
|
+
color: #905;
|
|
324
|
+
font-family: inherit;
|
|
325
|
+
border-radius: 4px;
|
|
326
|
+
line-height: normal;
|
|
327
|
+
font-weight: 400;
|
|
328
|
+
}
|
|
329
|
+
:global(:root.dark) content :global(code) {
|
|
330
|
+
background-color: #282c34;
|
|
331
|
+
color: #e06c75;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
content :global(a.heading-anchor-link) {
|
|
335
|
+
position: absolute;
|
|
336
|
+
right: 100%;
|
|
337
|
+
margin-right: 7px;
|
|
338
|
+
opacity: 0;
|
|
339
|
+
top: 50%;
|
|
340
|
+
transform: translateY(-50%);
|
|
341
|
+
display: inline-flex;
|
|
342
|
+
align-items: center;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
content {
|
|
346
|
+
:global(h1),
|
|
347
|
+
:global(h2),
|
|
348
|
+
:global(h3),
|
|
349
|
+
:global(h4),
|
|
350
|
+
:global(h5),
|
|
351
|
+
:global(h6) {
|
|
352
|
+
position: relative;
|
|
353
|
+
margin: 20px 0;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
:global(h1) {
|
|
357
|
+
font-size: 2em;
|
|
358
|
+
}
|
|
359
|
+
:global(h2) {
|
|
360
|
+
font-size: 1.5em;
|
|
361
|
+
}
|
|
362
|
+
:global(h3) {
|
|
363
|
+
font-size: 1.3em;
|
|
364
|
+
}
|
|
365
|
+
:global(h4) {
|
|
366
|
+
font-size: 1.2em;
|
|
367
|
+
}
|
|
368
|
+
:global(h5) {
|
|
369
|
+
font-size: 1.1em;
|
|
370
|
+
}
|
|
371
|
+
:global(h6) {
|
|
372
|
+
font-size: 1em;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
content {
|
|
377
|
+
:global(.heading-anchor:hover + .heading-anchor-link) {
|
|
378
|
+
opacity: 1;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
:global(h2 a:not(.heading-anchor-link)),
|
|
382
|
+
:global(h3 a:not(.heading-anchor-link)),
|
|
383
|
+
:global(h4 a:not(.heading-anchor-link)),
|
|
384
|
+
:global(h5 a:not(.heading-anchor-link)),
|
|
385
|
+
:global(h6 a:not(.heading-anchor-link)) {
|
|
386
|
+
text-decoration: none;
|
|
387
|
+
color: inherit;
|
|
32
388
|
}
|
|
33
389
|
}
|
|
34
390
|
</style>
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import type { NavPageConfig, NavSectionConfig } from './types.js';
|
|
1
2
|
interface Props {
|
|
2
|
-
|
|
3
|
-
|
|
3
|
+
basepath: string;
|
|
4
|
+
rootName?: string;
|
|
5
|
+
sections: NavSectionConfig[];
|
|
6
|
+
page: NavPageConfig;
|
|
4
7
|
}
|
|
5
8
|
declare const Docs: import("svelte").Component<Props, {}, "">;
|
|
6
9
|
type Docs = ReturnType<typeof Docs>;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { NavConfig } from './types.js';
|
|
3
|
+
import { getFirstPageSlug } from './fulldocs.js';
|
|
4
|
+
import IconCaretRight from '@hyvor/icons/IconCaretRight';
|
|
5
|
+
import IconArrowRight from '@hyvor/icons/IconArrowRight';
|
|
6
|
+
import NavItem from './NavItem.svelte';
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
basepath: string;
|
|
10
|
+
nav: NavConfig;
|
|
11
|
+
currentSlug: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
let { nav, basepath, currentSlug }: Props = $props();
|
|
15
|
+
|
|
16
|
+
let foldingOpen = $state(false);
|
|
17
|
+
|
|
18
|
+
const href = $derived.by(() => {
|
|
19
|
+
if (nav.type === 'page') {
|
|
20
|
+
return basepath + '/' + nav.slug;
|
|
21
|
+
} else if (nav.type === 'sub-section') {
|
|
22
|
+
return basepath + '/' + (getFirstPageSlug(nav.sections) ?? '');
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
{#if nav.type === 'folding-section'}
|
|
28
|
+
<button class="nav-item" onclick={() => (foldingOpen = !foldingOpen)}>
|
|
29
|
+
<div class="nav-name">{nav.name}</div>
|
|
30
|
+
<span class="nav-icon folding-icon" class:open={foldingOpen}>
|
|
31
|
+
<IconCaretRight size={10} />
|
|
32
|
+
</span>
|
|
33
|
+
</button>
|
|
34
|
+
<div class="folded-content" class:open={foldingOpen}>
|
|
35
|
+
{#each nav.navs as innerNav}
|
|
36
|
+
<NavItem nav={innerNav} {basepath} {currentSlug} />
|
|
37
|
+
{/each}
|
|
38
|
+
</div>
|
|
39
|
+
{:else if nav.type === 'sub-section'}
|
|
40
|
+
<a {href} class="nav-item">
|
|
41
|
+
<div class="nav-name">{nav.name}</div>
|
|
42
|
+
<span class="nav-icon">
|
|
43
|
+
<IconArrowRight size={10} />
|
|
44
|
+
</span>
|
|
45
|
+
</a>
|
|
46
|
+
{:else}
|
|
47
|
+
<a {href} class="nav-item" class:active={nav.type === 'page' && nav.slug === currentSlug}>
|
|
48
|
+
<div class="nav-name">{nav.name}</div>
|
|
49
|
+
</a>
|
|
50
|
+
{/if}
|
|
51
|
+
|
|
52
|
+
<style>
|
|
53
|
+
.nav-item {
|
|
54
|
+
display: flex;
|
|
55
|
+
align-items: center;
|
|
56
|
+
padding: 7px 22px;
|
|
57
|
+
font-size: 14px;
|
|
58
|
+
border-left: 3px solid transparent;
|
|
59
|
+
transition: 0.1s background-color ease;
|
|
60
|
+
width: 100%;
|
|
61
|
+
text-align: initial;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.nav-item.active {
|
|
65
|
+
border-left: 3px solid var(--accent);
|
|
66
|
+
background-color: var(--accent-lightest);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.nav-item:not(.active):hover {
|
|
70
|
+
background-color: var(--hover);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.nav-name {
|
|
74
|
+
flex: 1;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.folding-icon {
|
|
78
|
+
transition: 0.2s transform ease;
|
|
79
|
+
}
|
|
80
|
+
.folding-icon.open {
|
|
81
|
+
transform: rotate(90deg);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.folded-content {
|
|
85
|
+
display: none;
|
|
86
|
+
padding-left: 14px;
|
|
87
|
+
}
|
|
88
|
+
.folded-content.open {
|
|
89
|
+
display: block;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.folded-content::after {
|
|
93
|
+
content: '';
|
|
94
|
+
display: block;
|
|
95
|
+
}
|
|
96
|
+
</style>
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import type { NavConfig } from './types.js';
|
|
2
|
+
import NavItem from './NavItem.svelte';
|
|
1
3
|
interface Props {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
+
basepath: string;
|
|
5
|
+
nav: NavConfig;
|
|
6
|
+
currentSlug: string;
|
|
4
7
|
}
|
|
5
8
|
declare const NavItem: import("svelte").Component<Props, {}, "">;
|
|
6
9
|
type NavItem = ReturnType<typeof NavItem>;
|