@hyvor/design 2.0.0-beta.1 → 2.0.1
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/README.md +9 -0
- package/dist/cloud/HyvorBar/BarProducts/BarProducts.svelte +1 -4
- package/dist/cloud/HyvorBar/BarUpdatesList.svelte +1 -3
- package/dist/cloud/HyvorBar/HyvorBar.svelte +0 -2
- package/dist/cloud/HyvorBar/bar.d.ts +1 -1
- package/dist/cloud/OrganizationMembers/OrganizationMembersSearch.svelte +1 -4
- package/dist/cloud/ResourceCreator/Accordian.svelte +2 -4
- package/dist/components/Accordion/Accordion.svelte +134 -134
- package/dist/components/ActionList/ActionList.svelte +2 -8
- package/dist/components/ActionList/ActionListGroup.svelte +1 -5
- package/dist/components/ActionList/ActionListItem.svelte +7 -7
- package/dist/components/Button/Button.svelte +2 -12
- package/dist/components/CodeBlock/CodeBlock.svelte +45 -28
- package/dist/components/CodeBlock/CodeBlock.svelte.d.ts +2 -3
- package/dist/components/CodeBlock/TabbedCodeBlock.svelte +60 -64
- package/dist/components/CodeBlock/TabbedCodeBlock.svelte.d.ts +1 -1
- package/dist/components/CodeBlock/getCode.d.ts +3 -1
- package/dist/components/CodeBlock/getCode.js +33 -50
- package/dist/components/ColorPicker/ColorPicker.svelte +1 -1
- package/dist/components/Dark/DarkProvider.svelte +1 -1
- package/dist/components/DetailCard/DetailCard.svelte +43 -46
- package/dist/components/DetailCard/DetailCard.svelte.d.ts +1 -1
- package/dist/components/DetailCard/DetailCards.svelte +13 -16
- package/dist/components/DetailCard/DetailCards.svelte.d.ts +1 -1
- package/dist/components/Dropdown/DropdownContent.svelte +1 -2
- package/dist/components/EmojiPicker/EmojiSelector.svelte +3 -14
- package/dist/components/EmojiPicker/emojidata.js +3 -3
- package/dist/components/FileUploader/Preview/Preview.svelte +1 -1
- package/dist/components/FileUploader/TabUpload/TabUpload.svelte +2 -4
- package/dist/components/FileUploader/file-uploader.js +5 -10
- package/dist/components/FileUploader/helpers.js +1 -1
- package/dist/components/IconButton/IconButton.svelte +2 -10
- package/dist/components/IconMessage/IconMessage.svelte +29 -44
- package/dist/components/Internationalization/LanguageToggle.svelte +2 -2
- package/dist/components/Internationalization/T.svelte +2 -9
- package/dist/components/Internationalization/i18n.js +3 -1
- package/dist/components/Loader/Loader.svelte +1 -3
- package/dist/components/Modal/ConfirmModalProvider.svelte +1 -3
- package/dist/components/Modal/Modal.svelte +16 -12
- package/dist/components/TabNav/TabNav.svelte +0 -2
- package/dist/components/TextInput/TextInput.svelte +29 -52
- package/dist/components/TextInput/TextInput.svelte.d.ts +5 -3
- package/dist/components/Textarea/Textarea.svelte +84 -98
- package/dist/index.css +4 -4
- package/dist/legacy.js +2 -2
- package/dist/marketing/Affiliate/Affiliate.svelte +53 -51
- package/dist/marketing/Container/Container.svelte +4 -5
- package/dist/marketing/Docs/Nav/Nav.svelte +1 -2
- package/dist/marketing/Footer/Footer.svelte +2 -2
- package/dist/marketing/Header/Header.svelte +131 -140
- package/dist/marketing/Header/Header.svelte.d.ts +3 -1
- package/dist/marketing/Header/HeaderNotification.svelte +64 -0
- package/dist/marketing/Header/HeaderNotification.svelte.d.ts +7 -0
- package/dist/marketing/cloud.d.ts +1 -0
- package/dist/marketing/cloud.js +15 -0
- package/dist/marketing/track/track.d.ts +0 -1
- package/dist/marketing/track/track.js +3 -6
- package/dist/variables.scss +1 -1
- package/package.json +24 -22
- package/dist/components/CodeBlock/hljs.scss +0 -228
- package/dist/components/CodeBlock/prism.scss +0 -375
package/README.md
CHANGED
|
@@ -14,4 +14,13 @@ docker compose up
|
|
|
14
14
|
|
|
15
15
|
# visit https://design.hyvor.localhost
|
|
16
16
|
# API calls will work as long as you set instance to https://hyvor.localhost
|
|
17
|
+
## Commands
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# fix prettier
|
|
22
|
+
npm run format
|
|
23
|
+
|
|
24
|
+
# fix prettier via Docker (recommended for compatibility issues with CI)
|
|
25
|
+
docker compose run design npm run format
|
|
17
26
|
```
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import BarUser from './BarUser.svelte';
|
|
3
|
-
import { onMount } from 'svelte';
|
|
4
3
|
import BarProducts from './BarProducts/BarProducts.svelte';
|
|
5
4
|
import BarSupport from './BarSupport.svelte';
|
|
6
5
|
import { initBar, type BarConfig } from './bar.js';
|
|
@@ -11,7 +10,6 @@
|
|
|
11
10
|
import BarOrganization from './Organization/BarOrganization.svelte';
|
|
12
11
|
import { cloudContextId, getCloudContext } from '../CloudContext/cloudContext.svelte.js';
|
|
13
12
|
import { PRODUCTS } from './BarProducts/products.js';
|
|
14
|
-
import { get } from 'svelte/store';
|
|
15
13
|
|
|
16
14
|
interface Props {
|
|
17
15
|
config?: Partial<BarConfig>;
|
|
@@ -12,7 +12,7 @@ export interface BarUpdate {
|
|
|
12
12
|
content: string;
|
|
13
13
|
url?: string;
|
|
14
14
|
}
|
|
15
|
-
export type BarUpdateType = 'company' | 'core' | 'talk' | 'blogs' | 'fortguard';
|
|
15
|
+
export type BarUpdateType = 'company' | 'core' | 'talk' | 'blogs' | 'post' | 'relay' | 'fortguard';
|
|
16
16
|
export declare const barUnreadUpdates: import("svelte/store").Writable<number>;
|
|
17
17
|
export declare const barHasFailedInvoices: import("svelte/store").Writable<boolean>;
|
|
18
18
|
export declare function initBar(): Promise<void>;
|
|
@@ -2,10 +2,7 @@
|
|
|
2
2
|
import { clickOutside, IconMessage, toast } from '../../components/index.js';
|
|
3
3
|
import Loader from '../../components/Loader/Loader.svelte';
|
|
4
4
|
import TextInput from '../../components/TextInput/TextInput.svelte';
|
|
5
|
-
import {
|
|
6
|
-
getCloudContext,
|
|
7
|
-
type OrganizationMember
|
|
8
|
-
} from '../CloudContext/cloudContext.svelte.js';
|
|
5
|
+
import { getCloudContext, type OrganizationMember } from '../CloudContext/cloudContext.svelte.js';
|
|
9
6
|
import { searchMembers } from './members.js';
|
|
10
7
|
import { dropdownSlide } from '../../components/Dropdown/dropdownSlide.js';
|
|
11
8
|
import UserPicture from '../@components/UserPicture.svelte';
|
|
@@ -94,10 +94,8 @@
|
|
|
94
94
|
{#if loading}
|
|
95
95
|
<Loader size="small" />
|
|
96
96
|
{/if}
|
|
97
|
-
<Button
|
|
98
|
-
|
|
99
|
-
onclick={onButtonClick}
|
|
100
|
-
disabled={loading || buttonDisabled}>{buttonText}</Button
|
|
97
|
+
<Button size="large" onclick={onButtonClick} disabled={loading || buttonDisabled}
|
|
98
|
+
>{buttonText}</Button
|
|
101
99
|
>
|
|
102
100
|
</div>
|
|
103
101
|
</div>
|
|
@@ -1,143 +1,143 @@
|
|
|
1
1
|
<script lang="ts">
|
|
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
|
-
|
|
2
|
+
import type { Component, Snippet } from 'svelte';
|
|
3
|
+
import IconCaretDownFill from '@hyvor/icons/IconCaretDownFill';
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
title: string;
|
|
7
|
+
children?: Snippet;
|
|
8
|
+
open?: boolean;
|
|
9
|
+
icon?: Component;
|
|
10
|
+
headerColor?: string;
|
|
11
|
+
textColor?: string;
|
|
12
|
+
openedColor?: string;
|
|
13
|
+
borderColor?: string;
|
|
14
|
+
topBorderColor?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
let {
|
|
18
|
+
title,
|
|
19
|
+
children,
|
|
20
|
+
open = $bindable(false),
|
|
21
|
+
icon,
|
|
22
|
+
headerColor,
|
|
23
|
+
textColor,
|
|
24
|
+
openedColor,
|
|
25
|
+
borderColor,
|
|
26
|
+
topBorderColor
|
|
27
|
+
}: Props = $props();
|
|
28
|
+
|
|
29
|
+
const Icon = icon;
|
|
30
|
+
|
|
31
|
+
function handleClick() {
|
|
32
|
+
open = !open;
|
|
33
|
+
}
|
|
34
34
|
</script>
|
|
35
35
|
|
|
36
36
|
<div
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
class="accordion-item"
|
|
38
|
+
style:--custom-border={borderColor}
|
|
39
|
+
style:--custom-text={textColor}
|
|
40
|
+
style:--custom-opened={openedColor}
|
|
41
|
+
style:--custom-header={headerColor}
|
|
42
42
|
>
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
43
|
+
<button class="accordion-header" class:open onclick={handleClick}>
|
|
44
|
+
{#if icon}
|
|
45
|
+
<span class="icon">
|
|
46
|
+
<Icon size={20} />
|
|
47
|
+
</span>
|
|
48
|
+
{/if}
|
|
49
|
+
<span class="title">{title}</span>
|
|
50
|
+
<span class="chevron" class:rotated={open}>
|
|
51
|
+
<IconCaretDownFill />
|
|
52
|
+
</span>
|
|
53
|
+
</button>
|
|
54
|
+
|
|
55
|
+
<div class="accordion-content" class:show={open}>
|
|
56
|
+
<div
|
|
57
|
+
class="content-text"
|
|
58
|
+
style:--custom-top-border={topBorderColor}
|
|
59
|
+
style:--custom-header={headerColor}
|
|
60
|
+
>
|
|
61
|
+
{@render children?.()}
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
64
|
</div>
|
|
65
65
|
|
|
66
66
|
<style>
|
|
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
|
-
|
|
67
|
+
.accordion-item {
|
|
68
|
+
overflow: hidden;
|
|
69
|
+
border-radius: 20px;
|
|
70
|
+
border: 1px solid var(--custom-border, var(--border));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.accordion-header {
|
|
74
|
+
width: 100%;
|
|
75
|
+
padding: 14px 20px;
|
|
76
|
+
background: var(--custom-header, none);
|
|
77
|
+
border: none;
|
|
78
|
+
display: flex;
|
|
79
|
+
justify-content: space-between;
|
|
80
|
+
align-items: center;
|
|
81
|
+
cursor: pointer;
|
|
82
|
+
font-size: 16px;
|
|
83
|
+
border-radius: 20px;
|
|
84
|
+
color: var(--custom-text, var(--text));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.accordion-header.open {
|
|
88
|
+
border-radius: 20px 20px 0 0;
|
|
89
|
+
background-color: var(--custom-opened, var(--hover));
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.title {
|
|
93
|
+
font-weight: 500;
|
|
94
|
+
text-align: left;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.chevron {
|
|
98
|
+
display: flex;
|
|
99
|
+
align-items: center;
|
|
100
|
+
transition: transform 0.3s ease;
|
|
101
|
+
color: var(--custom-text, var(--text));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.chevron.rotated {
|
|
105
|
+
transform: rotate(180deg);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.accordion-content {
|
|
109
|
+
height: 0;
|
|
110
|
+
overflow: hidden;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.accordion-content.show {
|
|
114
|
+
height: auto;
|
|
115
|
+
overflow: visible;
|
|
116
|
+
animation: slideDown 0.3s ease-out;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.content-text {
|
|
120
|
+
padding: 20px;
|
|
121
|
+
color: var(--custom-text, var(--text));
|
|
122
|
+
line-height: 1.6;
|
|
123
|
+
border-top: 1px solid var(--custom-top-border, var(--border));
|
|
124
|
+
background: var(--custom-header, none);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.icon {
|
|
128
|
+
display: inline-block;
|
|
129
|
+
margin-right: 10px;
|
|
130
|
+
vertical-align: middle;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
@keyframes slideDown {
|
|
134
|
+
from {
|
|
135
|
+
opacity: 0;
|
|
136
|
+
transform: translateY(-10px);
|
|
137
|
+
}
|
|
138
|
+
to {
|
|
139
|
+
opacity: 1;
|
|
140
|
+
transform: translateY(0);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
143
|
</style>
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { run } from 'svelte/legacy';
|
|
3
|
-
|
|
4
2
|
import { setContext } from 'svelte';
|
|
5
3
|
|
|
6
4
|
interface Props {
|
|
@@ -12,12 +10,8 @@
|
|
|
12
10
|
|
|
13
11
|
let { selection = 'none', selectionAlign = 'start', children, ...rest }: Props = $props();
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
});
|
|
18
|
-
run(() => {
|
|
19
|
-
setContext('action-list-selection-align', selectionAlign);
|
|
20
|
-
});
|
|
13
|
+
setContext('action-list-selection', () => selection);
|
|
14
|
+
setContext('action-list-selection-align', () => selectionAlign);
|
|
21
15
|
</script>
|
|
22
16
|
|
|
23
17
|
<div class="action-list" {...rest}>
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { run } from 'svelte/legacy';
|
|
3
|
-
|
|
4
2
|
import { setContext } from 'svelte';
|
|
5
3
|
|
|
6
4
|
interface Props {
|
|
@@ -12,9 +10,7 @@
|
|
|
12
10
|
|
|
13
11
|
let { title = undefined, divider = false, selection = undefined, children }: Props = $props();
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
if (selection !== undefined) setContext('action-list-selection', selection);
|
|
17
|
-
});
|
|
13
|
+
setContext('action-list-selection', () => selection);
|
|
18
14
|
</script>
|
|
19
15
|
|
|
20
16
|
<div class="action-list-group" class:has-divider={divider}>
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
import { getContext, createEventDispatcher } from 'svelte';
|
|
6
6
|
import Selected from './Selected.svelte';
|
|
7
7
|
|
|
8
|
-
const selection: 'none' | 'single' | 'multi' = getContext('action-list-selection');
|
|
9
|
-
const selectionAlign: 'start' | 'end' = getContext('action-list-selection-align');
|
|
8
|
+
const selection: () => 'none' | 'single' | 'multi' = getContext('action-list-selection');
|
|
9
|
+
const selectionAlign: () => 'start' | 'end' = getContext('action-list-selection-align');
|
|
10
10
|
|
|
11
11
|
interface Props {
|
|
12
12
|
selected?: boolean;
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
...rest
|
|
31
31
|
}: Props = $props();
|
|
32
32
|
|
|
33
|
-
selected = selection !== 'none' && selected;
|
|
33
|
+
selected = selection() !== 'none' && selected;
|
|
34
34
|
|
|
35
35
|
const dispatch = createEventDispatcher();
|
|
36
36
|
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
}}
|
|
54
54
|
{...rest}
|
|
55
55
|
>
|
|
56
|
-
{#if selectionAlign === 'start'}
|
|
57
|
-
<Selected {selection} bind:selected />
|
|
56
|
+
{#if selectionAlign() === 'start'}
|
|
57
|
+
<Selected selection={selection()} bind:selected />
|
|
58
58
|
{/if}
|
|
59
59
|
|
|
60
60
|
{#if start}
|
|
@@ -79,8 +79,8 @@
|
|
|
79
79
|
</span>
|
|
80
80
|
{/if}
|
|
81
81
|
|
|
82
|
-
{#if selectionAlign === 'end'}
|
|
83
|
-
<Selected {selection} bind:selected />
|
|
82
|
+
{#if selectionAlign() === 'end'}
|
|
83
|
+
<Selected selection={selection()} bind:selected />
|
|
84
84
|
{/if}
|
|
85
85
|
</div>
|
|
86
86
|
|
|
@@ -62,7 +62,6 @@
|
|
|
62
62
|
this={as}
|
|
63
63
|
class="button {size} {color} {variant} {align}"
|
|
64
64
|
class:block
|
|
65
|
-
|
|
66
65
|
onkeyup={legacyHandlers(onkeyup, bubble('keyup'))}
|
|
67
66
|
onkeydown={legacyHandlers(onkeydown, bubble('keydown'))}
|
|
68
67
|
onkeypress={legacyHandlers(onkeypress, bubble('keypress'))}
|
|
@@ -73,7 +72,6 @@
|
|
|
73
72
|
onmouseenter={legacyHandlers(onmouseenter, bubble('mouseenter'))}
|
|
74
73
|
onmouseleave={legacyHandlers(onmouseleave, bubble('mouseleave'))}
|
|
75
74
|
onchange={legacyHandlers(onchange, bubble('change'))}
|
|
76
|
-
|
|
77
75
|
role="button"
|
|
78
76
|
tabindex="0"
|
|
79
77
|
bind:this={button}
|
|
@@ -282,11 +280,7 @@
|
|
|
282
280
|
background-color: var(--orange-light);
|
|
283
281
|
color: var(--orange-dark);
|
|
284
282
|
transition: 0.2s box-shadow;
|
|
285
|
-
--local-hover-shadow-color: color-mix(
|
|
286
|
-
in srgb,
|
|
287
|
-
var(--orange-light) 40%,
|
|
288
|
-
transparent
|
|
289
|
-
);
|
|
283
|
+
--local-hover-shadow-color: color-mix(in srgb, var(--orange-light) 40%, transparent);
|
|
290
284
|
}
|
|
291
285
|
.button.outline {
|
|
292
286
|
border: 1px solid;
|
|
@@ -341,11 +335,7 @@
|
|
|
341
335
|
border-color: var(--accent);
|
|
342
336
|
color: var(--accent);
|
|
343
337
|
transition: 0.2s box-shadow;
|
|
344
|
-
--local-hover-shadow-color: color-mix(
|
|
345
|
-
in srgb,
|
|
346
|
-
var(--accent-light) 40%,
|
|
347
|
-
transparent
|
|
348
|
-
);
|
|
338
|
+
--local-hover-shadow-color: color-mix(in srgb, var(--accent-light) 40%, transparent);
|
|
349
339
|
}
|
|
350
340
|
.button.outline-fill.gray {
|
|
351
341
|
background-color: var(--gray-light);
|
|
@@ -1,39 +1,52 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
import '
|
|
2
|
+
import Button from '../Button/Button.svelte';
|
|
3
|
+
import IconCopy from '@hyvor/icons/IconCopy';
|
|
4
|
+
import toast from '../Toast/toast.js';
|
|
5
|
+
import { getCode, sanitizeLines, type Language } from './getCode.js';
|
|
4
6
|
|
|
5
|
-
type InputLanguage = 'html' | 'css' | 'js' | 'ts' | 'yaml' | 'json' | 'svelte' | 'jsx' | 'php';
|
|
6
|
-
|
|
7
|
-
const languagesMap: Partial<Record<InputLanguage, Language>> = {
|
|
8
|
-
svelte: 'html',
|
|
9
|
-
jsx: 'js'
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
type Language = any;
|
|
13
|
-
|
|
14
|
-
// import getCode, { type Language } from './getCode.js';
|
|
15
7
|
interface Props {
|
|
16
8
|
code: string;
|
|
17
|
-
language?:
|
|
9
|
+
language?: Language | null;
|
|
18
10
|
}
|
|
19
11
|
|
|
20
12
|
let { code, language = 'html' }: Props = $props();
|
|
21
13
|
|
|
22
|
-
let
|
|
23
|
-
language ? languagesMap[language] || language : null
|
|
24
|
-
) as Language | null;
|
|
14
|
+
let sanitizedCode = $derived(sanitizeLines(code));
|
|
25
15
|
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
|
|
16
|
+
function copyToClipboard() {
|
|
17
|
+
navigator.clipboard.writeText(sanitizedCode);
|
|
18
|
+
toast.success('Copied');
|
|
29
19
|
}
|
|
30
20
|
</script>
|
|
31
21
|
|
|
32
|
-
<
|
|
22
|
+
<div class="code-container">
|
|
23
|
+
<div class="copy-button">
|
|
24
|
+
<Button color="input" size="x-small" onclick={copyToClipboard}>
|
|
25
|
+
<IconCopy size={10} />
|
|
26
|
+
</Button>
|
|
27
|
+
</div>
|
|
28
|
+
{@html await getCode(sanitizedCode, language)}
|
|
29
|
+
</div>
|
|
33
30
|
|
|
34
31
|
<style>
|
|
35
32
|
/*styles for CodeBlock component */
|
|
36
|
-
|
|
33
|
+
.code-container {
|
|
34
|
+
position: relative;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.code-container .copy-button {
|
|
38
|
+
position: absolute;
|
|
39
|
+
top: 0px;
|
|
40
|
+
right: 12px;
|
|
41
|
+
transform: translateY(-40%);
|
|
42
|
+
z-index: 10;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.copy-button :global(button) {
|
|
46
|
+
border: 1px solid var(--border);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.code-container :global(pre) {
|
|
37
50
|
text-align: left;
|
|
38
51
|
white-space: pre;
|
|
39
52
|
word-spacing: normal;
|
|
@@ -43,18 +56,22 @@
|
|
|
43
56
|
border-radius: 20px;
|
|
44
57
|
padding: 20px;
|
|
45
58
|
line-height: 1.2;
|
|
59
|
+
background-color: #f4f2f0 !important;
|
|
46
60
|
}
|
|
47
|
-
|
|
61
|
+
|
|
62
|
+
.code-container :global(pre code) {
|
|
48
63
|
all: unset;
|
|
49
|
-
font-family:
|
|
50
|
-
Consolas,
|
|
51
|
-
Monaco,
|
|
52
|
-
Andale Mono,
|
|
53
|
-
Ubuntu Mono,
|
|
54
|
-
monospace;
|
|
55
64
|
font-size: 14px;
|
|
56
65
|
line-height: 1.5 !important;
|
|
57
66
|
tab-size: 4;
|
|
58
67
|
hyphens: none;
|
|
59
68
|
}
|
|
69
|
+
|
|
70
|
+
:global(:root.dark .shiki, :root.dark .shiki span) {
|
|
71
|
+
color: var(--shiki-dark) !important;
|
|
72
|
+
background-color: var(--shiki-dark-bg) !important;
|
|
73
|
+
font-style: var(--shiki-dark-font-style) !important;
|
|
74
|
+
font-weight: var(--shiki-dark-font-weight) !important;
|
|
75
|
+
text-decoration: var(--shiki-dark-text-decoration) !important;
|
|
76
|
+
}
|
|
60
77
|
</style>
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import './
|
|
2
|
-
type InputLanguage = 'html' | 'css' | 'js' | 'ts' | 'yaml' | 'json' | 'svelte' | 'jsx' | 'php';
|
|
1
|
+
import { type Language } from './getCode.js';
|
|
3
2
|
interface Props {
|
|
4
3
|
code: string;
|
|
5
|
-
language?:
|
|
4
|
+
language?: Language | null;
|
|
6
5
|
}
|
|
7
6
|
declare const CodeBlock: import("svelte").Component<Props, {}, "">;
|
|
8
7
|
type CodeBlock = ReturnType<typeof CodeBlock>;
|