├── .github
└── workflows
│ ├── main.yaml
│ └── publish.yaml
├── .gitignore
├── LICENSE
├── README.md
├── docs
├── .gitignore
├── README.md
├── astro.config.mjs
├── package.json
├── postcss.config.cjs
├── public
│ ├── favicon.ico
│ └── icons.svg
├── src
│ ├── components
│ │ └── sample.mdx
│ ├── env.d.ts
│ ├── layouts
│ │ └── BaseLayout.astro
│ ├── pages
│ │ ├── index.astro
│ │ ├── theme.ts
│ │ └── typography.astro
│ └── tailwind.css
├── tailwind.config.ts
└── tsconfig.json
├── package.json
├── packages
├── palette
│ ├── package.json
│ ├── src
│ │ ├── alias.test.ts
│ │ ├── alias.ts
│ │ ├── index.ts
│ │ ├── plugin.test.ts
│ │ └── plugin.ts
│ ├── tsconfig.json
│ └── tsup.config.ts
└── typography
│ ├── package.json
│ ├── src
│ └── index.ts
│ ├── tsconfig.json
│ └── tsup.config.ts
├── pnpm-lock.yaml
├── pnpm-workspace.yaml
├── prettier.config.cjs
├── tsconfig.json
└── turbo.json
/.github/workflows/main.yaml:
--------------------------------------------------------------------------------
1 | on:
2 | push:
3 | branches:
4 | - main
5 | pull_request:
6 | branches:
7 | - main
8 | jobs:
9 | build:
10 | runs-on: ubuntu-22.04
11 | strategy:
12 | matrix:
13 | node-version: [18, 20]
14 | steps:
15 | - uses: actions/checkout@v3
16 | - uses: pnpm/action-setup@v2
17 | with:
18 | version: 8
19 | - name: Use Node v${{ matrix.node-version }}
20 | uses: actions/setup-node@v3
21 | with:
22 | node-version: ${{ matrix.node-version }}
23 | cache: "pnpm"
24 | - name: Install dependencies
25 | run: pnpm install
26 | - name: Sherif
27 | run: pnpm run sherif
28 | - name: Publint
29 | run: pnpm run publint
30 | - name: Run tests
31 | run: pnpm run test
32 | - name: Build
33 | run: pnpm run build
34 |
--------------------------------------------------------------------------------
/.github/workflows/publish.yaml:
--------------------------------------------------------------------------------
1 | on:
2 | push:
3 | tags:
4 | - "v*"
5 | jobs:
6 | build:
7 | runs-on: ubuntu-22.04
8 | steps:
9 | - uses: actions/checkout@v3
10 | - uses: pnpm/action-setup@v2
11 | with:
12 | version: 8
13 | - name: Use Node v20
14 | uses: actions/setup-node@v3
15 | with:
16 | node-version: 20
17 | cache: "pnpm"
18 | - name: Install dependencies
19 | run: pnpm install
20 | - name: Sherif
21 | run: pnpm run sherif
22 | - name: Publint
23 | run: pnpm run publint
24 | - name: Run tests
25 | run: pnpm run test
26 | - name: Build
27 | run: pnpm run build
28 | - name: Publish
29 | run: pnpm publish --filter windy-radix-palette
30 | env:
31 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
32 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | dist
3 | .turbo
4 | .astro
5 | .vercel
6 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Ross Bratton
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.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Windy Radix Palette
2 |
3 | An unofficial package to improve the compatibility of [Radix Colors](https://www.radix-ui.com/colors) and [Tailwind](https://tailwindcss.com/).
4 |
5 | ### [You probably don't need to use this plugin!](#using-radix-colors-directly)
6 |
7 | > [!WARNING]
8 | > The following documentation is for version 2.x of this package.
9 | > v1.0.0 of this package has an issue that makes it unable to display P3 colors. There is a v2.0.0-beta.x version available which fixes this issue.
10 |
11 | ## Installation
12 |
13 | ```sh
14 | npm install --save-dev windy-radix-palette @radix-ui/colors
15 | ```
16 |
17 | ## Usage
18 |
19 | Add the plugin to your Tailwind config:
20 |
21 | ```js
22 | const { createPlugin } = require("windy-radix-palette");
23 |
24 | const colors = createPlugin();
25 |
26 | module.exports = {
27 | plugins: [colors.plugin],
28 | };
29 | ```
30 |
31 | Then you can use the classes in your markup!
32 |
33 | ```html
34 |
35 | ```
36 |
37 | ## Customization
38 |
39 | ### Colors
40 |
41 | By default, this plugin will add CSS properties for **all** of the available Radix Colors. This adds many hundreds of CSS properties into your stylesheet. If this is an issue for your case, you can tell the plugin which colors you'd like it to generate for you:
42 |
43 | ```js
44 | const radixColors = require("@radix-ui/colors");
45 | const { createPlugin } = require("windy-radix-palette");
46 |
47 | const colors = createPlugin({
48 | colors: {
49 | mauveA: radixColors.mauveA,
50 | mauveDarkA: radixColors.mauveDarkA,
51 | red: radixColors.red,
52 | redDark: radixColors.redDark,
53 | },
54 | });
55 |
56 | module.exports = {
57 | plugins: [colors.plugin],
58 | };
59 | ```
60 |
61 | ## Aliasing
62 |
63 | The return value from `createPlugin()` includes an `alias` function. This function can be called to help create aliases for Radix Colors, or arbitrary values.
64 |
65 | ### Semantic aliases
66 |
67 | Creating semantic aliases for colors can be helpful to when it comes to theming. For example, in western culture, it would be common to see `red` mapped to "danger", `yellow` to "warning", and `green` to "success".
68 |
69 | ```js
70 | const { createPlugin } = require("windy-radix-palette");
71 |
72 | const colors = createPlugin();
73 |
74 | module.exports = {
75 | theme: {
76 | extend: {
77 | colors: {
78 | danger: {
79 | 1: colors.alias("red.1"),
80 | 2: colors.alias("red.2"),
81 | },
82 | warning: {
83 | 1: colors.alias("yellow.1"),
84 | 2: colors.alias("yellow.2"),
85 | },
86 | success: {
87 | 1: colors.alias("green.1"),
88 | 2: colors.alias("green.2"),
89 | },
90 | },
91 | },
92 | },
93 | };
94 | ```
95 |
96 | ### Renaming scales
97 |
98 | If you wish to rename a scale, just omit the scale step from the alias:
99 |
100 | ```js
101 | const { createPlugin } = require("windy-radix-palette");
102 |
103 | const colors = createPlugin();
104 |
105 | module.exports = {
106 | theme: {
107 | extend: {
108 | colors: {
109 | danger: colors.alias("red"),
110 | warning: colors.alias("yellow"),
111 | success: colors.alias("green"),
112 | },
113 | },
114 | },
115 | };
116 | ```
117 |
118 | This will make `danger-1` map to `red-1`, `danger-2` map to `red-2`, etc.
119 |
120 | ### Mutable aliases
121 |
122 | > When designing for both light and dark modes, you sometimes need to map a variable to one color in light mode, and another color in dark mode. Common examples include:
123 | >
124 | > - Components that have a white background in light mode and a subtle gray background in dark mode. For example, Card, Popover, DropdownMenu, HoverCard, Dialog etc.
125 | > - Components that have a transparent black background in light mode and a transparent white background in dark mode. For example, Tooltip.
126 | > - Shadows that are saturated, transparent gray in light mode, and pure black in dark mode.
127 | > - An overlay that is light transparent black in light mode, and a darker transparent black in dark mode.
128 | >
129 | > — [Radix Colors](https://www.radix-ui.com/colors/docs/overview/aliasing#mutable-aliases)
130 |
131 | ```js
132 | const { createPlugin } = require("windy-radix-palette");
133 |
134 | const colors = createPlugin();
135 |
136 | module.exports = {
137 | theme: {
138 | extend: {
139 | colors: {
140 | panel: colors.alias({
141 | light: "white",
142 | dark: "slate.2",
143 | }),
144 | "panel-contrast": colors.alias({
145 | light: "blackA.9",
146 | dark: "whiteA.9",
147 | }),
148 | shadow: colors.alias({
149 | light: "slateA.3",
150 | dark: "black",
151 | }),
152 | overlay: colors.alias({
153 | light: "blackA.8",
154 | dark: "blackA.11",
155 | }),
156 | },
157 | },
158 | },
159 | };
160 | ```
161 |
162 | It is also possible to use a mutable alias on an entire scale:
163 |
164 | ```js
165 | const { createPlugin } = require("windy-radix-palette");
166 |
167 | const colors = createPlugin();
168 |
169 | module.exports = {
170 | theme: {
171 | extend: {
172 | colors: {
173 | overlay: colors.alias({
174 | light: "blackA",
175 | dark: "whiteA",
176 | }),
177 | },
178 | },
179 | },
180 | };
181 | ```
182 |
183 | ### Arbitrary values
184 |
185 | You can also use the `alias` function to create aliases for arbitrary values:
186 |
187 | ```js
188 | const { createPlugin } = require("windy-radix-palette");
189 |
190 | const colors = createPlugin();
191 |
192 | module.exports = {
193 | theme: {
194 | extend: {
195 | colors: {
196 | surface: colors.alias({
197 | light: "hsla(0, 0%, 100%, 0.9)",
198 | dark: "rgba(0, 0, 0, 0.25)",
199 | }),
200 | },
201 | },
202 | },
203 | };
204 | ```
205 |
206 | ### CSS variable names
207 |
208 | The `alias` function will try not to create any extra CSS variables if they aren't required. In the case of mutable aliases, however, a CSS variable must be created so that we have a consistent value to reference in Tailwind config.
209 |
210 | By default, any CSS variables created will have the name `--wrp-alias-`, where `` is replaced with a randomly generated sequence of characters.
211 |
212 | If you want to have control over the name of the generated variable, you can pass a `name` property to your alias. The variable will use the name provided, for example, the following code will create a CSS variable `--surface`:
213 |
214 | ```js
215 | const { createPlugin } = require("windy-radix-palette");
216 |
217 | const colors = createPlugin();
218 |
219 | module.exports = {
220 | theme: {
221 | extend: {
222 | colors: {
223 | surface: colors.alias({
224 | name: "surface",
225 | light: "hsla(0, 0%, 100%, 0.9)",
226 | dark: "rgba(0, 0, 0, 0.25)",
227 | }),
228 | },
229 | },
230 | },
231 | };
232 | ```
233 |
234 | ### Opacity Support
235 |
236 | Use of Tailwind's opacity modifier is disabled by default. This means that classes like the following will not work with the default plugin configuration:
237 |
238 | ```html
239 |
240 | ```
241 |
242 | This is partially an opinionated decision (the Radix Colors are hand-picked with purpose), but also because it makes support for the P3 colors included in Radix Colors v3 a much better experience for users of this plugin.
243 |
244 | ```js
245 | const { createPlugin } = require("windy-radix-palette");
246 |
247 | const colors = createPlugin({
248 | opacitySupport: true,
249 | });
250 |
251 | module.exports = {
252 | plugins: [colors.plugin],
253 | };
254 | ```
255 |
256 | If you'd like to enable support for the opacity modifier, bear in mind that P3 colors will not be automatically applied when support is detected, and instead you will have to do this manually, with the help of the `p3` modifier added by this plugin:
257 |
258 | ```html
259 |
260 | ```
261 |
262 | ### Root Selector
263 |
264 | By default, this plugin will add CSS properties to the `:root` CSS [pseudo-class](https://developer.mozilla.org/en-US/docs/Web/CSS/:root). The selector where these properties are placed can be customized via the `rootSelector` option. For example, when working with shadow DOM you might want to put the properties under the `:host` selector:
265 |
266 | ```js
267 | const { createPlugin } = require("windy-radix-palette");
268 |
269 | const colors = createPlugin({
270 | rootSelector: ":host",
271 | });
272 |
273 | module.exports = {
274 | plugins: [colors.plugin],
275 | };
276 | ```
277 |
278 | ## Dark mode
279 |
280 | The colors in this palette will automatically switch to the light/dark variant based on your Tailwind dark mode settings:
281 |
282 | - When `darkMode` is not set, or is set to `'media'`, the palette will change based on the user's preferred color scheme ([`prefers-color-scheme`](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme))
283 | - When `darkMode` is set to `'class'`, the palette will change based on the presence of the dark mode selector (defaults to `.dark`), note that you can [customize the dark mode selector](https://tailwindcss.com/docs/dark-mode#customizing-the-class-name) if required
284 |
285 | ## Typography
286 |
287 | We also ship a typography preset that is meant to be used in combination with `windy-radix-palette` and `@tailwindcss/typography`. It adds custom color themes for all available Radix colors.
288 |
289 | ### Installation
290 |
291 | ```sh
292 | npm install --save-dev windy-radix-typography @tailwindcss/typography
293 | ```
294 |
295 | ### Usage
296 |
297 | Add it to your Tailwind config:
298 |
299 | ```js
300 | const { createPlugin } = require("windy-radix-palette");
301 |
302 | const colors = createPlugin();
303 |
304 | module.exports = {
305 | plugins: [colors.plugin, require("@tailwindcss/typography")],
306 | presets: [require("windy-radix-typography")],
307 | };
308 | ```
309 |
310 | Now you can use the prose themes in your markup:
311 |
312 | ```html
313 |
...
314 | ```
315 |
316 | ### Customization
317 |
318 | Customization is done in the way you'd typically customize typography styles in Tailwind. Let's say that you want to make `a` tags blue:
319 |
320 | ```js
321 |
...
322 | ```
323 |
324 | ## Using Radix Colors directly
325 |
326 | **You probably don't need to use this plugin!**
327 |
328 | Here is one way you can use Radix Colors with Tailwind, without this plugin:
329 |
330 | #### 1. Import Radix Colors you want to use in your CSS
331 |
332 | ```css
333 | @import "tailwindcss/base";
334 | @import "tailwindcss/components";
335 | @import "tailwindcss/utilities";
336 |
337 | @import "@radix-ui/colors/slate";
338 | @import "@radix-ui/colors/slate-alpha";
339 | @import "@radix-ui/colors/slate-dark";
340 | @import "@radix-ui/colors/slate-dark-alpha";
341 | ```
342 |
343 | #### 2. Add the colors to your Tailwind config
344 |
345 | ```js
346 | module.exports = {
347 | // ...
348 | theme: {
349 | extend: {
350 | colors: {
351 | slate: {
352 | 1: "var(--slate-1)",
353 | 2: "var(--slate-2)",
354 | 3: "var(--slate-3)",
355 | 4: "var(--slate-4)",
356 | 5: "var(--slate-5)",
357 | 6: "var(--slate-6)",
358 | 7: "var(--slate-7)",
359 | 8: "var(--slate-8)",
360 | 9: "var(--slate-9)",
361 | 10: "var(--slate-10)",
362 | 11: "var(--slate-11)",
363 | 12: "var(--slate-12)",
364 | a1: "var(--slate-a1)",
365 | a2: "var(--slate-a2)",
366 | a3: "var(--slate-a3)",
367 | a4: "var(--slate-a4)",
368 | a5: "var(--slate-a5)",
369 | a6: "var(--slate-a6)",
370 | a7: "var(--slate-a7)",
371 | a8: "var(--slate-a8)",
372 | a9: "var(--slate-a9)",
373 | a10: "var(--slate-a10)",
374 | a11: "var(--slate-a11)",
375 | a12: "var(--slate-a12)",
376 | },
377 | },
378 | },
379 | },
380 | };
381 | ```
382 |
383 | #### 3. Use colors in your markup
384 |
385 | ```html
386 |
389 | ```
390 |
391 | My reason for originally creating this plugin was to generate a version of the Radix Colors `.css` files that used the `.dark` selector, instead of `.dark-mode`, which used to be the only selector used by Radix Colors for dark mode at the time.
392 |
393 | What I didn't realize at that time was that [Tailwind supports customizing the dark mode selector](https://tailwindcss.com/docs/dark-mode#customizing-the-class-name), so you would have been able to integrate the two pretty easily without the trouble of using a plugin.
394 |
395 | Nowadays, Radix Colors dark mode actually also uses the `.dark` selector as well, which means that it works nicely with Tailwind out of the box. In fact, there are examples of Radix and Tailwind integration on the Radix Primitives docs.
396 |
397 | ## Prior Art
398 |
399 | - [Radix UI](https://github.com/radix-ui)
400 |
--------------------------------------------------------------------------------
/docs/.gitignore:
--------------------------------------------------------------------------------
1 | # build output
2 | dist/
3 |
4 | # dependencies
5 | node_modules/
6 |
7 | # logs
8 | npm-debug.log*
9 | yarn-debug.log*
10 | yarn-error.log*
11 | pnpm-debug.log*
12 |
13 |
14 | # environment variables
15 | .env
16 | .env.production
17 |
18 | # macOS-specific files
19 | .DS_Store
20 |
21 | .astro
22 |
--------------------------------------------------------------------------------
/docs/README.md:
--------------------------------------------------------------------------------
1 | # Astro Starter Kit: Minimal
2 |
3 | ```
4 | npm init astro -- --template minimal
5 | ```
6 |
7 | [](https://stackblitz.com/github/withastro/astro/tree/latest/examples/minimal)
8 |
9 | > 🧑🚀 **Seasoned astronaut?** Delete this file. Have fun!
10 |
11 | ## 🚀 Project Structure
12 |
13 | Inside of your Astro project, you'll see the following folders and files:
14 |
15 | ```
16 | /
17 | ├── public/
18 | ├── src/
19 | │ └── pages/
20 | │ └── index.astro
21 | └── package.json
22 | ```
23 |
24 | Astro looks for `.astro` or `.md` files in the `src/pages/` directory. Each page is exposed as a route based on its file name.
25 |
26 | There's nothing special about `src/components/`, but that's where we like to put any Astro/React/Vue/Svelte/Preact components.
27 |
28 | Any static assets, like images, can be placed in the `public/` directory.
29 |
30 | ## 🧞 Commands
31 |
32 | All commands are run from the root of the project, from a terminal:
33 |
34 | | Command | Action |
35 | | :--------------------- | :----------------------------------------------- |
36 | | `npm install` | Installs dependencies |
37 | | `npm run dev` | Starts local dev server at `localhost:3000` |
38 | | `npm run build` | Build your production site to `./dist/` |
39 | | `npm run preview` | Preview your build locally, before deploying |
40 | | `npm run astro ...` | Run CLI commands like `astro add`, `astro check` |
41 | | `npm run astro --help` | Get help using the Astro CLI |
42 |
43 | ## 👀 Want to learn more?
44 |
45 | Feel free to check [our documentation](https://docs.astro.build) or jump into our [Discord server](https://astro.build/chat).
46 |
--------------------------------------------------------------------------------
/docs/astro.config.mjs:
--------------------------------------------------------------------------------
1 | import { defineConfig } from "astro/config";
2 | import mdx from "@astrojs/mdx";
3 | import tailwind from "@astrojs/tailwind";
4 | import vercel from "@astrojs/vercel/serverless";
5 |
6 | export default defineConfig({
7 | site: "https://windy-radix-palette.vercel.app",
8 | integrations: [
9 | mdx(),
10 | tailwind({
11 | applyBaseStyles: false,
12 | }),
13 | ],
14 | output: "server",
15 | adapter: vercel(),
16 | });
17 |
--------------------------------------------------------------------------------
/docs/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "docs",
3 | "version": "0.0.1",
4 | "private": true,
5 | "scripts": {
6 | "dev": "astro dev",
7 | "start": "astro dev",
8 | "build": "astro build",
9 | "preview": "astro preview",
10 | "astro": "astro"
11 | },
12 | "dependencies": {
13 | "@astrojs/vercel": "^5.1.0",
14 | "htmx.org": "^1.9.6"
15 | },
16 | "devDependencies": {
17 | "@astrojs/mdx": "^1.1.3",
18 | "@astrojs/tailwind": "^5.0.2",
19 | "@radix-ui/colors": "3.0.0",
20 | "@tailwindcss/typography": "^0.5.10",
21 | "astro": "^3.4.0",
22 | "tailwindcss": "^3.3.5",
23 | "windy-radix-palette": "workspace:*",
24 | "windy-radix-typography": "workspace:*"
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/docs/postcss.config.cjs:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | plugins: {
3 | tailwindcss: {},
4 | autoprefixer: {},
5 | },
6 | };
7 |
--------------------------------------------------------------------------------
/docs/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/brattonross/windy-radix-palette/f55b36bc2620bf4d107d5c576f670463e814b2e9/docs/public/favicon.ico
--------------------------------------------------------------------------------
/docs/public/icons.svg:
--------------------------------------------------------------------------------
1 |
21 |
--------------------------------------------------------------------------------
/docs/src/components/sample.mdx:
--------------------------------------------------------------------------------
1 |
2 | Until now, trying to style an article, document, or blog post with Tailwind has been a tedious
3 | task that required a keen eye for typography and a lot of complex custom CSS.
4 |
5 |
6 | By default, Tailwind removes all of the default browser styling from paragraphs, headings, lists and more. This ends up being really useful for building application UIs because you spend less time undoing user-agent styles, but when you _really are_ just trying to style some content that came from a rich-text editor in a CMS or a markdown file, it can be surprising and unintuitive.
7 |
8 | We get lots of complaints about it actually, with people regularly asking us things like:
9 |
10 | > Why is Tailwind removing the default styles on my `h1` elements? How do I disable this? What do you mean I lose all the other base styles too?
11 |
12 | We hear you, but we're not convinced that simply disabling our base styles is what you really want. You don't want to have to remove annoying margins every time you use a `p` element in a piece of your dashboard UI. And I doubt you really want your blog posts to use the user-agent styles either — you want them to look _awesome_, not awful.
13 |
14 | The `@tailwindcss/typography` plugin is our attempt to give you what you _actually_ want, without any of the downsides of doing something stupid like disabling our base styles.
15 |
16 | It adds a new `prose` class that you can slap on any block of vanilla HTML content and turn it into a beautiful, well-formatted document:
17 |
18 | ```html
19 |
20 |
Garlic bread with cheese: What the science tells us
21 |
22 | For years parents have espoused the health benefits of eating garlic bread with cheese to their
23 | children, with the food earning such an iconic status in our culture that kids will often dress
24 | up as warm, cheesy loaf for Halloween.
25 |
26 |
27 | But a recent study shows that the celebrated appetizer may be linked to a series of rabies cases
28 | springing up around the country.
29 |
30 |
31 |
32 | ```
33 |
34 | For more information about how to use the plugin and the features it includes, [read the documentation](https://github.com/tailwindcss/typography/blob/master/README.md).
35 |
36 | ---
37 |
38 | ## What to expect from here on out
39 |
40 | What follows from here is just a bunch of absolute nonsense I've written to dogfood the plugin itself. It includes every sensible typographic element I could think of, like **bold text**, unordered lists, ordered lists, code blocks, block quotes, _and even italics_.
41 |
42 | It's important to cover all of these use cases for a few reasons:
43 |
44 | 1. We want everything to look good out of the box.
45 | 2. Really just the first reason, that's the whole point of the plugin.
46 | 3. Here's a third pretend reason though a list with three items looks more realistic than a list with two items.
47 |
48 | Now we're going to try out another header style.
49 |
50 | ### Typography should be easy
51 |
52 | So that's a header for you — with any luck if we've done our job correctly that will look pretty reasonable.
53 |
54 | Something a wise person once told me about typography is:
55 |
56 | > Typography is pretty important if you don't want your stuff to look like trash. Make it good then it won't be bad.
57 |
58 | It's probably important that images look okay here by default as well:
59 |
60 |
61 |
65 |
66 | Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of
67 | classical Latin literature from 45 BC, making it over 2000 years old.
68 |
69 |
70 |
71 | Now I'm going to show you an example of an unordered list to make sure that looks good, too:
72 |
73 | - So here is the first item in this list.
74 | - In this example we're keeping the items short.
75 | - Later, we'll use longer, more complex list items.
76 |
77 | And that's the end of this section.
78 |
79 | ## What if we stack headings?
80 |
81 | ### We should make sure that looks good, too.
82 |
83 | Sometimes you have headings directly underneath each other. In those cases you often have to undo the top margin on the second heading because it usually looks better for the headings to be closer together than a paragraph followed by a heading should be.
84 |
85 | ### When a heading comes after a paragraph …
86 |
87 | When a heading comes after a paragraph, we need a bit more space, like I already mentioned above. Now let's see what a more complex list would look like.
88 |
89 | - **I often do this thing where list items have headings.**
90 |
91 | For some reason I think this looks cool which is unfortunate because it's pretty annoying to get the styles right.
92 |
93 | I often have two or three paragraphs in these list items, too, so the hard part is getting the spacing between the paragraphs, list item heading, and separate list items to all make sense. Pretty tough honestly, you could make a strong argument that you just shouldn't write this way.
94 |
95 | - **Since this is a list, I need at least two items.**
96 |
97 | I explained what I'm doing already in the previous list item, but a list wouldn't be a list if it only had one item, and we really want this to look realistic. That's why I've added this second list item so I actually have something to look at when writing the styles.
98 |
99 | - **It's not a bad idea to add a third item either.**
100 |
101 | I think it probably would've been fine to just use two items but three is definitely not worse, and since I seem to be having no trouble making up arbitrary things to type, I might as well include it. I'm going to press Enter now.
102 |
103 | After this sort of list I usually have a closing statement or paragraph, because it kinda looks weird jumping right to a heading.
104 |
105 | ## Code should look okay by default.
106 |
107 | I think most people are going to use [highlight.js](https://highlightjs.org/) or [Prism](https://prismjs.com/) or something if they want to style their code blocks but it wouldn't hurt to make them look _okay_ out of the box, even with no syntax highlighting.
108 |
109 | Here's what a default `tailwind.config.js` file looks like at the time of writing:
110 |
111 | ```js
112 | module.exports = {
113 | purge: [],
114 | theme: {
115 | extend: {},
116 | },
117 | variants: {},
118 | plugins: [],
119 | }
120 | ```
121 |
122 | Hopefully that looks good enough to you.
123 |
124 | ### What about nested lists?
125 |
126 | Nested lists basically always look bad which is why editors like Medium don't even let you do it, but I guess since some of you goofballs are going to do it we have to carry the burden of at least making it work.
127 |
128 | 1. **Nested lists are rarely a good idea.**
129 | - You might feel like you are being really "organized" or something but you are just creating a gross shape on the screen that is hard to read.
130 | - Nested navigation in UIs is a bad idea too, keep things as flat as possible.
131 | - Nesting tons of folders in your source code is also not helpful.
132 | 2. **Since we need to have more items, here's another one.**
133 | - I'm not sure if we'll bother styling more than two levels deep.
134 | - Two is already too much, three is guaranteed to be a bad idea.
135 | - If you nest four levels deep you belong in prison.
136 | 3. **Two items isn't really a list, three is good though.**
137 | - Again please don't nest lists if you want people to actually read your content.
138 | - Nobody wants to look at this.
139 | - I'm upset that we even have to bother styling this.
140 |
141 | The most annoying thing about lists in Markdown is that `
` elements aren't given a child `
` tag unless there are multiple paragraphs in the list item. That means I have to worry about styling that annoying situation too.
142 |
143 | - **For example, here's another nested list.**
144 |
145 | But this time with a second paragraph.
146 |
147 | - These list items won't have `
` tags
148 | - Because they are only one line each
149 |
150 | - **But in this second top-level list item, they will.**
151 |
152 | This is especially annoying because of the spacing on this paragraph.
153 |
154 | - As you can see here, because I've added a second line, this list item now has a `
` tag.
155 |
156 | This is the second line I'm talking about by the way.
157 |
158 | - Finally here's another list item so it's more like a list.
159 |
160 | - A closing list item, but with no nested list, because why not?
161 |
162 | And finally a sentence to close off this section.
163 |
164 | ## We didn't forget about description lists
165 |
166 | Well, that's not exactly true, we first released this plugin back in 2020 and it took three years before we added description lists. But they're here now, so let's just be happy about that…okay? They can be great for things like FAQs.
167 |
168 |
169 |
Why do you never see elephants hiding in trees?
170 |
171 | Because they're so good at it. Lorem ipsum dolor sit amet consectetur adipisicing elit. Quas
172 | cupiditate laboriosam fugiat.
173 |
174 |
What do you call someone with no body and no nose?
175 |
176 | Nobody knows. Lorem ipsum dolor sit amet consectetur adipisicing elit. Culpa, voluptas ipsa quia
177 | excepturi, quibusdam natus exercitationem sapiente tempore labore voluptatem.
178 |
179 |
Why can't you hear a pterodactyl go to the bathroom?
180 |
181 | Because the pee is silent. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsam, quas
182 | voluptatibus ex culpa ipsum, aspernatur blanditiis fugiat ullam magnam suscipit deserunt illum
183 | natus facilis atque vero consequatur! Quisquam, debitis error.
184 |
185 |
186 |
187 | ## There are other elements we need to style
188 |
189 | I almost forgot to mention links, like [this link to the Tailwind CSS website](https://tailwindcss.com). We almost made them blue but that's so yesterday, so we went with dark gray, feels edgier.
190 |
191 | We even included table styles, check it out:
192 |
193 | | Wrestler | Origin | Finisher |
194 | | ----------------------- | ------------ | ------------------ |
195 | | Bret "The Hitman" Hart | Calgary, AB | Sharpshooter |
196 | | Stone Cold Steve Austin | Austin, TX | Stone Cold Stunner |
197 | | Randy Savage | Sarasota, FL | Elbow Drop |
198 | | Vader | Boulder, CO | Vader Bomb |
199 | | Razor Ramon | Chuluota, FL | Razor's Edge |
200 |
201 | We also need to make sure inline code looks good, like if I wanted to talk about `` elements or tell you the good news about `@tailwindcss/typography`.
202 |
203 | ### Sometimes I even use `code` in headings
204 |
205 | Even though it's probably a bad idea, and historically I've had a hard time making it look good. This _"wrap the code blocks in backticks"_ trick works pretty well though really.
206 |
207 | Another thing I've done in the past is put a `code` tag inside of a link, like if I wanted to tell you about the [`tailwindcss/docs`](https://github.com/tailwindcss/docs) repository. I don't love that there is an underline below the backticks but it is absolutely not worth the madness it would require to avoid it.
208 |
209 | #### We haven't used an `h4` yet
210 |
211 | But now we have. Please don't use `h5` or `h6` in your content, Medium only supports two heading levels for a reason, you animals. I honestly considered using a `before` pseudo-element to scream at you if you use an `h5` or `h6`.
212 |
213 | We don't style them at all out of the box because `h4` elements are already so small that they are the same size as the body copy. What are we supposed to do with an `h5`, make it _smaller_ than the body copy? No thanks.
214 |
215 | ### We still need to think about stacked headings though.
216 |
217 | #### Let's make sure we don't screw that up with `h4` elements, either.
218 |
219 | Phew, with any luck we have styled the headings above this text and they look pretty good.
220 |
221 | Let's add a closing paragraph here so things end with a decently sized block of text. I can't explain why I want things to end that way but I have to assume it's because I think things will look weird or unbalanced if there is a heading too close to the end of the document.
222 |
223 | What I've written here is probably long enough, but adding this final sentence can't hurt.
224 |
--------------------------------------------------------------------------------
/docs/src/env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 | ///
3 |
--------------------------------------------------------------------------------
/docs/src/layouts/BaseLayout.astro:
--------------------------------------------------------------------------------
1 | ---
2 | import "~/tailwind.css";
3 |
4 | export interface Props {
5 | description?: string;
6 | title?: string;
7 | }
8 |
9 | const { description, title } = Astro.props;
10 |
11 | const currentTheme = Astro.cookies.has("wrp_theme")
12 | ? Astro.cookies.get("wrp_theme")?.value ?? "system"
13 | : "system";
14 | ---
15 |
16 |
23 |
24 |
25 |
26 | {
27 | title ? (
28 | {title} – windy-radix-palette
29 | ) : (
30 | windy-radix-palette
31 | )
32 | }
33 | {description ? : null}
34 |
35 | {currentTheme === "system" ? (
36 |
42 | ) : null}
43 |
71 |
72 |
76 |
79 |