wp-block-styles 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Connor (https://connorontheweb.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,141 @@
1
+ # wp-block-styles
2
+
3
+ Comprehensive CSS for WordPress Gutenberg block classes rendered via the **WP REST API** in headless Next.js, Nuxt, SvelteKit, Astro, or any other front-end framework.
4
+
5
+ Unlike `@wordpress/base-styles` — which pulls in the full WP editor design system — this package is a **lean, renderer-focused stylesheet** with zero dependencies and no JavaScript.
6
+
7
+ ## Why this package?
8
+
9
+ When you render WordPress content via the REST API, none of the block styles come with it — just raw HTML with Gutenberg's `wp-block-*` class names and no stylesheet to make sense of them. WordPress's own `@wordpress/base-styles` package exists but pulls in the entire editor design system, which is built for the admin UI, not for rendering on an arbitrary front-end.
10
+
11
+ This package is the missing piece: a standalone, zero-dependency CSS file that targets exactly the classes Gutenberg emits in rendered post content. It handles layout-breaking edge cases like full-bleed images, responsive embed ratios, and float-aligned figures — the things that quietly break in production and are tedious to track down one by one.
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ npm install wp-block-styles
17
+ # or
18
+ yarn add wp-block-styles
19
+ # or
20
+ pnpm add wp-block-styles
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ ### Global (recommended for most projects)
26
+
27
+ Import once in your app's root layout and all WP content is styled everywhere:
28
+
29
+ ```js
30
+ // Next.js: app/layout.tsx or pages/_app.js
31
+ import 'wp-block-styles'
32
+ ```
33
+
34
+ ### Scoped to a single page
35
+
36
+ If WP content only lives on a few routes:
37
+
38
+ ```js
39
+ // pages/[slug].tsx or app/posts/[slug]/page.tsx
40
+ import 'wp-block-styles'
41
+ ```
42
+
43
+ Next.js deduplicates CSS imports — even if multiple pages import this file, it only ships once in the bundle.
44
+
45
+ ### With a wrapper class (fully scoped, zero bleed)
46
+
47
+ All selectors are also prefixed with `.wp-content`. Wrap your rendered post HTML in a div with that class to ensure nothing leaks into the rest of your layout:
48
+
49
+ ```jsx
50
+ import 'wp-block-styles'
51
+
52
+ export default function Post({ content }) {
53
+ return (
54
+ <article
55
+ className="wp-content"
56
+ dangerouslySetInnerHTML={{ __html: content }}
57
+ />
58
+ )
59
+ }
60
+ ```
61
+
62
+ ## Customization via CSS Custom Properties
63
+
64
+ Override the built-in variables in your global CSS to theme the stylesheet without forking it:
65
+
66
+ ```css
67
+ :root {
68
+ --wp-content-max-width: 780px; /* content column width */
69
+ --wp-wide-max-width: 1200px; /* alignwide breakout width */
70
+ --wp-gap: 1.5rem; /* spacing between block elements */
71
+ --wp-border-color: #e2e2e2; /* borders on tables, separators, etc. */
72
+ --wp-code-bg: #1e1e1e; /* code block background */
73
+ --wp-code-color: #f8f8f2; /* code block text */
74
+ --wp-blockquote-border: #888; /* blockquote left border color */
75
+ --wp-pullquote-border: currentColor;
76
+ --wp-caption-color: #6b6b6b; /* captions and meta text */
77
+ }
78
+ ```
79
+
80
+ ## What's covered
81
+
82
+ All current WordPress core block types as of Gutenberg 21.x / WordPress 6.9:
83
+
84
+ | Category | Blocks |
85
+ |---|---|
86
+ | Text | Paragraph, Heading, List, Code, Preformatted, Verse/Poetry, Footnotes |
87
+ | Media | Image, Gallery, Video, Audio, Cover, Media & Text, File |
88
+ | Embeds | All oEmbed types with aspect ratio variants (16:9, 4:3, 1:1, 9:16, 21:9) |
89
+ | Design | Columns, Group, Separator, Spacer, Buttons, Table, Details/Accordion |
90
+ | Text | Math (MathML/LaTeX) — new in WP 6.9 |
91
+ | Quotes | Blockquote (default + large style), Pullquote (default + solid style) |
92
+ | Widgets | Latest Posts, Latest Comments, Search |
93
+ | Social Embeds | Twitter/X pre-load blockquote, Instagram, TikTok iframe overrides |
94
+ | Misc | Social Icons, Navigation (reset), Classic/Legacy Editor output |
95
+ | Utilities | Alignment (alignwide, alignfull, alignleft, alignright), text-align helpers, color & font-size palette classes |
96
+
97
+ ## Caching
98
+
99
+ This file is static and side-effect free. If you self-host it, use aggressive caching:
100
+
101
+ ```
102
+ Cache-Control: public, max-age=31536000, immutable
103
+ ```
104
+
105
+ If imported via npm, your bundler (webpack, Turbopack, Vite) handles content-hash cache busting automatically on version updates.
106
+
107
+ ## Contributing
108
+
109
+ Issues and PRs welcome at [github.com/connorontheweb/wp-block-styles](https://github.com/connorontheweb/wp-block-styles).
110
+
111
+ When WordPress adds new core blocks, open an issue or submit a PR adding the relevant `.wp-block-*` selectors.
112
+
113
+ ## License
114
+
115
+ MIT
116
+
117
+ ## Minified build
118
+
119
+ A pre-minified version is included in the package:
120
+
121
+ ```js
122
+ import 'wp-block-styles/index.min.css'
123
+ ```
124
+
125
+ To regenerate the minified file after edits:
126
+
127
+ ```bash
128
+ npm run build
129
+ ```
130
+
131
+ ## Dark mode
132
+
133
+ Dark mode is handled automatically via `@media (prefers-color-scheme: dark)`. The stylesheet overrides border colors, code block backgrounds, table headers, and caption colors when the user's OS is in dark mode. Override the CSS custom properties in your own stylesheet to customize the dark theme.
134
+
135
+ ## Print
136
+
137
+ Print styles are included via `@media print`. Embeds are replaced with a `[Embedded media — view online]` placeholder, buttons and social icons are hidden, float alignments are cleared so nothing overflows the page, and links display their full URL after the anchor text.
138
+
139
+ ## Testing
140
+
141
+ Open `test.html` directly in a browser to visually verify all block types at once. No build step or server required — it loads `index.css` via a relative path and uses placeholder images from picsum.photos.