Skip to content

Commit 24bdee2

Browse files
committed
chore: AGENTS.md prose sweep and small cleanups
Replaced em-dashes across docs prose with colons, semicolons, periods, or parentheses per the project rule. Dropped the literal em-dash glyph from the blog byline divider in favor of a middle dot. Fixed three Nav components that pixel sizes through `rem()`; nav and sidebar widths use plain px from `utils/sizes.ts`. `utils/blog.server.ts` now loads MDX modules concurrently via `Promise.all`. `utils/cssCompatFormats.ts` deduplicates a double sort. `Nav/SidebarMenus.tsx` hoists `activeHref(pathname)` out of its top-level `.map` so the lookup runs once per render instead of per item. Removed two unused exports: `searchModalWidth` in `utils/sizes.ts` and the precomputed `Author.websiteHost` in `utils/authors.ts`.
1 parent c7f7999 commit 24bdee2

26 files changed

Lines changed: 60 additions & 67 deletions

components/BlogMeta.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ const JumpToComments = styled.a`
171171
}
172172
`;
173173

174-
export const BlogDivider = styled.span.attrs({ 'aria-hidden': 'true', children: '' })`
174+
export const BlogDivider = styled.span.attrs({ 'aria-hidden': 'true', children: '·' })`
175175
color: ${theme.color.blogAccentMuted};
176176
`;
177177

components/Nav/MobileNavbar.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import styled, { css } from 'styled-components';
22
import { mobile } from '../../utils/media';
3-
import rem from '../../utils/rem';
43
import { navbarHeight } from '../../utils/sizes';
54
import { theme } from '../../utils/theme';
65
import Link from '../Link';
@@ -28,7 +27,7 @@ export default function MobileNavbar({ isSideFolded, onSideToggle }: MobileNavba
2827
{isSideFolded ? <FoldIcon /> : <CloseIcon />}
2928
</NavButton>
3029

31-
<LogoLink href="/">
30+
<LogoLink>
3231
<Logo />
3332
</LogoLink>
3433

@@ -44,7 +43,7 @@ const Wrapper = styled.div`
4443
align-items: center;
4544
display: flex;
4645
flex-grow: 1;
47-
height: ${rem(navbarHeight)};
46+
height: ${navbarHeight}px;
4847
justify-content: space-between;
4948
padding-left: calc(${theme.layout.gutter} - ${NAV_BUTTON_ICON_INSET}px);
5049
padding-right: calc(${theme.layout.gutter} - ${THEME_TOGGLE_ICON_INSET}px);

