@neocode-ai/web 1.1.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 +54 -0
- package/astro.config.mjs +145 -0
- package/config.mjs +14 -0
- package/package.json +41 -0
- package/public/robots.txt +6 -0
- package/public/theme.json +183 -0
- package/src/assets/lander/check.svg +2 -0
- package/src/assets/lander/copy.svg +2 -0
- package/src/assets/lander/screenshot-github.png +0 -0
- package/src/assets/lander/screenshot-splash.png +0 -0
- package/src/assets/lander/screenshot-vscode.png +0 -0
- package/src/assets/lander/screenshot.png +0 -0
- package/src/assets/logo-dark.svg +20 -0
- package/src/assets/logo-light.svg +20 -0
- package/src/assets/logo-ornate-dark.svg +18 -0
- package/src/assets/logo-ornate-light.svg +18 -0
- package/src/assets/web/web-homepage-active-session.png +0 -0
- package/src/assets/web/web-homepage-new-session.png +0 -0
- package/src/assets/web/web-homepage-see-servers.png +0 -0
- package/src/components/Head.astro +50 -0
- package/src/components/Header.astro +128 -0
- package/src/components/Hero.astro +11 -0
- package/src/components/Lander.astro +713 -0
- package/src/components/Share.tsx +634 -0
- package/src/components/SiteTitle.astro +59 -0
- package/src/components/icons/custom.tsx +87 -0
- package/src/components/icons/index.tsx +4454 -0
- package/src/components/share/common.tsx +77 -0
- package/src/components/share/content-bash.module.css +85 -0
- package/src/components/share/content-bash.tsx +67 -0
- package/src/components/share/content-code.module.css +26 -0
- package/src/components/share/content-code.tsx +32 -0
- package/src/components/share/content-diff.module.css +153 -0
- package/src/components/share/content-diff.tsx +231 -0
- package/src/components/share/content-error.module.css +64 -0
- package/src/components/share/content-error.tsx +24 -0
- package/src/components/share/content-markdown.module.css +154 -0
- package/src/components/share/content-markdown.tsx +75 -0
- package/src/components/share/content-text.module.css +63 -0
- package/src/components/share/content-text.tsx +37 -0
- package/src/components/share/copy-button.module.css +30 -0
- package/src/components/share/copy-button.tsx +28 -0
- package/src/components/share/part.module.css +428 -0
- package/src/components/share/part.tsx +780 -0
- package/src/components/share.module.css +832 -0
- package/src/content/docs/1-0.mdx +67 -0
- package/src/content/docs/acp.mdx +156 -0
- package/src/content/docs/agents.mdx +720 -0
- package/src/content/docs/cli.mdx +597 -0
- package/src/content/docs/commands.mdx +323 -0
- package/src/content/docs/config.mdx +683 -0
- package/src/content/docs/custom-tools.mdx +170 -0
- package/src/content/docs/ecosystem.mdx +76 -0
- package/src/content/docs/enterprise.mdx +170 -0
- package/src/content/docs/formatters.mdx +130 -0
- package/src/content/docs/github.mdx +321 -0
- package/src/content/docs/gitlab.mdx +195 -0
- package/src/content/docs/ide.mdx +48 -0
- package/src/content/docs/index.mdx +359 -0
- package/src/content/docs/keybinds.mdx +191 -0
- package/src/content/docs/lsp.mdx +188 -0
- package/src/content/docs/mcp-servers.mdx +511 -0
- package/src/content/docs/models.mdx +223 -0
- package/src/content/docs/modes.mdx +331 -0
- package/src/content/docs/network.mdx +57 -0
- package/src/content/docs/permissions.mdx +237 -0
- package/src/content/docs/plugins.mdx +362 -0
- package/src/content/docs/providers.mdx +1889 -0
- package/src/content/docs/rules.mdx +180 -0
- package/src/content/docs/sdk.mdx +391 -0
- package/src/content/docs/server.mdx +286 -0
- package/src/content/docs/share.mdx +128 -0
- package/src/content/docs/skills.mdx +220 -0
- package/src/content/docs/themes.mdx +369 -0
- package/src/content/docs/tools.mdx +345 -0
- package/src/content/docs/troubleshooting.mdx +300 -0
- package/src/content/docs/tui.mdx +390 -0
- package/src/content/docs/web.mdx +136 -0
- package/src/content/docs/windows-wsl.mdx +113 -0
- package/src/content/docs/zen.mdx +251 -0
- package/src/content.config.ts +7 -0
- package/src/pages/[...slug].md.ts +18 -0
- package/src/pages/s/[id].astro +113 -0
- package/src/styles/custom.css +405 -0
- package/src/types/lang-map.d.ts +27 -0
- package/tsconfig.json +9 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
background-color: var(--sl-color-bg-surface);
|
|
3
|
+
padding: 0.5rem calc(0.5rem + 3px);
|
|
4
|
+
border-radius: 0.25rem;
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
align-items: flex-start;
|
|
8
|
+
gap: 1rem;
|
|
9
|
+
align-self: flex-start;
|
|
10
|
+
|
|
11
|
+
[data-section="content"] {
|
|
12
|
+
pre {
|
|
13
|
+
margin-bottom: 0.5rem;
|
|
14
|
+
line-height: 1.5;
|
|
15
|
+
font-size: 0.75rem;
|
|
16
|
+
white-space: pre-wrap;
|
|
17
|
+
word-break: break-word;
|
|
18
|
+
|
|
19
|
+
&:last-child {
|
|
20
|
+
margin-bottom: 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
span {
|
|
24
|
+
margin-right: 0.25rem;
|
|
25
|
+
&:last-child {
|
|
26
|
+
margin-right: 0;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
span[data-color="red"] {
|
|
30
|
+
color: var(--sl-color-red);
|
|
31
|
+
}
|
|
32
|
+
span[data-color="dimmed"] {
|
|
33
|
+
color: var(--sl-color-text-dimmed);
|
|
34
|
+
}
|
|
35
|
+
span[data-marker="label"] {
|
|
36
|
+
text-transform: uppercase;
|
|
37
|
+
letter-spacing: -0.5px;
|
|
38
|
+
}
|
|
39
|
+
span[data-separator] {
|
|
40
|
+
margin-right: 0.375rem;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
&[data-expanded="true"] {
|
|
46
|
+
[data-section="content"] {
|
|
47
|
+
display: block;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
&[data-expanded="false"] {
|
|
51
|
+
[data-section="content"] {
|
|
52
|
+
display: -webkit-box;
|
|
53
|
+
-webkit-box-orient: vertical;
|
|
54
|
+
-webkit-line-clamp: 7;
|
|
55
|
+
overflow: hidden;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
button {
|
|
60
|
+
flex: 0 0 auto;
|
|
61
|
+
padding: 2px 0;
|
|
62
|
+
font-size: 0.75rem;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import style from "./content-error.module.css"
|
|
2
|
+
import { type JSX, createSignal } from "solid-js"
|
|
3
|
+
import { createOverflow } from "./common"
|
|
4
|
+
|
|
5
|
+
interface Props extends JSX.HTMLAttributes<HTMLDivElement> {
|
|
6
|
+
expand?: boolean
|
|
7
|
+
}
|
|
8
|
+
export function ContentError(props: Props) {
|
|
9
|
+
const [expanded, setExpanded] = createSignal(false)
|
|
10
|
+
const overflow = createOverflow()
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<div class={style.root} data-expanded={expanded() || props.expand === true ? true : undefined}>
|
|
14
|
+
<div data-section="content" ref={overflow.ref}>
|
|
15
|
+
{props.children}
|
|
16
|
+
</div>
|
|
17
|
+
{((!props.expand && overflow.status) || expanded()) && (
|
|
18
|
+
<button type="button" data-element-button-text onClick={() => setExpanded((e) => !e)}>
|
|
19
|
+
{expanded() ? "Show less" : "Show more"}
|
|
20
|
+
</button>
|
|
21
|
+
)}
|
|
22
|
+
</div>
|
|
23
|
+
)
|
|
24
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
position: relative;
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
align-items: flex-start;
|
|
6
|
+
gap: 1rem;
|
|
7
|
+
|
|
8
|
+
[data-slot="expand-button"] {
|
|
9
|
+
flex: 0 0 auto;
|
|
10
|
+
padding: 2px 0;
|
|
11
|
+
font-size: 0.857em;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
[data-slot="markdown"] {
|
|
15
|
+
display: -webkit-box;
|
|
16
|
+
-webkit-box-orient: vertical;
|
|
17
|
+
-webkit-line-clamp: 3;
|
|
18
|
+
line-clamp: 3;
|
|
19
|
+
overflow: hidden;
|
|
20
|
+
|
|
21
|
+
[data-expanded] & {
|
|
22
|
+
display: block;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
font-size: 1em;
|
|
26
|
+
line-height: 1.5;
|
|
27
|
+
|
|
28
|
+
p,
|
|
29
|
+
blockquote,
|
|
30
|
+
ul,
|
|
31
|
+
ol,
|
|
32
|
+
dl,
|
|
33
|
+
table,
|
|
34
|
+
pre {
|
|
35
|
+
margin-bottom: 1rem;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
ul,
|
|
39
|
+
ol {
|
|
40
|
+
margin-bottom: 0.5rem;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/* Add spacing between top-level list items */
|
|
44
|
+
ol > li {
|
|
45
|
+
margin-bottom: 0.5rem;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
strong {
|
|
49
|
+
font-weight: 600;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
ol {
|
|
53
|
+
list-style-position: outside;
|
|
54
|
+
padding-left: 1.5rem;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
ul {
|
|
58
|
+
padding-left: 1.5rem;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/* Nested list spacing */
|
|
62
|
+
li ul,
|
|
63
|
+
li ol {
|
|
64
|
+
margin-top: 0.25rem;
|
|
65
|
+
margin-bottom: 0;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
h1,
|
|
69
|
+
h2,
|
|
70
|
+
h3,
|
|
71
|
+
h4,
|
|
72
|
+
h5,
|
|
73
|
+
h6 {
|
|
74
|
+
font-size: 1em;
|
|
75
|
+
font-weight: 600;
|
|
76
|
+
margin-bottom: 0.5rem;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
& > *:last-child {
|
|
80
|
+
margin-bottom: 0;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
pre {
|
|
84
|
+
--shiki-dark-bg: var(--sl-color-bg-surface) !important;
|
|
85
|
+
background-color: var(--sl-color-bg-surface) !important;
|
|
86
|
+
padding: 0.5rem 0.75rem;
|
|
87
|
+
line-height: 1.6;
|
|
88
|
+
font-size: 0.857em;
|
|
89
|
+
white-space: pre-wrap;
|
|
90
|
+
word-break: break-word;
|
|
91
|
+
|
|
92
|
+
span {
|
|
93
|
+
white-space: break-spaces;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
code {
|
|
98
|
+
font-weight: 500;
|
|
99
|
+
|
|
100
|
+
&:not(pre code) {
|
|
101
|
+
&::before {
|
|
102
|
+
content: "`";
|
|
103
|
+
font-weight: 700;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
&::after {
|
|
107
|
+
content: "`";
|
|
108
|
+
font-weight: 700;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
table {
|
|
114
|
+
border-collapse: collapse;
|
|
115
|
+
width: 100%;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
th,
|
|
119
|
+
td {
|
|
120
|
+
border: 1px solid var(--sl-color-border);
|
|
121
|
+
padding: 0.5rem 0.75rem;
|
|
122
|
+
text-align: left;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
th {
|
|
126
|
+
border-bottom: 1px solid var(--sl-color-border);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/* Remove outer borders */
|
|
130
|
+
table tr:first-child th,
|
|
131
|
+
table tr:first-child td {
|
|
132
|
+
border-top: none;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
table tr:last-child td {
|
|
136
|
+
border-bottom: none;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
table th:first-child,
|
|
140
|
+
table td:first-child {
|
|
141
|
+
border-left: none;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
table th:last-child,
|
|
145
|
+
table td:last-child {
|
|
146
|
+
border-right: none;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
[data-component="copy-button"] {
|
|
151
|
+
top: 0;
|
|
152
|
+
right: 0;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { marked } from "marked"
|
|
2
|
+
import { codeToHtml } from "shiki"
|
|
3
|
+
import markedShiki from "marked-shiki"
|
|
4
|
+
import { createOverflow } from "./common"
|
|
5
|
+
import { CopyButton } from "./copy-button"
|
|
6
|
+
import { createResource, createSignal } from "solid-js"
|
|
7
|
+
import { transformerNotationDiff } from "@shikijs/transformers"
|
|
8
|
+
import style from "./content-markdown.module.css"
|
|
9
|
+
|
|
10
|
+
const markedWithShiki = marked.use(
|
|
11
|
+
{
|
|
12
|
+
renderer: {
|
|
13
|
+
link({ href, title, text }) {
|
|
14
|
+
const titleAttr = title ? ` title="${title}"` : ""
|
|
15
|
+
return `<a href="${href}"${titleAttr} target="_blank" rel="noopener noreferrer">${text}</a>`
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
markedShiki({
|
|
20
|
+
highlight(code, lang) {
|
|
21
|
+
return codeToHtml(code, {
|
|
22
|
+
lang: lang || "text",
|
|
23
|
+
themes: {
|
|
24
|
+
light: "github-light",
|
|
25
|
+
dark: "github-dark",
|
|
26
|
+
},
|
|
27
|
+
transformers: [transformerNotationDiff()],
|
|
28
|
+
})
|
|
29
|
+
},
|
|
30
|
+
}),
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
interface Props {
|
|
34
|
+
text: string
|
|
35
|
+
expand?: boolean
|
|
36
|
+
highlight?: boolean
|
|
37
|
+
}
|
|
38
|
+
export function ContentMarkdown(props: Props) {
|
|
39
|
+
const [html] = createResource(
|
|
40
|
+
() => strip(props.text),
|
|
41
|
+
async (markdown) => {
|
|
42
|
+
return markedWithShiki.parse(markdown)
|
|
43
|
+
},
|
|
44
|
+
)
|
|
45
|
+
const [expanded, setExpanded] = createSignal(false)
|
|
46
|
+
const overflow = createOverflow()
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<div
|
|
50
|
+
class={style.root}
|
|
51
|
+
data-highlight={props.highlight === true ? true : undefined}
|
|
52
|
+
data-expanded={expanded() || props.expand === true ? true : undefined}
|
|
53
|
+
>
|
|
54
|
+
<div data-slot="markdown" ref={overflow.ref} innerHTML={html()} />
|
|
55
|
+
|
|
56
|
+
{!props.expand && overflow.status && (
|
|
57
|
+
<button
|
|
58
|
+
type="button"
|
|
59
|
+
data-component="text-button"
|
|
60
|
+
data-slot="expand-button"
|
|
61
|
+
onClick={() => setExpanded((e) => !e)}
|
|
62
|
+
>
|
|
63
|
+
{expanded() ? "Show less" : "Show more"}
|
|
64
|
+
</button>
|
|
65
|
+
)}
|
|
66
|
+
<CopyButton text={props.text} />
|
|
67
|
+
</div>
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function strip(text: string): string {
|
|
72
|
+
const wrappedRe = /^\s*<([A-Za-z]\w*)>\s*([\s\S]*?)\s*<\/\1>\s*$/
|
|
73
|
+
const match = text.match(wrappedRe)
|
|
74
|
+
return match ? match[2] : text
|
|
75
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
position: relative;
|
|
3
|
+
color: var(--sl-color-text);
|
|
4
|
+
background-color: var(--sl-color-bg-surface);
|
|
5
|
+
padding: 0.5rem calc(0.5rem + 3px);
|
|
6
|
+
padding-right: calc(1rem + 18px);
|
|
7
|
+
border-radius: 0.25rem;
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
align-items: flex-start;
|
|
11
|
+
gap: 1rem;
|
|
12
|
+
align-self: flex-start;
|
|
13
|
+
font-size: 0.875rem;
|
|
14
|
+
|
|
15
|
+
&[data-compact] {
|
|
16
|
+
font-size: 0.75rem;
|
|
17
|
+
color: var(--sl-color-text-dimmed);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
[data-slot="text"] {
|
|
21
|
+
line-height: 1.5;
|
|
22
|
+
white-space: pre-wrap;
|
|
23
|
+
overflow-wrap: anywhere;
|
|
24
|
+
display: -webkit-box;
|
|
25
|
+
-webkit-box-orient: vertical;
|
|
26
|
+
-webkit-line-clamp: 3;
|
|
27
|
+
line-clamp: 3;
|
|
28
|
+
overflow: hidden;
|
|
29
|
+
|
|
30
|
+
[data-expanded] & {
|
|
31
|
+
display: block;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
[data-slot="expand-button"] {
|
|
36
|
+
flex: 0 0 auto;
|
|
37
|
+
padding: 2px 0;
|
|
38
|
+
font-size: 0.75rem;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
&[data-theme="invert"] {
|
|
42
|
+
background-color: var(--sl-color-blue-high);
|
|
43
|
+
color: var(--sl-color-text-invert);
|
|
44
|
+
|
|
45
|
+
[data-slot="expand-button"] {
|
|
46
|
+
opacity: 0.85;
|
|
47
|
+
color: var(--sl-color-text-invert);
|
|
48
|
+
|
|
49
|
+
&:hover {
|
|
50
|
+
opacity: 1;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
&[data-theme="blue"] {
|
|
56
|
+
background-color: var(--sl-color-blue-low);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
[data-component="copy-button"] {
|
|
60
|
+
top: 0.5rem;
|
|
61
|
+
right: calc(0.5rem - 1px);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import style from "./content-text.module.css"
|
|
2
|
+
import { createSignal } from "solid-js"
|
|
3
|
+
import { createOverflow } from "./common"
|
|
4
|
+
import { CopyButton } from "./copy-button"
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
text: string
|
|
8
|
+
expand?: boolean
|
|
9
|
+
compact?: boolean
|
|
10
|
+
}
|
|
11
|
+
export function ContentText(props: Props) {
|
|
12
|
+
const [expanded, setExpanded] = createSignal(false)
|
|
13
|
+
const overflow = createOverflow()
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<div
|
|
17
|
+
class={style.root}
|
|
18
|
+
data-expanded={expanded() || props.expand === true ? true : undefined}
|
|
19
|
+
data-compact={props.compact === true ? true : undefined}
|
|
20
|
+
>
|
|
21
|
+
<pre data-slot="text" ref={overflow.ref}>
|
|
22
|
+
{props.text}
|
|
23
|
+
</pre>
|
|
24
|
+
{((!props.expand && overflow.status) || expanded()) && (
|
|
25
|
+
<button
|
|
26
|
+
type="button"
|
|
27
|
+
data-component="text-button"
|
|
28
|
+
data-slot="expand-button"
|
|
29
|
+
onClick={() => setExpanded((e) => !e)}
|
|
30
|
+
>
|
|
31
|
+
{expanded() ? "Show less" : "Show more"}
|
|
32
|
+
</button>
|
|
33
|
+
)}
|
|
34
|
+
<CopyButton text={props.text} />
|
|
35
|
+
</div>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
position: absolute;
|
|
3
|
+
opacity: 0;
|
|
4
|
+
visibility: hidden;
|
|
5
|
+
transition: opacity 0.15s ease;
|
|
6
|
+
|
|
7
|
+
button {
|
|
8
|
+
cursor: pointer;
|
|
9
|
+
background: none;
|
|
10
|
+
border: none;
|
|
11
|
+
padding: 0.125rem;
|
|
12
|
+
color: var(--sl-color-text-secondary);
|
|
13
|
+
|
|
14
|
+
svg {
|
|
15
|
+
display: block;
|
|
16
|
+
width: 1rem;
|
|
17
|
+
height: 1rem;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&[data-copied="true"] {
|
|
21
|
+
color: var(--sl-color-green-high);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/* Show copy button when parent is hovered */
|
|
27
|
+
*:hover > .root {
|
|
28
|
+
opacity: 1;
|
|
29
|
+
visibility: visible;
|
|
30
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createSignal } from "solid-js"
|
|
2
|
+
import { IconClipboard, IconCheckCircle } from "../icons"
|
|
3
|
+
import styles from "./copy-button.module.css"
|
|
4
|
+
|
|
5
|
+
interface CopyButtonProps {
|
|
6
|
+
text: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function CopyButton(props: CopyButtonProps) {
|
|
10
|
+
const [copied, setCopied] = createSignal(false)
|
|
11
|
+
|
|
12
|
+
function handleCopyClick() {
|
|
13
|
+
if (props.text) {
|
|
14
|
+
navigator.clipboard.writeText(props.text).catch((err) => console.error("Copy failed", err))
|
|
15
|
+
|
|
16
|
+
setCopied(true)
|
|
17
|
+
setTimeout(() => setCopied(false), 2000)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<div data-component="copy-button" class={styles.root}>
|
|
23
|
+
<button type="button" onClick={handleCopyClick} data-copied={copied() ? true : undefined}>
|
|
24
|
+
{copied() ? <IconCheckCircle width={16} height={16} /> : <IconClipboard width={16} height={16} />}
|
|
25
|
+
</button>
|
|
26
|
+
</div>
|
|
27
|
+
)
|
|
28
|
+
}
|