@hyvor/design 2.1.2 → 2.1.4
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/components/TabNav/TabNav.svelte +38 -6
- package/dist/components/TabNav/TabNav.svelte.d.ts +12 -3
- package/dist/components/TabNav/TabNavItem.svelte +9 -5
- package/dist/components/TabNav/tabnav.d.ts +4 -0
- package/dist/index.css +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/marketing/Docs/Docs.svelte +59 -4
- package/dist/marketing/Docs/NavItem.svelte +14 -4
- package/dist/variables.scss +4 -1
- package/package.json +2 -1
|
@@ -1,17 +1,49 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { setContext } from 'svelte';
|
|
3
|
+
import type { TabNavState } from './tabnav.js';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
type Props = (
|
|
6
|
+
| {
|
|
7
|
+
basePath?: undefined;
|
|
8
|
+
pathname?: undefined;
|
|
9
|
+
goto?: undefined;
|
|
10
|
+
}
|
|
11
|
+
| {
|
|
12
|
+
basePath: string;
|
|
13
|
+
// SvelteKit's `page.url.pathname`, e.g. `import { page } from '$app/state'`.
|
|
14
|
+
pathname: string;
|
|
15
|
+
// SvelteKit's `goto`, e.g. `import { goto } from '$app/navigation'`.
|
|
16
|
+
goto: (url: string, opts?: { replaceState?: boolean }) => void;
|
|
17
|
+
}
|
|
18
|
+
) & {
|
|
6
19
|
replaceState?: boolean;
|
|
7
20
|
children?: import('svelte').Snippet;
|
|
8
|
-
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
let { children, basePath, replaceState = false, pathname: pathnameProp, goto }: Props = $props();
|
|
24
|
+
|
|
25
|
+
let fallbackPathname = $state(typeof window !== 'undefined' ? window.location.pathname : '');
|
|
26
|
+
|
|
27
|
+
$effect(() => {
|
|
28
|
+
if (!basePath || pathnameProp !== undefined) return;
|
|
9
29
|
|
|
10
|
-
|
|
30
|
+
const onPopState = () => {
|
|
31
|
+
fallbackPathname = window.location.pathname;
|
|
32
|
+
};
|
|
33
|
+
window.addEventListener('popstate', onPopState);
|
|
34
|
+
return () => window.removeEventListener('popstate', onPopState);
|
|
35
|
+
});
|
|
11
36
|
|
|
12
|
-
const tabNavState = {
|
|
37
|
+
const tabNavState: TabNavState = {
|
|
13
38
|
basePath,
|
|
14
|
-
replaceState
|
|
39
|
+
replaceState,
|
|
40
|
+
goto,
|
|
41
|
+
get pathname() {
|
|
42
|
+
return pathnameProp ?? fallbackPathname;
|
|
43
|
+
},
|
|
44
|
+
set pathname(value: string) {
|
|
45
|
+
fallbackPathname = value;
|
|
46
|
+
}
|
|
15
47
|
};
|
|
16
48
|
|
|
17
49
|
setContext('tab-nav-state', tabNavState);
|
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
basePath?:
|
|
1
|
+
type Props = ({
|
|
2
|
+
basePath?: undefined;
|
|
3
|
+
pathname?: undefined;
|
|
4
|
+
goto?: undefined;
|
|
5
|
+
} | {
|
|
6
|
+
basePath: string;
|
|
7
|
+
pathname: string;
|
|
8
|
+
goto: (url: string, opts?: {
|
|
9
|
+
replaceState?: boolean;
|
|
10
|
+
}) => void;
|
|
11
|
+
}) & {
|
|
3
12
|
replaceState?: boolean;
|
|
4
13
|
children?: import('svelte').Snippet;
|
|
5
|
-
}
|
|
14
|
+
};
|
|
6
15
|
declare const TabNav: import("svelte").Component<Props, {}, "">;
|
|
7
16
|
type TabNav = ReturnType<typeof TabNav>;
|
|
8
17
|
export default TabNav;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { getContext } from 'svelte';
|
|
3
|
-
import { page } from '$app/state';
|
|
4
|
-
import { goto } from '$app/navigation';
|
|
5
3
|
import type { TabNavState } from './tabnav.js';
|
|
6
4
|
|
|
7
5
|
interface Props {
|
|
@@ -28,8 +26,7 @@
|
|
|
28
26
|
if (active) return true;
|
|
29
27
|
|
|
30
28
|
if (tabNavState.basePath) {
|
|
31
|
-
|
|
32
|
-
return currentUrl === getTabPath();
|
|
29
|
+
return tabNavState.pathname === getTabPath();
|
|
33
30
|
}
|
|
34
31
|
|
|
35
32
|
return false;
|
|
@@ -37,7 +34,14 @@
|
|
|
37
34
|
|
|
38
35
|
function handleClick(event: MouseEvent) {
|
|
39
36
|
if (tabNavState.basePath) {
|
|
40
|
-
|
|
37
|
+
const path = getTabPath();
|
|
38
|
+
|
|
39
|
+
if (tabNavState.goto) {
|
|
40
|
+
tabNavState.goto(path, { replaceState: tabNavState.replaceState });
|
|
41
|
+
tabNavState.pathname = path;
|
|
42
|
+
} else {
|
|
43
|
+
window.location.href = path;
|
|
44
|
+
}
|
|
41
45
|
}
|
|
42
46
|
onclick?.(event);
|
|
43
47
|
}
|
package/dist/index.css
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -64,6 +64,7 @@
|
|
|
64
64
|
<div class="nav-wrap">
|
|
65
65
|
<button
|
|
66
66
|
class="mobile-toggle hds-box"
|
|
67
|
+
class:open={mobileNavOpen}
|
|
67
68
|
onclick={(e) => {
|
|
68
69
|
e.stopPropagation();
|
|
69
70
|
mobileNavOpen = !mobileNavOpen;
|
|
@@ -76,7 +77,9 @@
|
|
|
76
77
|
{/if}
|
|
77
78
|
<span class="name">{page.name}</span>
|
|
78
79
|
</div>
|
|
79
|
-
<
|
|
80
|
+
<span class="mobile-toggle-icon">
|
|
81
|
+
<IconList size={18} />
|
|
82
|
+
</span>
|
|
80
83
|
</button>
|
|
81
84
|
|
|
82
85
|
<nav
|
|
@@ -113,9 +116,11 @@
|
|
|
113
116
|
</div>
|
|
114
117
|
|
|
115
118
|
<div class="content-wrap hds-box">
|
|
116
|
-
|
|
117
|
-
<page.
|
|
118
|
-
|
|
119
|
+
{#key page.slug}
|
|
120
|
+
<content class:wide={page.wide} bind:this={contentEl}>
|
|
121
|
+
<page.content />
|
|
122
|
+
</content>
|
|
123
|
+
{/key}
|
|
119
124
|
</div>
|
|
120
125
|
|
|
121
126
|
{#if !page.wide}
|
|
@@ -175,6 +180,7 @@
|
|
|
175
180
|
width: 100%;
|
|
176
181
|
padding: 10px 20px;
|
|
177
182
|
cursor: pointer;
|
|
183
|
+
transition: 0.15s background-color ease;
|
|
178
184
|
}
|
|
179
185
|
.mobile-toggle:hover {
|
|
180
186
|
background-color: var(--hover);
|
|
@@ -184,6 +190,14 @@
|
|
|
184
190
|
flex: 1;
|
|
185
191
|
text-align: left;
|
|
186
192
|
}
|
|
193
|
+
|
|
194
|
+
.mobile-toggle-icon {
|
|
195
|
+
display: inline-flex;
|
|
196
|
+
transition: 0.2s transform ease;
|
|
197
|
+
}
|
|
198
|
+
.mobile-toggle.open .mobile-toggle-icon {
|
|
199
|
+
transform: rotate(90deg);
|
|
200
|
+
}
|
|
187
201
|
.category,
|
|
188
202
|
.sep {
|
|
189
203
|
color: var(--text-light);
|
|
@@ -204,6 +218,18 @@
|
|
|
204
218
|
}
|
|
205
219
|
nav.open {
|
|
206
220
|
display: block;
|
|
221
|
+
animation: nav-open 0.2s ease-out;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
@keyframes nav-open {
|
|
226
|
+
from {
|
|
227
|
+
opacity: 0;
|
|
228
|
+
transform: translateY(-6px);
|
|
229
|
+
}
|
|
230
|
+
to {
|
|
231
|
+
opacity: 1;
|
|
232
|
+
transform: translateY(0);
|
|
207
233
|
}
|
|
208
234
|
}
|
|
209
235
|
|
|
@@ -261,6 +287,11 @@
|
|
|
261
287
|
flex: 1;
|
|
262
288
|
padding: 30px 45px;
|
|
263
289
|
min-width: 0;
|
|
290
|
+
background-image: radial-gradient(
|
|
291
|
+
ellipse 700px 300px at top right,
|
|
292
|
+
var(--accent-lightest),
|
|
293
|
+
transparent 70%
|
|
294
|
+
);
|
|
264
295
|
}
|
|
265
296
|
|
|
266
297
|
content {
|
|
@@ -268,11 +299,23 @@
|
|
|
268
299
|
margin: auto;
|
|
269
300
|
width: 650px;
|
|
270
301
|
max-width: 100%;
|
|
302
|
+
animation: content-in 0.35s ease;
|
|
271
303
|
}
|
|
272
304
|
content.wide {
|
|
273
305
|
width: 100%;
|
|
274
306
|
}
|
|
275
307
|
|
|
308
|
+
@keyframes content-in {
|
|
309
|
+
from {
|
|
310
|
+
opacity: 0;
|
|
311
|
+
transform: translateY(6px);
|
|
312
|
+
}
|
|
313
|
+
to {
|
|
314
|
+
opacity: 1;
|
|
315
|
+
transform: translateY(0);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
276
319
|
/* content styles */
|
|
277
320
|
|
|
278
321
|
content :global(p),
|
|
@@ -288,6 +331,7 @@
|
|
|
288
331
|
margin: 0 0 30px;
|
|
289
332
|
position: relative;
|
|
290
333
|
display: table;
|
|
334
|
+
font-family: var(--font-serif);
|
|
291
335
|
&:after {
|
|
292
336
|
position: absolute;
|
|
293
337
|
content: '';
|
|
@@ -295,6 +339,7 @@
|
|
|
295
339
|
left: 0px;
|
|
296
340
|
width: 30%;
|
|
297
341
|
height: 3px;
|
|
342
|
+
border-radius: 2px;
|
|
298
343
|
background: var(--accent);
|
|
299
344
|
margin-top: 10px;
|
|
300
345
|
}
|
|
@@ -302,6 +347,14 @@
|
|
|
302
347
|
content :global(a:not(.no-link-color a)) {
|
|
303
348
|
color: var(--link);
|
|
304
349
|
text-decoration: underline;
|
|
350
|
+
text-decoration-color: color-mix(in srgb, var(--link) 40%, transparent);
|
|
351
|
+
transition: 0.15s text-decoration-color ease;
|
|
352
|
+
}
|
|
353
|
+
content :global(a:not(.no-link-color a):hover) {
|
|
354
|
+
text-decoration-color: var(--link);
|
|
355
|
+
}
|
|
356
|
+
content :global(p) {
|
|
357
|
+
margin: 0 0 16px;
|
|
305
358
|
}
|
|
306
359
|
content :global(li) {
|
|
307
360
|
margin-bottom: 8px;
|
|
@@ -340,6 +393,8 @@
|
|
|
340
393
|
transform: translateY(-50%);
|
|
341
394
|
display: inline-flex;
|
|
342
395
|
align-items: center;
|
|
396
|
+
color: var(--accent-light);
|
|
397
|
+
transition: 0.15s opacity ease;
|
|
343
398
|
}
|
|
344
399
|
|
|
345
400
|
content {
|
|
@@ -53,19 +53,29 @@
|
|
|
53
53
|
.nav-item {
|
|
54
54
|
display: flex;
|
|
55
55
|
align-items: center;
|
|
56
|
-
padding: 7px
|
|
56
|
+
padding: 7px 25px;
|
|
57
57
|
font-size: 14px;
|
|
58
|
-
|
|
59
|
-
transition: 0.
|
|
58
|
+
position: relative;
|
|
59
|
+
transition: 0.15s background-color ease;
|
|
60
60
|
width: 100%;
|
|
61
61
|
text-align: initial;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
.nav-item.active {
|
|
65
|
-
border-left: 3px solid var(--accent);
|
|
66
65
|
background-color: var(--accent-lightest);
|
|
67
66
|
}
|
|
68
67
|
|
|
68
|
+
.nav-item.active::before {
|
|
69
|
+
content: '';
|
|
70
|
+
position: absolute;
|
|
71
|
+
left: 0;
|
|
72
|
+
top: 2px;
|
|
73
|
+
bottom: 2px;
|
|
74
|
+
width: 3px;
|
|
75
|
+
border-radius: 2px;
|
|
76
|
+
background: var(--accent);
|
|
77
|
+
}
|
|
78
|
+
|
|
69
79
|
.nav-item:not(.active):hover {
|
|
70
80
|
background-color: var(--hover);
|
|
71
81
|
}
|
package/dist/variables.scss
CHANGED
|
@@ -55,8 +55,11 @@
|
|
|
55
55
|
--box-radius: 20px;
|
|
56
56
|
--box-background: #fff;
|
|
57
57
|
|
|
58
|
-
--line-height-content:
|
|
58
|
+
--line-height-content: 28px;
|
|
59
59
|
--header-height: 55px;
|
|
60
|
+
|
|
61
|
+
--font-sans-serif: 'Readex Pro', Avenir, Inter, Helvetica, Arial, sans-serif;
|
|
62
|
+
--font-serif: 'Source Serif 4', serif;
|
|
60
63
|
}
|
|
61
64
|
|
|
62
65
|
:root.dark {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyvor/design",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"private": false,
|
|
6
6
|
"repository": {
|
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"@apidevtools/json-schema-ref-parser": "^15.5.1",
|
|
62
62
|
"@fontsource/readex-pro": "^5.2.11",
|
|
63
|
+
"@fontsource/source-serif-4": "^5.3.0",
|
|
63
64
|
"@hyvor/icons": "^1.1.1",
|
|
64
65
|
"deepmerge-ts": "^7.1.5",
|
|
65
66
|
"emojibase-data": "^17.0.0",
|