Skip to content

Commit 425450b

Browse files
authored
Merge pull request #1150 from mathuo/feat/docs-newsletter
feat(docs): add newsletter page and sticky signup widget
2 parents a33ca83 + 733475d commit 425450b

6 files changed

Lines changed: 178 additions & 1 deletion

File tree

packages/docs/docusaurus.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,11 @@ const config = {
241241
src: 'img/dockview_logo.svg',
242242
},
243243
items: [
244+
{
245+
to: '/newsletter',
246+
label: 'Newsletter',
247+
position: 'right',
248+
},
244249
{
245250
type: 'doc',
246251
docId: 'overview/introduction',
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/* ── Wrapper ─────────────────────────────────────────────────────────────────── */
2+
3+
.wrapper {
4+
position: fixed;
5+
bottom: 24px;
6+
right: 24px;
7+
z-index: 9998;
8+
display: flex;
9+
align-items: stretch;
10+
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
11+
border-radius: 999px;
12+
}
13+
14+
/* ── Sticky trigger ─────────────────────────────────────────────────────────── */
15+
16+
.trigger {
17+
display: flex;
18+
align-items: center;
19+
gap: 8px;
20+
padding: 12px 20px;
21+
background: var(--ifm-color-primary);
22+
color: #fff;
23+
border: none;
24+
border-radius: 999px 0 0 999px;
25+
font-size: 0.9rem;
26+
font-weight: 600;
27+
cursor: pointer;
28+
transition: filter 0.15s;
29+
text-decoration: none;
30+
}
31+
32+
.trigger:hover {
33+
filter: brightness(1.1);
34+
color: #fff;
35+
text-decoration: none;
36+
}
37+
38+
.trigger:active {
39+
transform: translateY(0);
40+
}
41+
42+
/* ── Dismiss button ──────────────────────────────────────────────────────────── */
43+
44+
.dismiss {
45+
display: flex;
46+
align-items: center;
47+
justify-content: center;
48+
width: 44px;
49+
padding: 0;
50+
background: color-mix(in srgb, var(--ifm-color-primary) 80%, black);
51+
color: #fff;
52+
border: none;
53+
border-left: 1px solid rgba(255, 255, 255, 0.25);
54+
border-radius: 0 999px 999px 0;
55+
cursor: pointer;
56+
transition: filter 0.15s;
57+
}
58+
59+
.dismiss:hover {
60+
filter: brightness(1.15);
61+
}
62+
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import React from 'react';
2+
import Link from '@docusaurus/Link';
3+
import styles from './NewsletterWidget.module.css';
4+
5+
const MailIcon = () => (
6+
<svg
7+
width="20"
8+
height="20"
9+
viewBox="0 0 24 24"
10+
fill="none"
11+
stroke="currentColor"
12+
strokeWidth="2"
13+
strokeLinecap="round"
14+
strokeLinejoin="round"
15+
>
16+
<rect x="2" y="4" width="20" height="16" rx="2" />
17+
<polyline points="2,4 12,13 22,4" />
18+
</svg>
19+
);
20+
21+
const CloseIcon = () => (
22+
<svg
23+
width="14"
24+
height="14"
25+
viewBox="0 0 24 24"
26+
fill="none"
27+
stroke="currentColor"
28+
strokeWidth="2.5"
29+
strokeLinecap="round"
30+
strokeLinejoin="round"
31+
>
32+
<line x1="18" y1="6" x2="6" y2="18" />
33+
<line x1="6" y1="6" x2="18" y2="18" />
34+
</svg>
35+
);
36+
37+
export default function NewsletterWidget() {
38+
const [hidden, setHidden] = React.useState(false);
39+
40+
if (hidden) return null;
41+
42+
return (
43+
<div className={styles.wrapper}>
44+
<Link to="/newsletter" className={styles.trigger} aria-label="Newsletter signup">
45+
<MailIcon />
46+
<span>Newsletter</span>
47+
</Link>
48+
<button
49+
className={styles.dismiss}
50+
onClick={() => setHidden(true)}
51+
aria-label="Dismiss newsletter"
52+
>
53+
<CloseIcon />
54+
</button>
55+
</div>
56+
);
57+
}

packages/docs/src/pages/index.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@
215215
color: var(--ifm-color-content-secondary);
216216
}
217217

218+
218219
@media (prefers-reduced-motion: reduce) {
219220
.hero-framework {
220221
animation: none;
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import React from 'react';
2+
import Layout from '@theme/Layout';
3+
4+
function NewsletterEmbed() {
5+
const containerRef = React.useRef<HTMLDivElement>(null);
6+
7+
React.useEffect(() => {
8+
const script = document.createElement('script');
9+
script.src = 'https://dockview.kit.com/35a816915c/index.js';
10+
script.async = true;
11+
script.setAttribute('data-uid', '35a816915c');
12+
containerRef.current?.appendChild(script);
13+
return () => {
14+
containerRef.current?.removeChild(script);
15+
};
16+
}, []);
17+
18+
return <div ref={containerRef} />;
19+
}
20+
21+
export default function Newsletter(): JSX.Element {
22+
return (
23+
<Layout
24+
title="Newsletter"
25+
description="Subscribe to the Dockview newsletter for updates, releases, and tips."
26+
>
27+
<main>
28+
<div
29+
style={{
30+
maxWidth: 600,
31+
margin: '80px auto',
32+
padding: '0 24px',
33+
minHeight: '60vh',
34+
}}
35+
>
36+
<h1>Newsletter</h1>
37+
<p style={{ color: 'var(--ifm-color-content-secondary)' }}>
38+
Sign up for updates related to the Dockview project.
39+
</p>
40+
<NewsletterEmbed />
41+
<p style={{ fontSize: '0.8rem', color: 'var(--ifm-color-content-secondary)', marginTop: '1rem' }}>
42+
We do not share or sell your email address.
43+
</p>
44+
</div>
45+
</main>
46+
</Layout>
47+
);
48+
}

packages/docs/src/theme/Root.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import React from 'react';
22
import { RecoilRoot } from 'recoil';
3+
import NewsletterWidget from '../components/NewsletterWidget';
34

45
// Default implementation, that you can customize
56
export default function Root({ children }) {
67
return (
78
<React.StrictMode>
8-
<RecoilRoot>{children}</RecoilRoot>
9+
<RecoilRoot>
10+
{children}
11+
<NewsletterWidget />
12+
</RecoilRoot>
913
</React.StrictMode>
1014
);
1115
}

0 commit comments

Comments
 (0)