Skip to content

Commit b453885

Browse files
committed
feat: 🎸 share btn
add x share button
1 parent 82fbedb commit b453885

2 files changed

Lines changed: 37 additions & 2 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { css } from "../../../styled-system/css";
2+
3+
export default function ShareButton() {
4+
const handleShareX = () => {
5+
const url = window.location.href + "?utm_source=share_btn&utm_medium=x_post_link";
6+
const text = document.title || 'Check this out';
7+
const shareUrl = `https://x.com/intent/post?text=${encodeURIComponent(text)}&url=${encodeURIComponent(url)}`;
8+
window.open(shareUrl, '_blank', 'noopener,noreferrer');
9+
}
10+
return (
11+
<button className={css({
12+
background: "transparent",
13+
border: "1px solid #f0d0ff",
14+
color: "#f0d0ff",
15+
cursor: "pointer",
16+
padding: "10px 20px",
17+
textDecoration: "underline",
18+
"&:hover": {
19+
background: "#f0d0ff",
20+
color: "#050021",
21+
textDecoration: "none",
22+
},
23+
})} onClick={handleShareX}>
24+
Share on X
25+
</button>
26+
);
27+
}

‎src/layout/main.tsx‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { css } from "../../styled-system/css";
22
import Link from "next/link";
33
import ClickSpark from "../components/ClickSpark/ClickSpark";
4+
import ShareButton from "../components/AnimatedContent/shrebtn";
45

56
export default function Layout({ children }) {
67
return (
@@ -64,7 +65,7 @@ export default function Layout({ children }) {
6465
>
6566
Apps
6667
</Link>
67-
68+
6869
<Link
6970
href={"/videos"}
7071
className={css({
@@ -90,6 +91,13 @@ export default function Layout({ children }) {
9091
background: "#000",
9192
})}
9293
>
94+
95+
<div className={css({ marginBottom: "20px" })}>
96+
<p>Share this page:</p>
97+
<div className={css({ display: "flex", justifyContent: "center" })}>
98+
<ShareButton />
99+
</div>
100+
</div>
93101
<div>(c) Nknight AMAMIYA 2021</div>
94102
<Link
95103
href={"https://varius.technology/"}
@@ -112,7 +120,7 @@ export default function Layout({ children }) {
112120
>
113121
nknighta.me
114122
</Link>
115-
123+
116124
<Link
117125
href={"/llmassets"}
118126
className={css({

0 commit comments

Comments
 (0)