Skip to content

Commit 910ba6d

Browse files
feat: use cmp
Signed-off-by: David Dal Busco <david.dalbusco@outlook.com>
1 parent 12dd630 commit 910ba6d

2 files changed

Lines changed: 5 additions & 70 deletions

File tree

src/components/Launch/index.tsx

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,8 @@
1-
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
1+
import BashSnippet from "@site/src/components/BashSnippet";
22
import { LaunchIllustration } from "@site/src/icons/LaunchIllustration";
3-
import { trackEvent } from "@site/src/providers/analytics.providers";
4-
import CodeBlock from "@theme/CodeBlock";
5-
import { useRef } from "react";
63
import styles from "./styles.module.scss";
74

85
export default function Launch(): JSX.Element {
9-
const { siteConfig } = useDocusaurusContext();
10-
const container = useRef(null);
11-
12-
const onClick = async ({ target }: MouseEvent) => {
13-
const btn = container.current?.querySelector('button[title="Copy"]');
14-
15-
if (!btn?.contains(target)) {
16-
return;
17-
}
18-
19-
await trackEvent({
20-
name: "copy_launch_snippet",
21-
siteConfig
22-
});
23-
};
24-
256
return (
267
<div className={styles.sub}>
278
<article>
@@ -31,23 +12,10 @@ export default function Launch(): JSX.Element {
3112
templates.
3213
</p>
3314

34-
<div
35-
className={styles.code}
36-
ref={container}
37-
onClick={async ($event) => onClick($event as unknown as MouseEvent)}
38-
>
39-
<svg
40-
xmlns="http://www.w3.org/2000/svg"
41-
height="24"
42-
viewBox="0 -960 960 960"
43-
width="24"
44-
fill="#00fff5"
45-
className={styles.bash}
46-
>
47-
<path d="M530-481 353-658q-9-9-8.5-21t9.5-21q9-9 21.5-9t21.5 9l198 198q5 5 7 10t2 11q0 6-2 11t-7 10L396-261q-9 9-21 8.5t-21-9.5q-9-9-9-21.5t9-21.5l176-176Z" />
48-
</svg>
49-
<CodeBlock className="code-npm">npm create juno@latest</CodeBlock>
50-
</div>
15+
<BashSnippet
16+
analyticsEventName="copy_launch_snippet"
17+
cmd="npm create juno@latest"
18+
/>
5119
</article>
5220

5321
<picture

src/components/Launch/styles.module.scss

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -30,36 +30,3 @@
3030
max-width: 560px;
3131
}
3232
}
33-
34-
.code {
35-
position: relative;
36-
37-
:global(.code-npm) {
38-
width: 290px;
39-
box-shadow: none;
40-
41-
code {
42-
padding: var(--ifm-pre-padding) var(--ifm-pre-padding)
43-
var(--ifm-pre-padding) 2rem;
44-
}
45-
46-
span {
47-
color: #00fff5;
48-
}
49-
50-
button {
51-
opacity: 1;
52-
border-color: transparent;
53-
padding-top: 0.55rem;
54-
}
55-
}
56-
}
57-
58-
.bash {
59-
position: absolute;
60-
left: 0.75rem;
61-
top: 50%;
62-
transform: translate(0, -50%);
63-
64-
z-index: 1;
65-
}

0 commit comments

Comments
 (0)