@hyvor/design 2.1.1 → 2.1.3
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/Base/Base.svelte +1 -1
- package/dist/components/Callout/Callout.svelte +72 -20
- package/dist/components/Callout/Callout.svelte.d.ts +6 -1
- package/dist/components/Modal/Modal.svelte +5 -5
- package/dist/components/Modal/Modal.svelte.d.ts +1 -0
- package/dist/components/Modal/portal.d.ts +4 -0
- package/dist/components/Modal/portal.js +25 -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,5 +1,17 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
|
+
import IconCheckCircle from '@hyvor/icons/IconCheckCircle';
|
|
4
|
+
import IconExclamationCircle from '@hyvor/icons/IconExclamationCircle';
|
|
5
|
+
import IconExclamationTriangle from '@hyvor/icons/IconExclamationTriangle';
|
|
6
|
+
import IconInfoCircle from '@hyvor/icons/IconInfoCircle';
|
|
7
|
+
|
|
8
|
+
const defaultIcons = {
|
|
9
|
+
soft: undefined,
|
|
10
|
+
info: IconInfoCircle,
|
|
11
|
+
success: IconCheckCircle,
|
|
12
|
+
warning: IconExclamationCircle,
|
|
13
|
+
danger: IconExclamationTriangle
|
|
14
|
+
};
|
|
3
15
|
|
|
4
16
|
const {
|
|
5
17
|
type = 'soft',
|
|
@@ -7,34 +19,59 @@
|
|
|
7
19
|
children = undefined,
|
|
8
20
|
text = undefined,
|
|
9
21
|
icon = undefined,
|
|
10
|
-
|
|
22
|
+
showIcon = true,
|
|
23
|
+
fg = undefined,
|
|
24
|
+
bg = undefined
|
|
11
25
|
}: {
|
|
12
26
|
type?: 'info' | 'success' | 'warning' | 'danger' | 'soft';
|
|
13
27
|
title?: string | Snippet;
|
|
14
28
|
icon?: Snippet;
|
|
29
|
+
/** Whether to show an icon. Defaults to the icon matching `type`, unless a custom `icon` snippet is given. */
|
|
30
|
+
showIcon?: boolean;
|
|
15
31
|
text?: string | Snippet;
|
|
16
32
|
children?: Snippet;
|
|
17
|
-
|
|
33
|
+
/** Custom text color. Overrides `type`. If `bg` is not set, a matching background is derived from it. */
|
|
34
|
+
fg?: string;
|
|
35
|
+
/** Custom background color. Overrides `type`. If `fg` is not set, a matching text color is derived from it. */
|
|
36
|
+
bg?: string;
|
|
18
37
|
} = $props();
|
|
38
|
+
|
|
39
|
+
const DefaultIcon = $derived(defaultIcons[type]);
|
|
40
|
+
|
|
41
|
+
const style = $derived.by(() => {
|
|
42
|
+
if (fg === undefined && bg === undefined) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const finalFg = fg ?? `color-mix(in srgb, ${bg} 55%, black)`;
|
|
47
|
+
const finalBg = bg ?? `color-mix(in srgb, ${fg} 15%, white)`;
|
|
48
|
+
|
|
49
|
+
return `color: ${finalFg}; background-color: ${finalBg};`;
|
|
50
|
+
});
|
|
19
51
|
</script>
|
|
20
52
|
|
|
21
|
-
|
|
53
|
+
{#snippet iconContent()}
|
|
54
|
+
{#if icon}
|
|
55
|
+
{@render icon()}
|
|
56
|
+
{:else}
|
|
57
|
+
<DefaultIcon />
|
|
58
|
+
{/if}
|
|
59
|
+
{/snippet}
|
|
60
|
+
|
|
61
|
+
<div class={'callout ' + type} {style}>
|
|
22
62
|
{#if typeof title === 'string'}
|
|
23
63
|
<div class="title-wrap">
|
|
24
|
-
{#if
|
|
25
|
-
<span
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
>
|
|
29
|
-
{@render icon()}
|
|
64
|
+
{#if showIcon}
|
|
65
|
+
<span class="title-icon">
|
|
66
|
+
{@render iconContent()}
|
|
30
67
|
</span>
|
|
31
68
|
{/if}
|
|
32
69
|
<div class="title">{title}</div>
|
|
33
70
|
</div>
|
|
34
71
|
{:else if title !== undefined}
|
|
35
72
|
<div class="title-wrap">
|
|
36
|
-
{#if
|
|
37
|
-
<span class="title-icon">{@render
|
|
73
|
+
{#if showIcon}
|
|
74
|
+
<span class="title-icon">{@render iconContent()}</span>
|
|
38
75
|
{/if}
|
|
39
76
|
|
|
40
77
|
<div class="title">{@render title?.()}</div>
|
|
@@ -42,8 +79,8 @@
|
|
|
42
79
|
{/if}
|
|
43
80
|
|
|
44
81
|
<div class="text-wrap">
|
|
45
|
-
{#if
|
|
46
|
-
<span class="icon">{@render
|
|
82
|
+
{#if showIcon && !title}
|
|
83
|
+
<span class="icon">{@render iconContent()}</span>
|
|
47
84
|
{/if}
|
|
48
85
|
|
|
49
86
|
<div class="text">
|
|
@@ -61,7 +98,7 @@
|
|
|
61
98
|
|
|
62
99
|
<style>
|
|
63
100
|
.callout {
|
|
64
|
-
padding:
|
|
101
|
+
padding: 10px 20px;
|
|
65
102
|
border-radius: var(--box-radius);
|
|
66
103
|
line-height: var(--line-height-content);
|
|
67
104
|
}
|
|
@@ -92,16 +129,16 @@
|
|
|
92
129
|
}
|
|
93
130
|
|
|
94
131
|
.title-wrap {
|
|
95
|
-
margin-bottom: 4px;
|
|
96
132
|
display: flex;
|
|
97
133
|
align-items: center;
|
|
98
134
|
font-weight: 600;
|
|
99
|
-
font-size: 18px;
|
|
100
135
|
}
|
|
101
136
|
|
|
102
137
|
.title-icon {
|
|
103
|
-
|
|
104
|
-
|
|
138
|
+
margin-right: 6px;
|
|
139
|
+
display: inline-flex;
|
|
140
|
+
height: var(--line-height-content);
|
|
141
|
+
align-items: center;
|
|
105
142
|
}
|
|
106
143
|
|
|
107
144
|
.text-wrap {
|
|
@@ -110,7 +147,22 @@
|
|
|
110
147
|
}
|
|
111
148
|
|
|
112
149
|
.icon {
|
|
113
|
-
margin-right:
|
|
114
|
-
font-size:
|
|
150
|
+
margin-right: 6px;
|
|
151
|
+
font-size: 16px;
|
|
152
|
+
display: inline-flex;
|
|
153
|
+
height: var(--line-height-content);
|
|
154
|
+
align-items: center;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.text :global(p) {
|
|
158
|
+
margin: 0.5em 0;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.text :global(p:first-child) {
|
|
162
|
+
margin-top: 0;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.text :global(p:last-child) {
|
|
166
|
+
margin-bottom: 0;
|
|
115
167
|
}
|
|
116
168
|
</style>
|
|
@@ -3,9 +3,14 @@ type $$ComponentProps = {
|
|
|
3
3
|
type?: 'info' | 'success' | 'warning' | 'danger' | 'soft';
|
|
4
4
|
title?: string | Snippet;
|
|
5
5
|
icon?: Snippet;
|
|
6
|
+
/** Whether to show an icon. Defaults to the icon matching `type`, unless a custom `icon` snippet is given. */
|
|
7
|
+
showIcon?: boolean;
|
|
6
8
|
text?: string | Snippet;
|
|
7
9
|
children?: Snippet;
|
|
8
|
-
|
|
10
|
+
/** Custom text color. Overrides `type`. If `bg` is not set, a matching background is derived from it. */
|
|
11
|
+
fg?: string;
|
|
12
|
+
/** Custom background color. Overrides `type`. If `fg` is not set, a matching text color is derived from it. */
|
|
13
|
+
bg?: string;
|
|
9
14
|
};
|
|
10
15
|
declare const Callout: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
11
16
|
type Callout = ReturnType<typeof Callout>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import ModalFooter from './ModalFooter.svelte';
|
|
3
3
|
import type { Footer } from './modal-types.js';
|
|
4
|
+
import { portal } from './portal.js';
|
|
4
5
|
import IconX from '@hyvor/icons/IconX';
|
|
5
6
|
import IconButton from './../IconButton/IconButton.svelte';
|
|
6
7
|
import { fade, scale } from 'svelte/transition';
|
|
@@ -15,6 +16,7 @@
|
|
|
15
16
|
width?: string;
|
|
16
17
|
height?: string;
|
|
17
18
|
bare?: boolean;
|
|
19
|
+
appendToBody?: boolean;
|
|
18
20
|
id?: string;
|
|
19
21
|
role?: 'dialog' | 'alertdialog';
|
|
20
22
|
closeOnOutsideClick?: boolean;
|
|
@@ -34,6 +36,7 @@
|
|
|
34
36
|
width,
|
|
35
37
|
height,
|
|
36
38
|
bare = false,
|
|
39
|
+
appendToBody = false,
|
|
37
40
|
id = 'modal',
|
|
38
41
|
role = 'alertdialog',
|
|
39
42
|
closeOnOutsideClick = true,
|
|
@@ -101,6 +104,7 @@
|
|
|
101
104
|
role="presentation"
|
|
102
105
|
class="wrap"
|
|
103
106
|
bind:this={wrapEl}
|
|
107
|
+
use:portal={appendToBody ? '#hds-base' : false}
|
|
104
108
|
transition:fade|global={{ duration: 100 }}
|
|
105
109
|
onclick={(e) => handleClose(e)}
|
|
106
110
|
>
|
|
@@ -127,11 +131,7 @@
|
|
|
127
131
|
|
|
128
132
|
<div class="close-wrap">
|
|
129
133
|
{#if hasClose}
|
|
130
|
-
<IconButton
|
|
131
|
-
variant="invisible"
|
|
132
|
-
on:click={handleCancel}
|
|
133
|
-
aria-label="Close modal"
|
|
134
|
-
>
|
|
134
|
+
<IconButton variant="invisible" on:click={handleCancel} aria-label="Close modal">
|
|
135
135
|
<IconX size={25} />
|
|
136
136
|
</IconButton>
|
|
137
137
|
{/if}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export function portal(node, target = false) {
|
|
2
|
+
const originalParent = node.parentNode;
|
|
3
|
+
const originalNextSibling = node.nextSibling;
|
|
4
|
+
function resolveTarget(t) {
|
|
5
|
+
if (typeof t !== 'string')
|
|
6
|
+
return t;
|
|
7
|
+
return document.querySelector(t) ?? document.body;
|
|
8
|
+
}
|
|
9
|
+
function place(t) {
|
|
10
|
+
if (t === false) {
|
|
11
|
+
if (originalParent && node.parentNode !== originalParent) {
|
|
12
|
+
originalParent.insertBefore(node, originalNextSibling);
|
|
13
|
+
}
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
resolveTarget(t).appendChild(node);
|
|
17
|
+
}
|
|
18
|
+
place(target);
|
|
19
|
+
return {
|
|
20
|
+
update: place,
|
|
21
|
+
destroy() {
|
|
22
|
+
node.remove();
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
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.3",
|
|
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",
|