sve-ui 0.0.7 → 0.0.9
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.
|
@@ -2,22 +2,24 @@
|
|
|
2
2
|
export let typeCodeLabel = 'Sve-UI';
|
|
3
3
|
|
|
4
4
|
let copied = false;
|
|
5
|
-
let text = globalThis?.document?.getElementById('textCode')?.innerHTML || '';
|
|
6
|
-
|
|
7
5
|
const copyToClipboard = async () => {
|
|
8
6
|
try {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
const codeElement = document.querySelector('.code-box code');
|
|
8
|
+
if (codeElement) {
|
|
9
|
+
const text = codeElement.textContent;
|
|
10
|
+
text && (await navigator.clipboard.writeText(text));
|
|
11
|
+
copied = true;
|
|
12
|
+
setTimeout(() => {
|
|
13
|
+
copied = false;
|
|
14
|
+
}, 1500);
|
|
15
|
+
}
|
|
14
16
|
} catch (err) {
|
|
15
17
|
console.error('Failed to copy: ', err);
|
|
16
18
|
}
|
|
17
19
|
};
|
|
18
20
|
</script>
|
|
19
21
|
|
|
20
|
-
<
|
|
22
|
+
<pre class="code-box">
|
|
21
23
|
<article class="button-copy">
|
|
22
24
|
<span>{typeCodeLabel}</span>
|
|
23
25
|
<button on:click={copyToClipboard}>
|
|
@@ -44,36 +46,53 @@
|
|
|
44
46
|
</button>
|
|
45
47
|
</article>
|
|
46
48
|
|
|
47
|
-
|
|
48
|
-
<
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
</pre>
|
|
52
|
-
</section>
|
|
49
|
+
<code id="textCode" class={copied ? 'textCode' : ''}>
|
|
50
|
+
<slot />
|
|
51
|
+
</code>
|
|
52
|
+
</pre>
|
|
53
53
|
|
|
54
54
|
<style>
|
|
55
55
|
.code-box {
|
|
56
56
|
background-color: #070606;
|
|
57
|
+
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu,
|
|
58
|
+
Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
|
|
57
59
|
border-radius: 4px;
|
|
58
60
|
max-width: 75ch;
|
|
59
|
-
border-top-left-radius: 0.375rem;
|
|
60
|
-
border-top-right-radius: 0.375rem;
|
|
61
61
|
margin: 0 auto;
|
|
62
|
+
color: #fffdfa;
|
|
63
|
+
position: relative;
|
|
62
64
|
}
|
|
63
65
|
|
|
64
|
-
.code-box
|
|
66
|
+
.code-box code {
|
|
65
67
|
font-size: 0.9rem;
|
|
66
68
|
font-family: 'Söhne Mono', 'Monaco', 'Andale Mono', 'Ubuntu Mono', monospace;
|
|
67
|
-
|
|
69
|
+
display: block;
|
|
70
|
+
padding: 0 0.6rem;
|
|
71
|
+
overflow: auto;
|
|
72
|
+
transition: background-color 0.2s ease-in-out;
|
|
68
73
|
}
|
|
69
74
|
|
|
70
75
|
.textCode {
|
|
71
76
|
background-color: #71c562;
|
|
77
|
+
transition: background-color 0.2s ease-in-out;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.button-copy {
|
|
81
|
+
display: flex;
|
|
82
|
+
align-items: center;
|
|
83
|
+
justify-content: space-between;
|
|
84
|
+
background-color: rgba(52, 53, 65, 0.6);
|
|
85
|
+
border-top-left-radius: 0.375rem;
|
|
86
|
+
border-top-right-radius: 0.375rem;
|
|
87
|
+
padding: 0.8rem;
|
|
88
|
+
position: absolute;
|
|
89
|
+
top: 0;
|
|
90
|
+
left: 0;
|
|
91
|
+
right: 0;
|
|
72
92
|
}
|
|
73
93
|
|
|
74
94
|
button {
|
|
75
95
|
display: flex;
|
|
76
|
-
margin-left: auto;
|
|
77
96
|
gap: 0.5rem;
|
|
78
97
|
cursor: pointer;
|
|
79
98
|
background-color: transparent;
|
|
@@ -92,15 +111,6 @@
|
|
|
92
111
|
border-radius: 4px;
|
|
93
112
|
}
|
|
94
113
|
|
|
95
|
-
.button-copy {
|
|
96
|
-
display: flex;
|
|
97
|
-
align-items: center;
|
|
98
|
-
background-color: rgba(52, 53, 65, 0.6);
|
|
99
|
-
border-top-left-radius: 0.375rem;
|
|
100
|
-
border-top-right-radius: 0.375rem;
|
|
101
|
-
padding: 0.8rem;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
114
|
@media only screen and (max-width: 768px) {
|
|
105
115
|
.code-box {
|
|
106
116
|
max-width: 100%;
|
|
@@ -7,6 +7,10 @@
|
|
|
7
7
|
* @see Docs https://sveui.org/components/codeexample
|
|
8
8
|
*/
|
|
9
9
|
export default class CodeExample extends SvelteComponentTyped<{
|
|
10
|
+
/**
|
|
11
|
+
* The type code label text, show in the top of the code example component.
|
|
12
|
+
* @default 'Sve-UI'
|
|
13
|
+
*/
|
|
10
14
|
typeCodeLabel?: string | undefined;
|
|
11
15
|
}, {
|
|
12
16
|
[evt: string]: CustomEvent<any>;
|
|
@@ -20,10 +24,6 @@ export type CodeExampleSlots = typeof __propDef.slots;
|
|
|
20
24
|
import { SvelteComponentTyped } from "svelte";
|
|
21
25
|
declare const __propDef: {
|
|
22
26
|
props: {
|
|
23
|
-
/**
|
|
24
|
-
* The type code label
|
|
25
|
-
* @default 'Sve-UI'
|
|
26
|
-
*/
|
|
27
27
|
typeCodeLabel?: string | undefined;
|
|
28
28
|
};
|
|
29
29
|
events: {
|