Skip to content

Commit 1b67e66

Browse files
committed
feat: rebuild website for styled-components v6.4
Complete site rebuild: createTheme-based OKLCH token system, sidebar-first navigation with scroll-spy, dark mode (CSS-first with raw script in head), blog section with dynamic MDX assembly, live code editors, 404 page, DocSearch integration, responsive layout, and SSR registry.
1 parent bbfbfa9 commit 1b67e66

182 files changed

Lines changed: 4170 additions & 5620 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/api/proxy/[asset]/route.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import axios from 'axios';
21
import { NextRequest, NextResponse } from 'next/server';
32

43
const proxyMap: Record<string, string> = {
54
'npm-v.svg': 'https://img.shields.io/npm/v/styled-components.svg',
6-
'size.svg': 'https://img.shields.io/badge/gzip%20size-12.4%20kB-brightgreen.svg',
75
'downloads.svg': 'https://img.shields.io/npm/dm/styled-components.svg?maxAge=3600',
86
'stars.svg':
97
'https://img.shields.io/github/stars/styled-components/styled-components.svg?style=social&label=Star&maxAge=3600',
@@ -23,11 +21,9 @@ export async function GET(request: NextRequest, { params }: { params: Promise<{
2321
}
2422

2523
try {
26-
const { data, headers } = await axios.get(remoteUrl, {
27-
responseType: 'arraybuffer',
28-
});
29-
30-
const contentType = headers['content-type'];
24+
const resp = await fetch(remoteUrl);
25+
const data = await resp.arrayBuffer();
26+
const contentType = resp.headers.get('content-type') || 'application/octet-stream';
3127

3228
return new NextResponse(data, {
3329
status: 200,
@@ -36,7 +32,7 @@ export async function GET(request: NextRequest, { params }: { params: Promise<{
3632
'cache-control': 's-maxage=3600,stale-while-revalidate',
3733
},
3834
});
39-
} catch (error) {
35+
} catch {
4036
return NextResponse.json({ error: 'Error fetching remote asset' }, { status: 500 });
4137
}
4238
}

app/blog/[slug]/page.tsx

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { notFound } from 'next/navigation';
2+
import BlogPostPage from '@/components/BlogPostPage';
3+
import CelebrationEffect from '@/components/CelebrationEffect';
4+
import { getPosts, getPostBySlug } from '@/utils/blog.server';
5+
6+
export async function generateStaticParams() {
7+
const posts = await getPosts();
8+
return posts.map(post => ({ slug: post.slug }));
9+
}
10+
11+
export async function generateMetadata({ params }: { params: Promise<{ slug: string }> }) {
12+
const { slug } = await params;
13+
const post = await getPostBySlug(slug);
14+
if (!post) return { title: 'Post Not Found' };
15+
16+
return {
17+
title: post.title,
18+
description: post.description ?? `${post.title} by ${post.author}`,
19+
};
20+
}
21+
22+
export default async function BlogPost({ params }: { params: Promise<{ slug: string }> }) {
23+
const { slug } = await params;
24+
const post = await getPostBySlug(slug);
25+
26+
if (!post) {
27+
notFound();
28+
}
29+
30+
let MdxContent: React.ComponentType;
31+
try {
32+
const mod = await import(`@/sections/blog/${post.date}-${post.slug}.mdx`);
33+
MdxContent = mod.default;
34+
} catch {
35+
notFound();
36+
}
37+
38+
return (
39+
<>
40+
{slug === 'celebrating-a-decade-of-styled-components' && <CelebrationEffect />}
41+
<BlogPostPage post={post}>
42+
<MdxContent />
43+
</BlogPostPage>
44+
</>
45+
);
46+
}

app/blog/blog.css

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/* Route-level overrides for blog pages.
2+
Static CSS to avoid the createGlobalStyle SSR -> client hydration flash. */
3+
4+
[data-e2e-id='content'] img {
5+
max-width: 100%;
6+
height: auto;
7+
border-radius: 4px;
8+
}
9+
10+
/* Magazine-style section break: short warm rule, generous air. */
11+
[data-e2e-id='content'] hr {
12+
border: 0;
13+
margin: 3.5rem auto;
14+
width: 4rem;
15+
height: 2px;
16+
background: var(--sc-color-blogAccent);
17+
opacity: 0.6;
18+
}

app/blog/layout.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import './blog.css';
2+
3+
export default function BlogLayout({ children }: { children: React.ReactNode }) {
4+
return children;
5+
}

app/blog/page.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import BlogListPage from '@/components/BlogListPage';
2+
import { getPosts } from '@/utils/blog.server';
3+
4+
export const metadata = {
5+
title: 'Blog',
6+
description: 'Articles and announcements from the styled-components team',
7+
};
8+
9+
export default async function BlogPage() {
10+
const posts = await getPosts();
11+
12+
return <BlogListPage posts={posts} />;
13+
}

app/docs.json

Lines changed: 18 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"pages": [
33
{
4-
"title": "Basics",
4+
"title": "The Basics",
55
"pathname": "basics",
66
"sections": [
77
{
@@ -134,57 +134,23 @@
134134
"title": "FAQs",
135135
"pathname": "faqs",
136136
"sections": [
137-
{
138-
"title": "What do I need to do to migrate to v6?"
139-
},
140-
{
141-
"title": "How should I handle dynamic styles?"
142-
},
143-
{
144-
"title": "When to use attrs?"
145-
},
146-
{
147-
"title": "Why should I avoid declaring styled components in the render method?"
148-
},
149-
{
150-
"title": "Can I nest rules?"
151-
},
152-
{
153-
"title": "How can I override styles with higher specificity?"
154-
},
155-
{
156-
"title": "How can I override inline styles?"
157-
},
158-
{
159-
"title": "Why am I getting HTML attribute warnings?"
160-
},
161-
{
162-
"title": "Which browsers are supported?"
163-
},
164-
{
165-
"title": "Why do my DOM nodes have two classes?"
166-
},
167-
{
168-
"title": "Why am I getting a warning about several instances of module on the page?"
169-
},
170-
{
171-
"title": "Can I use css frameworks?"
172-
},
173-
{
174-
"title": "I am a library author. Should I bundle styled-components with my library?"
175-
},
176-
{
177-
"title": "How do I fix flickering text after server side rendering?"
178-
},
179-
{
180-
"title": "How can I fix issues when using npm link or yarn link?"
181-
},
182-
{
183-
"title": "Missing Declarations for styled-components/native?"
184-
},
185-
{
186-
"title": "What do I need to do to migrate to v5?"
187-
}
137+
{ "title": "What do I need to do to migrate to v6?" },
138+
{ "title": "What do I need to do to migrate to v5?" },
139+
{ "title": "How should I handle dynamic styles?" },
140+
{ "title": "When to use attrs?" },
141+
{ "title": "Why should I avoid declaring styled components in the render method?" },
142+
{ "title": "Can I nest rules?" },
143+
{ "title": "How can I override styles with higher specificity?" },
144+
{ "title": "How can I override inline styles?" },
145+
{ "title": "Can I use css frameworks?" },
146+
{ "title": "Why am I getting HTML attribute warnings?" },
147+
{ "title": "Why do my DOM nodes have two classes?" },
148+
{ "title": "Why am I getting a warning about several instances of module on the page?" },
149+
{ "title": "How do I fix flickering text after server side rendering?" },
150+
{ "title": "How can I fix issues when using npm link or yarn link?" },
151+
{ "title": "Missing Declarations for styled-components/native?" },
152+
{ "title": "Which browsers are supported?" },
153+
{ "title": "I am a library author. Should I bundle styled-components with my library?" }
188154
]
189155
}
190156
]

app/docs/advanced/page.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import { Metadata } from 'next';
12
import DocsLayout from '@/components/DocsLayout';
2-
import NextPage from '@/components/NextPage';
3+
import DocsPageNav from '@/components/DocsPageNav';
34

45
import Theming from '@/sections/advanced/theming.mdx';
56
import ServerSideRendering from '@/sections/advanced/server-side-rendering.mdx';
@@ -12,12 +13,14 @@ import Refs from '@/sections/advanced/refs.mdx';
1213
import Security from '@/sections/advanced/security.mdx';
1314
import TaggedTemplateLiterals from '@/sections/advanced/tagged-template-literals.mdx';
1415

16+
export const metadata: Metadata = {
17+
title: 'Advanced Usage',
18+
description: 'Theming, Server-Side Rendering, Performance, Existing CSS, Style Objects, Accessibility and more',
19+
};
20+
1521
export default function AdvancedPage() {
1622
return (
17-
<DocsLayout
18-
title="Advanced Usage"
19-
description="Theming, Server-Side Rendering, Performance, Existing CSS, Style Objects, Accessibility and more"
20-
>
23+
<DocsLayout title="Advanced Usage">
2124
<Theming />
2225
<ServerSideRendering />
2326
<Performance />
@@ -28,7 +31,7 @@ export default function AdvancedPage() {
2831
<Refs />
2932
<Security />
3033
<TaggedTemplateLiterals />
31-
<NextPage href="/docs/api" title="API Reference" />
34+
<DocsPageNav current="advanced" />
3235
</DocsLayout>
3336
);
3437
}

app/docs/api/page.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import { Metadata } from 'next';
12
import DocsLayout from '@/components/DocsLayout';
2-
import NextPage from '@/components/NextPage';
3+
import DocsPageNav from '@/components/DocsPageNav';
34

45
import Primary from '@/sections/api/primary/index.mdx';
56
import Helpers from '@/sections/api/helpers/index.mdx';
@@ -8,16 +9,21 @@ import TypeScript from '@/sections/api/typescript.mdx';
89
import OldAPIs from '@/sections/api/old/index.mdx';
910
import TestUtilities from '@/sections/api/test-utils/index.mdx';
1011

12+
export const metadata: Metadata = {
13+
title: 'API Reference',
14+
description: 'API Reference of styled-components',
15+
};
16+
1117
export default function APIPage() {
1218
return (
13-
<DocsLayout title="API Reference" description="API Reference of styled-components">
19+
<DocsLayout title="API Reference">
1420
<Primary />
1521
<Helpers />
1622
<TestUtilities />
1723
<SupportedCSS />
1824
<TypeScript />
1925
<OldAPIs />
20-
<NextPage href="/docs/tooling" title="Tooling" />
26+
<DocsPageNav current="api" />
2127
</DocsLayout>
2228
);
2329
}

app/docs/basics/page.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import { Metadata } from 'next';
12
import DocsLayout from '@/components/DocsLayout';
2-
import NextPage from '@/components/NextPage';
3+
import DocsPageNav from '@/components/DocsPageNav';
34

45
import Motivation from '@/sections/basics/motivation.mdx';
56
import Installation from '@/sections/basics/installation.mdx';
@@ -13,9 +14,14 @@ import AttachingAdditionalProps from '@/sections/basics/attaching-additional-pro
1314
import Animations from '@/sections/basics/animations.mdx';
1415
import ReactNative from '@/sections/basics/react-native.mdx';
1516

17+
export const metadata: Metadata = {
18+
title: 'The Basics',
19+
description: 'Get Started with styled-components basics.',
20+
};
21+
1622
export default function BasicsPage() {
1723
return (
18-
<DocsLayout title="Basics" description="Get Started with styled-components basics.">
24+
<DocsLayout title="The Basics">
1925
<Motivation />
2026
<Installation />
2127
<GettingStarted />
@@ -27,7 +33,7 @@ export default function BasicsPage() {
2733
<AttachingAdditionalProps />
2834
<Animations />
2935
<ReactNative />
30-
<NextPage href="/docs/advanced" title="Advanced" />
36+
<DocsPageNav current="basics" />
3137
</DocsLayout>
3238
);
3339
}

app/docs/faqs/page.tsx

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
import { Metadata } from 'next';
2+
import styled from 'styled-components';
13
import DocsLayout from '@/components/DocsLayout';
4+
import DocsPageNav from '@/components/DocsPageNav';
5+
import { theme, font } from '@/utils/theme';
26

37
import MigrationV6 from '@/sections/faqs/migration-v6.mdx';
48
import DynamicStylingPatterns from '@/sections/faqs/dynamic-styling-patterns.mdx';
@@ -18,26 +22,53 @@ import NPMLink from '@/sections/faqs/npm-link.mdx';
1822
import MissingNativeImport from '@/sections/faqs/missing-native-import.mdx';
1923
import MigrationV5 from '@/sections/faqs/migration-v5.mdx';
2024

25+
export const metadata: Metadata = {
26+
title: 'FAQs',
27+
description: 'Commonly asked questions about styled-components',
28+
};
29+
2130
export default function FAQsPage() {
2231
return (
23-
<DocsLayout title="FAQs" description="Commonly asked questions about styled-components">
32+
<DocsLayout title="FAQs">
33+
<Category>Migration</Category>
2434
<MigrationV6 />
35+
<MigrationV5 />
36+
37+
<Category>Styling Patterns</Category>
2538
<DynamicStylingPatterns />
2639
<WhenToUseAttrs />
2740
<DeclareComponentsInRenderMethod />
2841
<Nesting />
2942
<OverrideStyles />
3043
<OverrideInlineStyles />
44+
<CSSFrameworks />
45+
46+
<Category>Troubleshooting</Category>
3147
<HTMLAttributeWarnings />
32-
<BrowserSupport />
3348
<TwoDomClasses />
3449
<DuplicatedStyledComponents />
35-
<CSSFrameworks />
36-
<LibraryAuthors />
3750
<FlickeringText />
3851
<NPMLink />
3952
<MissingNativeImport />
40-
<MigrationV5 />
53+
54+
<Category>General</Category>
55+
<BrowserSupport />
56+
<LibraryAuthors />
57+
<DocsPageNav current="faqs" />
4158
</DocsLayout>
4259
);
4360
}
61+
62+
const Category = styled.h2`
63+
font-family: ${font.sans};
64+
font-size: ${theme.text.xl};
65+
font-weight: ${theme.fontWeight.semibold};
66+
color: ${theme.color.text};
67+
margin: ${theme.space[10]} 0 ${theme.space[2]};
68+
padding-bottom: ${theme.space[2]};
69+
border-bottom: 1px solid ${theme.color.border};
70+
71+
&:first-of-type {
72+
margin-top: ${theme.space[6]};
73+
}
74+
`;

0 commit comments

Comments
 (0)