components/Nav/NavButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const NavButton = styled.button.attrs(() => ({
1616
background: transparent;
1717
cursor: pointer;
1818
flex: 0 0 auto;
19-
height: ${rem(navbarHeight)};
19+
height: ${navbarHeight}px;
2020
padding: 0 ${rem(10)};
2121
text-align: center;
2222
transition: all 200ms ease-in-out;

components/Nav/SidebarMenus.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ export default function SidebarMenu({ latestPost }: { latestPost: LatestPost })
9595
[currentDocsPage]
9696
);
9797
const activeId = useScrollSpy(sectionIds);
98+
const currentActiveHref = activeHref(pathname);
9899

99100
return (
100101
<MenuRoot aria-label="Site navigation">
@@ -103,7 +104,7 @@ export default function SidebarMenu({ latestPost }: { latestPost: LatestPost })
103104
</SearchWrapper>
104105

105106
{TOP_LEVEL.map(({ href, label, icon: Icon, external, badge, badgeTone }) => {
106-
const isActive = !external && href === activeHref(pathname);
107+
const isActive = !external && href === currentActiveHref;
107108

108109
return (
109110
<TopSection key={href}>

components/Nav/Social.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const Wrapper = styled.nav.attrs({ 'aria-label': 'Social links' })`
1414
const SocialLink = styled(Link).attrs({ variant: 'unstyled' as const })`
1515
display: flex;
1616
margin-right: ${rem(20)};
17-
line-height: ${rem(navbarHeight)};
17+
line-height: ${navbarHeight}px;
1818
transition:
1919
opacity 0.2s,
2020
transform 0.2s;

sections/advanced/accessibility.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const IconButton = styled.button.attrs<{ $label: string }>(props => ({
5151

5252
### Linting
5353

54-
Standard `eslint-plugin-jsx-a11y` does not recognize styled-components it only inspects JSX element names and cannot determine that `<StyledButton>` is a `<button>`. Use [`eslint-plugin-styled-components-a11y`](https://www.npmjs.com/package/eslint-plugin-styled-components-a11y) instead, which parses styled-components' tagged template literals to identify the underlying HTML element.
54+
Standard `eslint-plugin-jsx-a11y` does not recognize styled-components: it only inspects JSX element names and cannot determine that `<StyledButton>` is a `<button>`. Use [`eslint-plugin-styled-components-a11y`](https://www.npmjs.com/package/eslint-plugin-styled-components-a11y) instead, which parses styled-components' tagged template literals to identify the underlying HTML element.
5555

5656
```
5757
npm install --save-dev eslint-plugin-styled-components-a11y
@@ -71,7 +71,7 @@ The plugin mirrors `eslint-plugin-jsx-a11y` for styled components, including rul
7171

7272
### Runtime auditing
7373

74-
For runtime accessibility checks, use [`@axe-core/react`](https://www.npmjs.com/package/@axe-core/react) in development. It audits the rendered DOM and logs violations to the browser console it works with any styling approach since it inspects the final HTML:
74+
For runtime accessibility checks, use [`@axe-core/react`](https://www.npmjs.com/package/@axe-core/react) in development. It audits the rendered DOM and logs violations to the browser console; it works with any styling approach since it inspects the final HTML:
7575

7676
```tsx
7777
if (process.env.NODE_ENV === 'development') {

sections/advanced/components-as-selectors.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const B = styled.div`
7373
```
7474

7575
In development, a `console.error` warning is emitted because `A` is a plain function component
76-
being used as an interpolation styled-components calls it as a function and gets an unexpected
76+
being used as an interpolation; styled-components calls it as a function and gets an unexpected
7777
result. The component still mounts, but the selector won't work as intended.
7878

7979
However, wrapping `A` in a `styled()` factory makes it eligible for interpolation -- just

sections/advanced/performance.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const Header = () => <Title>Hello</Title>;
2222

2323
Every unique interpolation result generates a new CSS class. For values that change frequently (colors from a picker, positions from mouse events, animation progress), this can produce hundreds of classes. styled-components warns at 200+.
2424

25-
CSS custom properties avoid this entirelythe CSS rule stays the same and the browser updates the variable natively:
25+
CSS custom properties avoid this entirely: the CSS rule stays the same and the browser updates the variable natively.
2626

2727
```tsx
2828
// Bad: new CSS class for every distinct color
@@ -40,7 +40,7 @@ const Box = styled.div`
4040

4141
### Use `attrs` for rapidly-changing values
4242

43-
When a value changes on every frame (mouse position, scroll offset), use `attrs` with a `style` object. This applies values as inline stylesno class generation at all:
43+
When a value changes on every frame (mouse position, scroll offset), use `attrs` with a `style` object. This applies values as inline styles, no class generation at all.
4444

4545
```tsx
4646
// Bad: generates a new CSS class on every mouse move
@@ -67,7 +67,7 @@ const Cursor = styled.div.attrs<{ $x: number; $y: number }>(props => ({
6767

6868
### Data attributes for discrete variants
6969

70-
For finite variant sets (size, color scheme, state), data attributes keep styles fully static — no interpolation functions, one cached class:
70+
For finite variant sets (size, color scheme, state), data attributes keep styles fully static. No interpolation functions, one cached class.
7171

7272
```tsx
7373
// Dynamic: interpolation function runs every render
@@ -129,7 +129,7 @@ function App({ mode }: { mode: 'light' | 'dark' }) {
129129
}
130130
```
131131

132-
This applies regardless of how deep the consumer is every styled component in the tree pays the cache miss when the theme reference changes.
132+
This applies regardless of how deep the consumer is: every styled component in the tree pays the cache miss when the theme reference changes.
133133

134134
### Static vs dynamic components
135135

sections/advanced/security.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ You can use [`CSS.escape`](https://developer.mozilla.org/en-US/docs/Web/API/CSS/
2626

2727
If your site sets a [`style-src` CSP](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/style-src) that requires a `nonce`, styled-components will attach it to every injected `<style>` tag. You can supply the nonce in any of the following ways (first match wins):
2828

29-
1. Pass `nonce` explicitly to [`StyleSheetManager`](/docs/api#stylesheetmanager)the recommended approach for Next.js, Remix, and other frameworks where the nonce is generated per-request:
29+
1. Pass `nonce` explicitly to [`StyleSheetManager`](/docs/api#stylesheetmanager): the recommended approach for Next.js, Remix, and other frameworks where the nonce is generated per-request.
3030

3131
```tsx
3232
<StyleSheetManager nonce={nonce}>

sections/advanced/server-side-rendering.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Key behaviors in RSC:
1616

1717
- No `'use client'` directive required
1818
- `ThemeProvider` becomes a pass-through component (no context in RSC)
19-
- `StyleSheetManager` works in RSC as of v6.4 `stylisPlugins`, `shouldForwardProp`, and `nonce` are applied
19+
- `StyleSheetManager` works in RSC as of v6.4 (`stylisPlugins`, `shouldForwardProp`, and `nonce` are applied)
2020
- CSS is automatically injected inline via `<style>` tags
2121

2222
Best practices for RSC:
@@ -30,7 +30,7 @@ Best practices for RSC:
3030

3131
#### Child-index selector caveat
3232

33-
RSC emits inline `<style>` tags as siblings of your styled elements. These tags are real DOM children, so `:first-child`, `:last-child`, and `:nth-child()` count them shifting indices and breaking your styles. Use `:first-of-type` / `:nth-of-type()` instead, which filter by element type and are immune to this issue.
33+
RSC emits inline `<style>` tags as siblings of your styled elements. These tags are real DOM children, so `:first-child`, `:last-child`, and `:nth-child()` count them, shifting indices and breaking your styles. Use `:first-of-type` / `:nth-of-type()` instead, which filter by element type and are immune to this issue.
3434

3535
If you need `:nth-child()` specifically, use the built-in [`stylisPluginRSC`](/docs/api#stylesheetmanager) plugin (v6.4+) which rewrites these selectors to exclude styled-components style tags:
3636

@@ -43,7 +43,7 @@ import { StyleSheetManager, stylisPluginRSC } from 'styled-components';
4343
</StyleSheetManager>
4444
```
4545

46-
This uses CSS Selectors Level 4 `of S` syntax ([browser support](https://caniuse.com/css-nth-child-of-s): Chrome 111+, Firefox 113+, Safari 9+). In unsupported browsers, the entire CSS rule is dropped so only opt in if your audience supports it.
46+
This uses CSS Selectors Level 4 `of S` syntax ([browser support](https://caniuse.com/css-nth-child-of-s): Chrome 111+, Firefox 113+, Safari 9+). In unsupported browsers, the entire CSS rule is dropped, so only opt in if your audience supports it.
4747

4848
#### Theming with CSS custom properties
4949

@@ -62,7 +62,7 @@ const Button = styled.button`
6262
`;
6363
```
6464

65-
Or set variables manually on a parent element — they cascade to all DOM children:
65+
Or set variables manually on a parent element. They cascade to all DOM children:
6666

6767
```tsx
6868
const Container = styled.div``;
@@ -81,7 +81,7 @@ To ensure deterministic component IDs for server/client consistency, use our [Ba
8181

8282
> If you use React Server Components (v6.3+), the plugins are optional for SSR but still provide minification and more legible class names in DevTools.
8383
84-
For Next.js users, the SWC plugin is built-in just add `styledComponents: true` to your `next.config.js` compiler options.
84+
For Next.js users, the SWC plugin is built-in; just add `styledComponents: true` to your `next.config.js` compiler options.
8585

8686
### Example
8787

0 commit comments

Comments
 (0)