@nauverse/tailwind-dot-grid-backgrounds 1.2.14 → 2.0.1

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/README.md CHANGED
@@ -4,144 +4,154 @@
4
4
  </h1>
5
5
 
6
6
  <p align="center">
7
- <img src="https://raw.githubusercontent.com/TheNaubit/tailwind-dot-grid-backgrounds/v1/images/header.png" alt="tailwind-dot-grid-backgrounds: dot and grid backgrounds for Tailwind CSS" />
7
+ <img src="https://raw.githubusercontent.com/TheNaubit/tailwind-dot-grid-backgrounds/main/images/header.png" alt="tailwind-dot-grid-backgrounds: dot and grid backgrounds for Tailwind CSS" />
8
8
  </p>
9
9
 
10
- <h4 align="center">A tiny Tailwind CSS plugin to add dot and grid customizable backgrounds fast</h4>
10
+ <h4 align="center">A tiny Tailwind CSS plugin to add customizable dot and grid backgrounds fast, in pure CSS</h4>
11
11
 
12
12
  <p align="center">
13
13
  <a href="https://github.com/TheNaubit/tailwind-dot-grid-backgrounds/actions/workflows/ci.yml">
14
- <img src="https://github.com/TheNaubit/tailwind-dot-grid-backgrounds/actions/workflows/ci.yml/badge.svg?branch=v1" alt="CI status">
14
+ <img src="https://github.com/TheNaubit/tailwind-dot-grid-backgrounds/actions/workflows/ci.yml/badge.svg?branch=main" alt="CI status">
15
+ </a>
16
+ <a href="https://github.com/TheNaubit/tailwind-dot-grid-backgrounds/actions/workflows/release.yml">
17
+ <img src="https://github.com/TheNaubit/tailwind-dot-grid-backgrounds/actions/workflows/release.yml/badge.svg?branch=main" alt="Release status">
15
18
  </a>
16
19
  <a href="https://www.npmjs.com/package/@nauverse/tailwind-dot-grid-backgrounds">
17
- <img src="https://img.shields.io/npm/v/@nauverse/tailwind-dot-grid-backgrounds/v1.svg?style=flat&label=npm%40v1" alt="npm version">
20
+ <img src="https://img.shields.io/npm/v/@nauverse/tailwind-dot-grid-backgrounds.svg?style=flat" alt="npm version">
18
21
  </a>
19
- <a href="https://bundlephobia.com/result?p=@nauverse/tailwind-dot-grid-backgrounds">
20
- <img src="https://img.shields.io/bundlephobia/minzip/%40nauverse/tailwind-dot-grid-backgrounds" alt="minzipped size">
22
+ <a href="https://www.npmjs.com/package/@nauverse/tailwind-dot-grid-backgrounds">
23
+ <img src="https://img.shields.io/npm/l/@nauverse/tailwind-dot-grid-backgrounds.svg?style=flat" alt="license">
21
24
  </a>
22
25
  </p>
23
26
 
24
27
  <p align="center">
25
- <a href="#what">What?</a> •
28
+ <a href="#tldr">tl;dr</a> •
26
29
  <a href="#guide-and-examples">Guide and examples</a> •
30
+ <a href="#migrating-from-v1">Migrating from v1</a> •
27
31
  <a href="#help">Help</a> •
28
32
  <a href="#contribute">Contribute</a>
29
33
  </p>
30
34
 
31
- > [!IMPORTANT]
32
- > **This is the `v1` line of the plugin, for Tailwind CSS v3.**
33
- >
34
- > Using **Tailwind CSS v4**? Use the latest version instead (`v2` and later). It is a pure CSS plugin with no JavaScript, loaded with `@import "@nauverse/tailwind-dot-grid-backgrounds";`. See the [main branch README](https://github.com/TheNaubit/tailwind-dot-grid-backgrounds#readme) for its guide and the migration steps.
35
-
36
35
  | Plugin version | Tailwind CSS | How it works | Branch |
37
36
  | -------------- | ------------ | ------------ | ------ |
38
37
  | `2.x` (latest) | `^4.0` | Pure CSS (`@utility`), no JavaScript | [`main`](https://github.com/TheNaubit/tailwind-dot-grid-backgrounds/tree/main) |
39
- | `1.x` | `^3.4` | JavaScript plugin (Node.js `>=22`) | [`v1`](https://github.com/TheNaubit/tailwind-dot-grid-backgrounds/tree/v1) (maintenance) |
38
+ | `1.x` | `^3.4` | JavaScript plugin | [`v1`](https://github.com/TheNaubit/tailwind-dot-grid-backgrounds/tree/v1) (maintenance, [docs](https://github.com/TheNaubit/tailwind-dot-grid-backgrounds/tree/v1#readme)) |
39
+
40
+ Still on Tailwind CSS v3? Install the `v1` line: `npm install --save-dev @nauverse/tailwind-dot-grid-backgrounds@1`.
40
41
 
41
42
  ## tl;dr
42
- This is a Tailwind CSS v3 plugin that allows you to add background grids and background dots in an easy and customizable way.
43
+ This is a Tailwind CSS v4 plugin that allows you to add background grids and background dots in an easy and customizable way.
43
44
 
44
45
  ### 1. Install the dependency
45
46
  ```bash
46
- npm install --save-dev @nauverse/tailwind-dot-grid-backgrounds@1
47
+ npm install --save-dev @nauverse/tailwind-dot-grid-backgrounds
47
48
  ```
48
49
 
49
- ### 2. Add the plugin to your Tailwind CSS config
50
- `tailwind.config.ts` / `tailwind.config.mjs`:
51
- ```ts
52
- import dotGridBackgrounds from "@nauverse/tailwind-dot-grid-backgrounds";
53
- import type { Config } from "tailwindcss";
54
-
55
- export default {
56
- content: ["./src/**/*.{html,js,jsx,ts,tsx}"],
57
- plugins: [
58
- dotGridBackgrounds,
59
- // ... the rest of your Tailwind CSS plugins
60
- ],
61
- } satisfies Config;
62
- ```
63
-
64
- Or, with a CommonJS `tailwind.config.js`:
65
- ```js
66
- /** @type {import('tailwindcss').Config} */
67
- module.exports = {
68
- content: ["./src/**/*.{html,js,jsx,ts,tsx}"],
69
- plugins: [
70
- require("@nauverse/tailwind-dot-grid-backgrounds"),
71
- // ... the rest of your Tailwind CSS plugins
72
- ],
73
- };
50
+ ### 2. Import it in your CSS, after Tailwind CSS
51
+ ```css
52
+ @import "tailwindcss";
53
+ @import "@nauverse/tailwind-dot-grid-backgrounds";
74
54
  ```
75
55
 
76
56
  ### 3. You are done!
77
57
  Try it by adding this HTML to your UI:
78
58
  ```html
79
- <div class="h-screen w-screen bg-yellow-300 bg-grid-8-s-2-neutral-950"></div>
59
+ <div class="h-screen w-screen bg-yellow-300 bg-grid-neutral-950 bg-grid-size-8 bg-grid-stroke-2"></div>
80
60
  ```
81
61
 
82
62
  ## What
83
63
  You could achieve the same by just using some Tailwind CSS code but... I found myself adding this kind of background in my projects very often. So I created a small Tailwind CSS plugin to allow me adding these backgrounds while keeping all the customization offered by Tailwind CSS.
84
64
 
85
65
  ### Features
86
- - Fully integrated with Tailwind CSS: it uses your theme colors, widths and border widths
87
- - Performant: the backgrounds are rendered with CSS gradients, no images
66
+ - Fully integrated with Tailwind CSS: theme colors, opacity modifiers, the spacing scale, arbitrary values and every variant (`hover:`, `md:`, `dark:`...)
67
+ - Pure CSS: just an `@import`, no JavaScript and no configuration
68
+ - Performant: the backgrounds are CSS gradients, and only the classes you use are generated
88
69
  - Zero dependencies
89
- - Tested
90
- - Easy to use, straight to the point
70
+ - Tested against the latest and the oldest supported Tailwind CSS v4 releases
91
71
 
92
72
  ## Guide and examples
93
73
 
94
- ### Background Grid
95
- Pattern: `bg-grid-<SIZE>-s-<STROKE_WIDTH>-<COLOR>`
74
+ A pattern is drawn by its color class. Its size and line (or dot) width are optional classes that you can combine with it, so each part can change on its own with variants (for example `md:bg-grid-size-12`).
75
+
76
+ ### Background grid
96
77
 
97
- - `<SIZE>` is the size of the grid squares. It accepts the keys of the `width` theme whose value is in `px` or `rem` (such as `8`, `0.5`, `px`...). You will see the available options in IntelliSense.
98
- - `<STROKE_WIDTH>` is the width of the strokes of the grid squares. It accepts the keys of the `borderWidth` theme whose value is in `px` or `rem` (such as `0`, `2`, `4`, `8`), plus `1` (since Tailwind CSS does not have a `border-1` class).
99
- - `<COLOR>` is the color of the strokes. It accepts any color of your theme, an opacity modifier (`/50`) and arbitrary values (`[#ff0000]`).
78
+ | Class | What it sets | Default |
79
+ | ----- | ------------ | ------- |
80
+ | `bg-grid-<color>` | Draws the grid with this line color | - |
81
+ | `bg-grid-size-<number>` | The size of the squares, in spacing units (like `w-<number>`) | `8` (`2rem`) |
82
+ | `bg-grid-stroke-<number>` | The width of the lines, in pixels | `1` (`1px`) |
83
+
84
+ - `<color>` accepts any theme color (`neutral-950`, your own `--color-*` variables) with an optional opacity modifier (`bg-grid-blue-700/80`, `bg-grid-blue-700/[35%]`), arbitrary values (`bg-grid-[#ff0000]`), CSS variables (`bg-grid-(--my-color)`) and `current` (`bg-grid-current` has no opacity modifier: use `bg-grid-[color-mix(in_oklab,currentcolor_50%,transparent)]` instead).
85
+ - `bg-grid-size-*` also accepts `--spacing-*` theme keys (`bg-grid-size-cell` with `--spacing-cell: 18px`), arbitrary lengths (`bg-grid-size-[18px]`) and CSS variables (`bg-grid-size-(--cell)`).
86
+ - `bg-grid-stroke-*` also accepts decimals (`bg-grid-stroke-0.5`), arbitrary lengths (`bg-grid-stroke-[0.1rem]`) and CSS variables (`bg-grid-stroke-(--line)`).
87
+ - Arbitrary values are not validated, like in Tailwind CSS itself: `bg-grid-[10px]` generates a class that draws nothing.
100
88
 
101
89
  #### Examples:
102
- `bg-grid-8-s-2-neutral-950`
90
+ `bg-grid-neutral-950 bg-grid-size-8 bg-grid-stroke-2`
103
91
  <p align="center">
104
- <img src="https://raw.githubusercontent.com/TheNaubit/tailwind-dot-grid-backgrounds/f3e4cac4117dee081ed982739d3c38ff12544869/images/bg-grid-8-s-2-neutral-950.png" alt="tailwind-dot-grid-backgrounds bg-grid-8-s-2-neutral-950" />
92
+ <img src="https://raw.githubusercontent.com/TheNaubit/tailwind-dot-grid-backgrounds/f3e4cac4117dee081ed982739d3c38ff12544869/images/bg-grid-8-s-2-neutral-950.png" alt="bg-grid-neutral-950 bg-grid-size-8 bg-grid-stroke-2" />
105
93
  </p>
106
94
 
107
- `bg-grid-48-s-8-blue-700/80`
95
+ `bg-grid-blue-700/80 bg-grid-size-48 bg-grid-stroke-8`
108
96
  <p align="center">
109
- <img src="https://raw.githubusercontent.com/TheNaubit/tailwind-dot-grid-backgrounds/f3e4cac4117dee081ed982739d3c38ff12544869/images/bg-grid-48-s-8-blue-700_80.png" alt="tailwind-dot-grid-backgrounds bg-grid-48-s-8-blue-700/80" />
97
+ <img src="https://raw.githubusercontent.com/TheNaubit/tailwind-dot-grid-backgrounds/f3e4cac4117dee081ed982739d3c38ff12544869/images/bg-grid-48-s-8-blue-700_80.png" alt="bg-grid-blue-700/80 bg-grid-size-48 bg-grid-stroke-8" />
110
98
  </p>
111
99
 
112
- ### Background Dots
113
- Pattern: `bg-dot-<SIZE>-s-<DOT_SIZE>-<COLOR>`
100
+ ### Background dots
101
+
102
+ | Class | What it sets | Default |
103
+ | ----- | ------------ | ------- |
104
+ | `bg-dot-<color>` | Draws the dots with this color | - |
105
+ | `bg-dot-size-<number>` | The distance between the dots (in both axes), in spacing units | `8` (`2rem`) |
106
+ | `bg-dot-radius-<number>` | The radius of the dots, in pixels | `1` (`1px`) |
114
107
 
115
- - `<SIZE>` is the size of the space (in both axes) between the dots. It accepts the keys of the `width` theme whose value is in `px` or `rem`. You will see the available options in IntelliSense.
116
- - `<DOT_SIZE>` is the radius of the dots. It accepts the keys of the `borderWidth` theme whose value is in `px` or `rem`, plus `1`.
117
- - `<COLOR>` is the color of the dots. It accepts any color of your theme, an opacity modifier (`/50`) and arbitrary values (`[#ff0000]`).
108
+ They accept the same values as their grid counterparts.
118
109
 
119
110
  #### Examples:
120
- `bg-dot-8-s-2-neutral-950`
111
+ `bg-dot-neutral-950 bg-dot-size-8 bg-dot-radius-2`
121
112
  <p align="center">
122
- <img src="https://raw.githubusercontent.com/TheNaubit/tailwind-dot-grid-backgrounds/f3e4cac4117dee081ed982739d3c38ff12544869/images/bg-dot-8-s-2-neutral-950.png" alt="tailwind-dot-grid-backgrounds bg-dot-8-s-2-neutral-950" />
113
+ <img src="https://raw.githubusercontent.com/TheNaubit/tailwind-dot-grid-backgrounds/f3e4cac4117dee081ed982739d3c38ff12544869/images/bg-dot-8-s-2-neutral-950.png" alt="bg-dot-neutral-950 bg-dot-size-8 bg-dot-radius-2" />
123
114
  </p>
124
115
 
125
- `bg-dot-16-s-8-blue-700/80`
116
+ `bg-dot-blue-700/80 bg-dot-size-16 bg-dot-radius-8`
126
117
  <p align="center">
127
- <img src="https://raw.githubusercontent.com/TheNaubit/tailwind-dot-grid-backgrounds/f3e4cac4117dee081ed982739d3c38ff12544869/images/bg-dot-16-s-8-blue-700_80.png" alt="tailwind-dot-grid-backgrounds bg-dot-16-s-8-blue-700/80" />
118
+ <img src="https://raw.githubusercontent.com/TheNaubit/tailwind-dot-grid-backgrounds/f3e4cac4117dee081ed982739d3c38ff12544869/images/bg-dot-16-s-8-blue-700_80.png" alt="bg-dot-blue-700/80 bg-dot-size-16 bg-dot-radius-8" />
128
119
  </p>
129
120
 
130
121
  ### Customizing
131
- The plugin reads your theme, so extending it adds new classes:
132
-
133
- ```ts
134
- export default {
135
- theme: {
136
- extend: {
137
- colors: { brand: { DEFAULT: "#123456", soft: "#abcdef" } }, // bg-grid-8-s-1-brand, bg-dot-8-s-1-brand-soft
138
- width: { cell: "18px" }, // bg-grid-cell-s-1-red-500
139
- borderWidth: { thick: "3px" }, // bg-grid-8-s-thick-red-500
140
- },
141
- },
142
- } satisfies Config;
122
+ Everything comes from your Tailwind CSS theme:
123
+
124
+ ```css
125
+ @import "tailwindcss";
126
+ @import "@nauverse/tailwind-dot-grid-backgrounds";
127
+
128
+ @theme {
129
+ --color-brand: #123456; /* bg-grid-brand, bg-dot-brand/50 */
130
+ --spacing-cell: 18px; /* bg-grid-size-cell */
131
+ }
143
132
  ```
144
133
 
134
+ The pattern settings are stored in the `--bg-grid-color`, `--bg-grid-size`, `--bg-grid-stroke`, `--bg-dot-color`, `--bg-dot-size` and `--bg-dot-radius` CSS variables. They are registered with `@property` as non-inherited, so a pattern never leaks into the patterns of its children.
135
+
136
+ ## Migrating from v1
137
+
138
+ Version 2 is for Tailwind CSS v4. It is a pure CSS plugin, and each part of a pattern is now its own class.
139
+
140
+ 1. Upgrade to Tailwind CSS v4 ([upgrade guide](https://tailwindcss.com/docs/upgrade-guide)).
141
+ 2. Install the latest version: `npm install --save-dev @nauverse/tailwind-dot-grid-backgrounds@latest`.
142
+ 3. Remove the plugin from your `tailwind.config.*` `plugins` (or the `@plugin` directive) and add `@import "@nauverse/tailwind-dot-grid-backgrounds";` after `@import "tailwindcss";`.
143
+ 4. Replace the classes. `<SIZE>`, `<STROKE_WIDTH>`/`<DOT_SIZE>` and `<COLOR>` keep the same values:
144
+
145
+ | v1 | v2 |
146
+ | -- | -- |
147
+ | `bg-grid-<SIZE>-s-<STROKE_WIDTH>-<COLOR>` | `bg-grid-<COLOR> bg-grid-size-<SIZE> bg-grid-stroke-<STROKE_WIDTH>` |
148
+ | `bg-dot-<SIZE>-s-<DOT_SIZE>-<COLOR>` | `bg-dot-<COLOR> bg-dot-size-<SIZE> bg-dot-radius-<DOT_SIZE>` |
149
+ | `bg-grid-8-s-2-neutral-950` | `bg-grid-neutral-950 bg-grid-size-8 bg-grid-stroke-2` |
150
+ | `bg-dot-16-s-8-blue-700/80` | `bg-dot-blue-700/80 bg-dot-size-16 bg-dot-radius-8` |
151
+ | `bg-grid-px-s-1-red-500` | `bg-grid-red-500 bg-grid-size-[1px]` |
152
+
153
+ Sizes now follow your spacing scale (`--spacing`) instead of being converted to pixels, and the stroke width and dot radius default to `1px`, so `bg-grid-<COLOR> bg-grid-size-<SIZE>` is enough for 1px lines.
154
+
145
155
  ## Help
146
156
 
147
157
  Thank you for using *tailwind-dot-grid-backgrounds*!
@@ -150,7 +160,7 @@ If you need any help using this plugin, feel free to [create a GitHub issue](htt
150
160
 
151
161
  ## Contribute
152
162
 
153
- Contributions of any kind (pull requests, bug reports, feature requests, documentation, design) are more than welcome! Read the [contributing guide](./CONTRIBUTING.md) to get started. Fixes for the Tailwind CSS v3 line go to the `v1` branch.
163
+ Contributions of any kind (pull requests, bug reports, feature requests, documentation, design) are more than welcome! Read the [contributing guide](./CONTRIBUTING.md) to get started (and [AGENTS.md](./AGENTS.md) if you use a coding agent).
154
164
 
155
165
  ## Contributors
156
166
 
package/index.css ADDED
@@ -0,0 +1,99 @@
1
+ /*
2
+ * @nauverse/tailwind-dot-grid-backgrounds
3
+ * Dot and grid backgrounds for Tailwind CSS v4, as pure CSS utilities.
4
+ *
5
+ * Grid: bg-grid-<color>[/<opacity>] bg-grid-size-<spacing> bg-grid-stroke-<px>
6
+ * Dots: bg-dot-<color>[/<opacity>] bg-dot-size-<spacing> bg-dot-radius-<px>
7
+ */
8
+
9
+ /*
10
+ * The pattern settings must not inherit: a nested element would otherwise reuse the size, stroke or color of its parent pattern.
11
+ * Without a value, each utility falls back to its default (1px lines or dots, every 8 spacing units).
12
+ */
13
+ @property --bg-grid-color {
14
+ syntax: "*";
15
+ inherits: false;
16
+ }
17
+
18
+ @property --bg-grid-size {
19
+ syntax: "*";
20
+ inherits: false;
21
+ }
22
+
23
+ @property --bg-grid-stroke {
24
+ syntax: "*";
25
+ inherits: false;
26
+ }
27
+
28
+ @property --bg-dot-color {
29
+ syntax: "*";
30
+ inherits: false;
31
+ }
32
+
33
+ @property --bg-dot-size {
34
+ syntax: "*";
35
+ inherits: false;
36
+ }
37
+
38
+ @property --bg-dot-radius {
39
+ syntax: "*";
40
+ inherits: false;
41
+ }
42
+
43
+ /* ---------------------------------- Grid ---------------------------------- */
44
+
45
+ /* The color of the grid lines (theme color, arbitrary value or CSS variable, with an optional opacity modifier). It also draws the grid. */
46
+ @utility bg-grid-* {
47
+ --bg-grid-color: --value(--color-*, [color], [*]);
48
+ --bg-grid-color: --alpha(--value(--color-*, [color], [*]) / calc(--modifier(number) * 1%));
49
+ --bg-grid-color: --alpha(--value(--color-*, [color], [*]) / --modifier([percentage]));
50
+ background-image: linear-gradient(to right, var(--bg-grid-color) var(--bg-grid-stroke, 1px), transparent var(--bg-grid-stroke, 1px)), linear-gradient(to bottom, var(--bg-grid-color) var(--bg-grid-stroke, 1px), transparent var(--bg-grid-stroke, 1px));
51
+ background-size: var(--bg-grid-size, --spacing(8)) var(--bg-grid-size, --spacing(8));
52
+ }
53
+
54
+ @utility bg-grid-current {
55
+ --bg-grid-color: currentcolor;
56
+ background-image: linear-gradient(to right, var(--bg-grid-color) var(--bg-grid-stroke, 1px), transparent var(--bg-grid-stroke, 1px)), linear-gradient(to bottom, var(--bg-grid-color) var(--bg-grid-stroke, 1px), transparent var(--bg-grid-stroke, 1px));
57
+ background-size: var(--bg-grid-size, --spacing(8)) var(--bg-grid-size, --spacing(8));
58
+ }
59
+
60
+ /* The size of the grid squares: a multiple of the spacing scale, a spacing theme key or an arbitrary length. */
61
+ @utility bg-grid-size-* {
62
+ --bg-grid-size: --spacing(--value(number));
63
+ --bg-grid-size: --value(--spacing-*, [length], [*]);
64
+ }
65
+
66
+ /* The width of the grid lines: a number of pixels or an arbitrary length. */
67
+ @utility bg-grid-stroke-* {
68
+ --bg-grid-stroke: --value(number)px;
69
+ --bg-grid-stroke: --value([length], [*]);
70
+ }
71
+
72
+ /* ---------------------------------- Dots ---------------------------------- */
73
+
74
+ /* The color of the dots (theme color, arbitrary value or CSS variable, with an optional opacity modifier). It also draws the dots. */
75
+ @utility bg-dot-* {
76
+ --bg-dot-color: --value(--color-*, [color], [*]);
77
+ --bg-dot-color: --alpha(--value(--color-*, [color], [*]) / calc(--modifier(number) * 1%));
78
+ --bg-dot-color: --alpha(--value(--color-*, [color], [*]) / --modifier([percentage]));
79
+ background-image: radial-gradient(var(--bg-dot-color) var(--bg-dot-radius, 1px), transparent var(--bg-dot-radius, 1px));
80
+ background-size: var(--bg-dot-size, --spacing(8)) var(--bg-dot-size, --spacing(8));
81
+ }
82
+
83
+ @utility bg-dot-current {
84
+ --bg-dot-color: currentcolor;
85
+ background-image: radial-gradient(var(--bg-dot-color) var(--bg-dot-radius, 1px), transparent var(--bg-dot-radius, 1px));
86
+ background-size: var(--bg-dot-size, --spacing(8)) var(--bg-dot-size, --spacing(8));
87
+ }
88
+
89
+ /* The distance between the dots (in both axes): a multiple of the spacing scale, a spacing theme key or an arbitrary length. */
90
+ @utility bg-dot-size-* {
91
+ --bg-dot-size: --spacing(--value(number));
92
+ --bg-dot-size: --value(--spacing-*, [length], [*]);
93
+ }
94
+
95
+ /* The radius of the dots: a number of pixels or an arbitrary length. */
96
+ @utility bg-dot-radius-* {
97
+ --bg-dot-radius: --value(number)px;
98
+ --bg-dot-radius: --value([length], [*]);
99
+ }
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@nauverse/tailwind-dot-grid-backgrounds",
3
- "description": "🎨 A tiny Tailwind plugin to add dot and grid customizable backgrounds fast",
3
+ "description": "A tiny Tailwind CSS v4 plugin to add customizable dot and grid backgrounds fast, in pure CSS",
4
4
  "author": {
5
5
  "name": "Albert Adler | @IAmAlbertAdler",
6
6
  "url": "https://albertadler.com"
7
7
  },
8
8
  "license": "MIT",
9
- "homepage": "https://github.com/TheNaubit/tailwind-dot-grid-backgrounds/tree/v1#readme",
9
+ "homepage": "https://github.com/TheNaubit/tailwind-dot-grid-backgrounds#readme",
10
10
  "repository": {
11
11
  "type": "git",
12
- "url": "https://github.com/TheNaubit/tailwind-dot-grid-backgrounds.git"
12
+ "url": "git+https://github.com/TheNaubit/tailwind-dot-grid-backgrounds.git"
13
13
  },
14
14
  "bugs": {
15
15
  "url": "https://github.com/TheNaubit/tailwind-dot-grid-backgrounds/issues"
@@ -17,65 +17,55 @@
17
17
  "keywords": [
18
18
  "tailwind",
19
19
  "tailwindcss",
20
+ "tailwindcss-v4",
20
21
  "tailwindcss-plugin",
21
- "tailwindcss-grid-background",
22
- "tailwindcss-dot-background",
22
+ "css",
23
23
  "grid-background",
24
- "dot-background"
24
+ "dot-background",
25
+ "background-pattern"
25
26
  ],
26
- "version": "1.2.14",
27
+ "version": "2.0.1",
27
28
  "type": "module",
28
- "main": "./dist/tailwind-dot-grid-backgrounds.umd.cjs",
29
- "module": "./dist/tailwind-dot-grid-backgrounds.js",
30
- "types": "./dist/index.d.ts",
31
- "engines": {
32
- "node": ">=22.0.0"
33
- },
29
+ "style": "./index.css",
34
30
  "exports": {
35
31
  ".": {
36
- "import": {
37
- "types": "./dist/index.d.ts",
38
- "default": "./dist/tailwind-dot-grid-backgrounds.js"
39
- },
40
- "require": {
41
- "types": "./dist/index.d.ts",
42
- "default": "./dist/tailwind-dot-grid-backgrounds.umd.cjs"
43
- }
44
- }
32
+ "style": "./index.css",
33
+ "default": "./index.css"
34
+ },
35
+ "./index.css": "./index.css",
36
+ "./package.json": "./package.json"
45
37
  },
46
38
  "files": [
47
- "dist"
39
+ "index.css"
40
+ ],
41
+ "sideEffects": [
42
+ "*.css"
48
43
  ],
49
44
  "scripts": {
50
- "build": "tsc --noEmit && vite build && tsc -p tsconfig.build.json",
51
45
  "test": "vitest",
52
46
  "test:run": "vitest run",
53
- "test:coverage": "vitest run --coverage",
47
+ "typecheck": "tsc --noEmit",
54
48
  "lint": "biome check",
55
49
  "lint:fix": "biome check --write",
56
- "prepare": "husky",
57
- "typecheck": "tsc --noEmit"
50
+ "prepare": "husky"
58
51
  },
59
52
  "devDependencies": {
60
- "@biomejs/biome": "2.5.14",
61
- "@commitlint/cli": "21.2.3",
62
- "@commitlint/config-conventional": "21.2.3",
53
+ "@biomejs/biome": "2.5.15",
54
+ "@commitlint/cli": "21.2.4",
55
+ "@commitlint/config-conventional": "21.2.4",
63
56
  "@semantic-release/changelog": "6.0.3",
64
57
  "@semantic-release/git": "10.0.1",
65
- "@types/node": "24.19.0",
66
- "@vitest/coverage-v8": "5.0.2",
58
+ "@tailwindcss/node": "4.3.3",
59
+ "@types/node": "24.19.2",
67
60
  "husky": "9.1.7",
68
- "postcss": "8.5.28",
69
61
  "semantic-release": "25.0.9",
70
- "tailwindcss": "3.4.19",
62
+ "tailwindcss": "4.3.3",
71
63
  "typescript": "7.0.2",
72
- "vite": "8.3.1",
73
- "vitest": "5.0.2"
64
+ "vitest": "5.0.5"
74
65
  },
75
66
  "peerDependencies": {
76
- "tailwindcss": "^3.4.0"
67
+ "tailwindcss": "^4.0.0"
77
68
  },
78
- "sideEffects": false,
79
69
  "devEngines": {
80
70
  "runtime": {
81
71
  "name": "node",
package/dist/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export { default } from "./plugin.js";
package/dist/plugin.d.ts DELETED
@@ -1,5 +0,0 @@
1
- declare const tailwindDotGridBackgrounds: {
2
- handler: import("tailwindcss/types/config.js").PluginCreator;
3
- config?: Partial<import("tailwindcss/types/config.js").Config>;
4
- };
5
- export default tailwindDotGridBackgrounds;
@@ -1,57 +0,0 @@
1
- import e from "tailwindcss/plugin.js";
2
- //#region src/theme-values.ts
3
- var t = 16, n = /* @__PURE__ */ new Set(["inherit"]);
4
- function r(e) {
5
- if (typeof e != "string") return null;
6
- let n = /^(-?\d*\.?\d+)(px|rem)$/.exec(e.trim());
7
- if (!n) return null;
8
- let r = Number.parseFloat(n[1]);
9
- return n[2] === "rem" ? r * t : r;
10
- }
11
- function i(e) {
12
- return Object.entries(e ?? {}).flatMap(([e, t]) => {
13
- let n = r(t);
14
- return n === null ? [] : [[e, n]];
15
- });
16
- }
17
- function a(e, t) {
18
- return Object.entries(e).flatMap(([e, r]) => {
19
- let i = e === "DEFAULT" ? t : t ? `${t}-${e}` : e;
20
- return typeof r == "object" && r ? a(r, i) : n.has(i) ? [] : [[i, r]];
21
- });
22
- }
23
- function o(e) {
24
- return Object.fromEntries(a(e ?? {}, ""));
25
- }
26
- function s(e) {
27
- let t = i(e).filter(([e]) => e !== "DEFAULT");
28
- return t.some(([e]) => e === "1") ? t : [["1", 1], ...t];
29
- }
30
- //#endregion
31
- //#region src/plugin.ts
32
- function c(e, t) {
33
- return (n) => ({
34
- backgroundImage: `linear-gradient(to right, ${n} ${t}px, transparent ${t}px),linear-gradient(to bottom, ${n} ${t}px, transparent ${t}px)`,
35
- backgroundSize: `${e}px ${e}px`
36
- });
37
- }
38
- function l(e, t) {
39
- return (n) => ({
40
- backgroundImage: `radial-gradient(${n} ${t}px, transparent ${t}px)`,
41
- backgroundSize: `${e}px ${e}px`
42
- });
43
- }
44
- var u = e(({ matchUtilities: e, theme: t }) => {
45
- let n = o(t("backgroundColor")), r = s(t("borderWidth")), a = i(t("width")), u = n;
46
- for (let [t, n] of r) for (let [r, i] of a) e({
47
- [`bg-grid-${r}-s-${t}`]: c(i, n),
48
- [`bg-dot-${r}-s-${t}`]: l(i, n)
49
- }, {
50
- values: u,
51
- type: "color"
52
- });
53
- });
54
- //#endregion
55
- export { u as default };
56
-
57
- //# sourceMappingURL=tailwind-dot-grid-backgrounds.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tailwind-dot-grid-backgrounds.js","names":["plugin","REM_TO_PX","UNSUPPORTED_COLORS","toPx","value","match","amount","toPxEntries","section","key","px","colorEntries","palette","name","prefix","flattenColors","strokeWidths","entries","borderWidth","gridBackground","color","stroke","size","dotBackground","dotSize","tailwindDotGridBackgrounds","colors","theme","strokes","sizes","values","strokeKey","sizeKey"],"sources":["../src/theme-values.ts","../src/plugin.ts"],"sourcesContent":["const REM_TO_PX = 16; // 1rem = 16px\n\n// Colors that cannot be used inside a gradient color stop.\nconst UNSUPPORTED_COLORS = new Set([\"inherit\"]);\n\ntype ColorValue = string | ((...args: never[]) => string);\ntype ColorPalette = { [key: string]: ColorValue | ColorPalette };\n\n// Convert a \"px\" or \"rem\" length to a number of pixels. Other values (percentages, keywords, other units...) return null.\nexport function toPx(value: unknown): number | null {\n\tif (typeof value !== \"string\") return null;\n\n\tconst match = /^(-?\\d*\\.?\\d+)(px|rem)$/.exec(value.trim());\n\tif (!match) return null;\n\n\tconst amount = Number.parseFloat(match[1] as string);\n\treturn match[2] === \"rem\" ? amount * REM_TO_PX : amount;\n}\n\n// Turn a theme section into [key, px] pairs, keeping only the values expressed in \"px\" or \"rem\".\nexport function toPxEntries(\n\tsection: Record<string, unknown> | undefined,\n): Array<[string, number]> {\n\treturn Object.entries(section ?? {}).flatMap(([key, value]) => {\n\t\tconst px = toPx(value);\n\t\treturn px === null ? [] : [[key, px] as [string, number]];\n\t});\n}\n\n// Flatten a nested color palette into [name, color] pairs (\"DEFAULT\" maps to the parent name), like Tailwind does.\nfunction colorEntries(\n\tpalette: ColorPalette,\n\tprefix: string,\n): Array<[string, ColorValue]> {\n\treturn Object.entries(palette).flatMap(([key, value]) => {\n\t\tconst name = key === \"DEFAULT\" ? prefix : prefix ? `${prefix}-${key}` : key;\n\n\t\tif (typeof value === \"object\" && value !== null) {\n\t\t\treturn colorEntries(value, name);\n\t\t}\n\n\t\treturn UNSUPPORTED_COLORS.has(name)\n\t\t\t? []\n\t\t\t: [[name, value] as [string, ColorValue]];\n\t});\n}\n\nexport function flattenColors(\n\tpalette: ColorPalette | undefined,\n): Record<string, ColorValue> {\n\treturn Object.fromEntries(colorEntries(palette ?? {}, \"\"));\n}\n\n// The stroke widths: every border width expressed in px or rem, except \"DEFAULT\" (it would create \"-s-DEFAULT-\" classes). \"1\" is always available since Tailwind has no \"border-1\".\nexport function strokeWidths(\n\tborderWidth: Record<string, unknown> | undefined,\n): Array<[string, number]> {\n\tconst entries = toPxEntries(borderWidth).filter(([key]) => key !== \"DEFAULT\");\n\treturn entries.some(([key]) => key === \"1\")\n\t\t? entries\n\t\t: [[\"1\", 1], ...entries];\n}\n","// The \".js\" extension is required: Tailwind CSS v3 has no \"exports\" map, so Node ESM needs the full file name.\nimport plugin from \"tailwindcss/plugin.js\";\nimport type { CSSRuleObject, PluginAPI } from \"tailwindcss/types/config.js\";\nimport { flattenColors, strokeWidths, toPxEntries } from \"./theme-values.js\";\n\ntype UtilityFactory = (color: string) => CSSRuleObject;\n\nfunction gridBackground(size: number, stroke: number): UtilityFactory {\n\treturn (color) => ({\n\t\tbackgroundImage: `linear-gradient(to right, ${color} ${stroke}px, transparent ${stroke}px),linear-gradient(to bottom, ${color} ${stroke}px, transparent ${stroke}px)`,\n\t\tbackgroundSize: `${size}px ${size}px`,\n\t});\n}\n\nfunction dotBackground(size: number, dotSize: number): UtilityFactory {\n\treturn (color) => ({\n\t\tbackgroundImage: `radial-gradient(${color} ${dotSize}px, transparent ${dotSize}px)`,\n\t\tbackgroundSize: `${size}px ${size}px`,\n\t});\n}\n\nconst tailwindDotGridBackgrounds = plugin(\n\t({ matchUtilities, theme }: PluginAPI) => {\n\t\t// Colors come from the \"backgroundColor\" theme (it includes \"colors\").\n\t\tconst colors = flattenColors(theme(\"backgroundColor\"));\n\n\t\t// Stroke widths (grid) and dot sizes come from the \"borderWidth\" theme, plus \"1\".\n\t\tconst strokes = strokeWidths(theme(\"borderWidth\"));\n\n\t\t// Grid square sizes and dot spacings come from the \"width\" theme values expressed in px or rem.\n\t\tconst sizes = toPxEntries(theme(\"width\"));\n\n\t\t// Tailwind types color values as strings, but a palette may also contain functions: both are handled by matchUtilities.\n\t\tconst values = colors as Record<string, string>;\n\n\t\tfor (const [strokeKey, stroke] of strokes) {\n\t\t\tfor (const [sizeKey, size] of sizes) {\n\t\t\t\tmatchUtilities(\n\t\t\t\t\t{\n\t\t\t\t\t\t[`bg-grid-${sizeKey}-s-${strokeKey}`]: gridBackground(size, stroke),\n\t\t\t\t\t\t[`bg-dot-${sizeKey}-s-${strokeKey}`]: dotBackground(size, stroke),\n\t\t\t\t\t},\n\t\t\t\t\t{ values, type: \"color\" },\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t},\n);\n\nexport default tailwindDotGridBackgrounds;\n"],"mappings":";;AAAA,IAAMC,IAAY,IAGZC,oBAAqB,IAAI,IAAI,CAAC,SAAS,CAAC;AAM9C,SAAgBC,EAAK,GAA+B;CACnD,IAAI,OAAOC,KAAU,UAAU,OAAO;CAEtC,IAAMC,IAAQ,0BAA0B,KAAKD,EAAM,KAAK,CAAC;CACzD,IAAI,CAACC,GAAO,OAAO;CAEnB,IAAMC,IAAS,OAAO,WAAWD,EAAM,EAAY;CACnD,OAAOA,EAAM,OAAO,QAAQC,IAASL,IAAYK;AAClD;AAGA,SAAgBC,EACf,GAC0B;CAC1B,OAAO,OAAO,QAAQC,KAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAACC,GAAKL,OAAW;EAC9D,IAAMM,IAAKP,EAAKC,CAAK;EACrB,OAAOM,MAAO,OAAO,CAAC,IAAI,CAAC,CAACD,GAAKC,CAAE,CAAqB;CACzD,CAAC;AACF;AAGA,SAASC,EACR,GACA,GAC8B;CAC9B,OAAO,OAAO,QAAQC,CAAO,CAAC,CAAC,SAAS,CAACH,GAAKL,OAAW;EACxD,IAAMS,IAAOJ,MAAQ,YAAYK,IAASA,IAAS,GAAGA,EAAO,GAAGL,MAAQA;EAMxE,OAJI,OAAOL,KAAU,YAAYA,IACzBO,EAAaP,GAAOS,CAAI,IAGzBX,EAAmB,IAAIW,CAAI,IAC/B,CAAC,IACD,CAAC,CAACA,GAAMT,CAAK,CAAyB;CAC1C,CAAC;AACF;AAEA,SAAgBW,EACf,GAC6B;CAC7B,OAAO,OAAO,YAAYJ,EAAaC,KAAW,CAAC,GAAG,EAAE,CAAC;AAC1D;AAGA,SAAgBI,EACf,GAC0B;CAC1B,IAAMC,IAAUV,EAAYW,CAAW,CAAC,CAAC,QAAQ,CAACT,OAASA,MAAQ,SAAS;CAC5E,OAAOQ,EAAQ,MAAM,CAACR,OAASA,MAAQ,GAAG,IACvCQ,IACA,CAAC,CAAC,KAAK,CAAC,GAAG,GAAGA,CAAO;AACzB;;;ACtDA,SAASE,EAAe,GAAc,GAAgC;CACrE,QAAQ,OAAW;EAClB,iBAAiB,6BAA6BC,EAAM,GAAGC,EAAO,kBAAkBA,EAAO,iCAAiCD,EAAM,GAAGC,EAAO,kBAAkBA,EAAO;EACjK,gBAAgB,GAAGC,EAAK,KAAKA,EAAK;CACnC;AACD;AAEA,SAASC,EAAc,GAAc,GAAiC;CACrE,QAAQ,OAAW;EAClB,iBAAiB,mBAAmBH,EAAM,GAAGI,EAAQ,kBAAkBA,EAAQ;EAC/E,gBAAgB,GAAGF,EAAK,KAAKA,EAAK;CACnC;AACD;AAEA,IAAMG,IAA6BzB,GACjC,EAAE,mBAAgB,eAAuB;CAEzC,IAAM0B,IAASX,EAAcY,EAAM,iBAAiB,CAAC,GAG/CC,IAAUZ,EAAaW,EAAM,aAAa,CAAC,GAG3CE,IAAQtB,EAAYoB,EAAM,OAAO,CAAC,GAGlCG,IAASJ;CAEf,KAAK,IAAM,CAACK,GAAWV,MAAWO,GACjC,KAAK,IAAM,CAACI,GAASV,MAASO,GAC7B,EACC;GACE,WAAWG,EAAQ,KAAKD,MAAcZ,EAAeG,GAAMD,CAAM;GACjE,UAAUW,EAAQ,KAAKD,MAAcR,EAAcD,GAAMD,CAAM;CACjE,GACA;EAAE;EAAQ,MAAM;CAAQ,CACzB;AAGH,CACD"}
@@ -1,2 +0,0 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?module.exports=t(require("tailwindcss/plugin.js")):typeof define==`function`&&define.amd?define([`tailwindcss/plugin.js`],t):(e=typeof globalThis<`u`?globalThis:e||self,e.tailwindDotGridBackgrounds=t(e.tailwindcss.plugin))})(this,function(e){var t=Object.create,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,s=(e,t,a,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=i(t),l=0,u=c.length,d;l<u;l++)d=c[l],!o.call(e,d)&&d!==a&&n(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(s=r(t,d))||s.enumerable});return e};e=((e,r,i)=>(i=e==null?{}:t(a(e)),s(r||!e||!e.__esModule||!o.call(e,`default`)?n(i,`default`,{value:e,enumerable:!0}):i,e)))(e,1);var c=16,l=new Set([`inherit`]);function u(e){if(typeof e!=`string`)return null;let t=/^(-?\d*\.?\d+)(px|rem)$/.exec(e.trim());if(!t)return null;let n=Number.parseFloat(t[1]);return t[2]===`rem`?n*c:n}function d(e){return Object.entries(e??{}).flatMap(([e,t])=>{let n=u(t);return n===null?[]:[[e,n]]})}function f(e,t){return Object.entries(e).flatMap(([e,n])=>{let r=e===`DEFAULT`?t:t?`${t}-${e}`:e;return typeof n==`object`&&n?f(n,r):l.has(r)?[]:[[r,n]]})}function p(e){return Object.fromEntries(f(e??{},``))}function m(e){let t=d(e).filter(([e])=>e!==`DEFAULT`);return t.some(([e])=>e===`1`)?t:[[`1`,1],...t]}function h(e,t){return n=>({backgroundImage:`linear-gradient(to right, ${n} ${t}px, transparent ${t}px),linear-gradient(to bottom, ${n} ${t}px, transparent ${t}px)`,backgroundSize:`${e}px ${e}px`})}function g(e,t){return n=>({backgroundImage:`radial-gradient(${n} ${t}px, transparent ${t}px)`,backgroundSize:`${e}px ${e}px`})}return(0,e.default)(({matchUtilities:e,theme:t})=>{let n=p(t(`backgroundColor`)),r=m(t(`borderWidth`)),i=d(t(`width`)),a=n;for(let[t,n]of r)for(let[r,o]of i)e({[`bg-grid-${r}-s-${t}`]:h(o,n),[`bg-dot-${r}-s-${t}`]:g(o,n)},{values:a,type:`color`})})});
2
- //# sourceMappingURL=tailwind-dot-grid-backgrounds.umd.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tailwind-dot-grid-backgrounds.umd.cjs","names":["plugin","factory","global","__create","__defProp","__getOwnPropDesc","__getOwnPropNames","__getProtoOf","__hasOwnProp","__copyProps","from","keys","i","n","key","to","except","k","desc","mod","isNodeMode","target","tailwindcss_plugin_js","REM_TO_PX","UNSUPPORTED_COLORS","toPx","value","match","amount","toPxEntries","section","px","colorEntries","palette","name","prefix","flattenColors","strokeWidths","entries","borderWidth","gridBackground","color","stroke","size","dotBackground","dotSize","colors","theme","strokes","sizes","values","strokeKey","sizeKey","matchUtilities"],"sources":["../src/theme-values.ts","../src/plugin.ts"],"sourcesContent":["const REM_TO_PX = 16; // 1rem = 16px\n\n// Colors that cannot be used inside a gradient color stop.\nconst UNSUPPORTED_COLORS = new Set([\"inherit\"]);\n\ntype ColorValue = string | ((...args: never[]) => string);\ntype ColorPalette = { [key: string]: ColorValue | ColorPalette };\n\n// Convert a \"px\" or \"rem\" length to a number of pixels. Other values (percentages, keywords, other units...) return null.\nexport function toPx(value: unknown): number | null {\n\tif (typeof value !== \"string\") return null;\n\n\tconst match = /^(-?\\d*\\.?\\d+)(px|rem)$/.exec(value.trim());\n\tif (!match) return null;\n\n\tconst amount = Number.parseFloat(match[1] as string);\n\treturn match[2] === \"rem\" ? amount * REM_TO_PX : amount;\n}\n\n// Turn a theme section into [key, px] pairs, keeping only the values expressed in \"px\" or \"rem\".\nexport function toPxEntries(\n\tsection: Record<string, unknown> | undefined,\n): Array<[string, number]> {\n\treturn Object.entries(section ?? {}).flatMap(([key, value]) => {\n\t\tconst px = toPx(value);\n\t\treturn px === null ? [] : [[key, px] as [string, number]];\n\t});\n}\n\n// Flatten a nested color palette into [name, color] pairs (\"DEFAULT\" maps to the parent name), like Tailwind does.\nfunction colorEntries(\n\tpalette: ColorPalette,\n\tprefix: string,\n): Array<[string, ColorValue]> {\n\treturn Object.entries(palette).flatMap(([key, value]) => {\n\t\tconst name = key === \"DEFAULT\" ? prefix : prefix ? `${prefix}-${key}` : key;\n\n\t\tif (typeof value === \"object\" && value !== null) {\n\t\t\treturn colorEntries(value, name);\n\t\t}\n\n\t\treturn UNSUPPORTED_COLORS.has(name)\n\t\t\t? []\n\t\t\t: [[name, value] as [string, ColorValue]];\n\t});\n}\n\nexport function flattenColors(\n\tpalette: ColorPalette | undefined,\n): Record<string, ColorValue> {\n\treturn Object.fromEntries(colorEntries(palette ?? {}, \"\"));\n}\n\n// The stroke widths: every border width expressed in px or rem, except \"DEFAULT\" (it would create \"-s-DEFAULT-\" classes). \"1\" is always available since Tailwind has no \"border-1\".\nexport function strokeWidths(\n\tborderWidth: Record<string, unknown> | undefined,\n): Array<[string, number]> {\n\tconst entries = toPxEntries(borderWidth).filter(([key]) => key !== \"DEFAULT\");\n\treturn entries.some(([key]) => key === \"1\")\n\t\t? entries\n\t\t: [[\"1\", 1], ...entries];\n}\n","// The \".js\" extension is required: Tailwind CSS v3 has no \"exports\" map, so Node ESM needs the full file name.\nimport plugin from \"tailwindcss/plugin.js\";\nimport type { CSSRuleObject, PluginAPI } from \"tailwindcss/types/config.js\";\nimport { flattenColors, strokeWidths, toPxEntries } from \"./theme-values.js\";\n\ntype UtilityFactory = (color: string) => CSSRuleObject;\n\nfunction gridBackground(size: number, stroke: number): UtilityFactory {\n\treturn (color) => ({\n\t\tbackgroundImage: `linear-gradient(to right, ${color} ${stroke}px, transparent ${stroke}px),linear-gradient(to bottom, ${color} ${stroke}px, transparent ${stroke}px)`,\n\t\tbackgroundSize: `${size}px ${size}px`,\n\t});\n}\n\nfunction dotBackground(size: number, dotSize: number): UtilityFactory {\n\treturn (color) => ({\n\t\tbackgroundImage: `radial-gradient(${color} ${dotSize}px, transparent ${dotSize}px)`,\n\t\tbackgroundSize: `${size}px ${size}px`,\n\t});\n}\n\nconst tailwindDotGridBackgrounds = plugin(\n\t({ matchUtilities, theme }: PluginAPI) => {\n\t\t// Colors come from the \"backgroundColor\" theme (it includes \"colors\").\n\t\tconst colors = flattenColors(theme(\"backgroundColor\"));\n\n\t\t// Stroke widths (grid) and dot sizes come from the \"borderWidth\" theme, plus \"1\".\n\t\tconst strokes = strokeWidths(theme(\"borderWidth\"));\n\n\t\t// Grid square sizes and dot spacings come from the \"width\" theme values expressed in px or rem.\n\t\tconst sizes = toPxEntries(theme(\"width\"));\n\n\t\t// Tailwind types color values as strings, but a palette may also contain functions: both are handled by matchUtilities.\n\t\tconst values = colors as Record<string, string>;\n\n\t\tfor (const [strokeKey, stroke] of strokes) {\n\t\t\tfor (const [sizeKey, size] of sizes) {\n\t\t\t\tmatchUtilities(\n\t\t\t\t\t{\n\t\t\t\t\t\t[`bg-grid-${sizeKey}-s-${strokeKey}`]: gridBackground(size, stroke),\n\t\t\t\t\t\t[`bg-dot-${sizeKey}-s-${strokeKey}`]: dotBackground(size, stroke),\n\t\t\t\t\t},\n\t\t\t\t\t{ values, type: \"color\" },\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t},\n);\n\nexport default tailwindDotGridBackgrounds;\n"],"mappings":"wyBAAA,IAAMuB,EAAY,GAGZC,EAAqB,IAAI,IAAI,CAAC,SAAS,CAAC,EAM9C,SAAgBC,EAAK,EAA+B,CACnD,GAAI,OAAOC,GAAU,SAAU,OAAO,KAEtC,IAAMC,EAAQ,0BAA0B,KAAKD,EAAM,KAAK,CAAC,EACzD,GAAI,CAACC,EAAO,OAAO,KAEnB,IAAMC,EAAS,OAAO,WAAWD,EAAM,EAAY,EACnD,OAAOA,EAAM,KAAO,MAAQC,EAASL,EAAYK,CAClD,CAGA,SAAgBC,EACf,EAC0B,CAC1B,OAAO,OAAO,QAAQC,GAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAChB,EAAKY,KAAW,CAC9D,IAAMK,EAAKN,EAAKC,CAAK,EACrB,OAAOK,IAAO,KAAO,CAAC,EAAI,CAAC,CAACjB,EAAKiB,CAAE,CAAqB,CACzD,CAAC,CACF,CAGA,SAASC,EACR,EACA,EAC8B,CAC9B,OAAO,OAAO,QAAQC,CAAO,CAAC,CAAC,SAAS,CAACnB,EAAKY,KAAW,CACxD,IAAMQ,EAAOpB,IAAQ,UAAYqB,EAASA,EAAS,GAAGA,EAAO,GAAGrB,IAAQA,EAMxE,OAJI,OAAOY,GAAU,UAAYA,EACzBM,EAAaN,EAAOQ,CAAI,EAGzBV,EAAmB,IAAIU,CAAI,EAC/B,CAAC,EACD,CAAC,CAACA,EAAMR,CAAK,CAAyB,CAC1C,CAAC,CACF,CAEA,SAAgBU,EACf,EAC6B,CAC7B,OAAO,OAAO,YAAYJ,EAAaC,GAAW,CAAC,EAAG,EAAE,CAAC,CAC1D,CAGA,SAAgBI,EACf,EAC0B,CAC1B,IAAMC,EAAUT,EAAYU,CAAW,CAAC,CAAC,QAAQ,CAACzB,KAASA,IAAQ,SAAS,EAC5E,OAAOwB,EAAQ,MAAM,CAACxB,KAASA,IAAQ,GAAG,EACvCwB,EACA,CAAC,CAAC,IAAK,CAAC,EAAG,GAAGA,CAAO,CACzB,CCtDA,SAASE,EAAe,EAAc,EAAgC,CACrE,MAAQ,KAAW,CAClB,gBAAiB,6BAA6BC,EAAM,GAAGC,EAAO,kBAAkBA,EAAO,iCAAiCD,EAAM,GAAGC,EAAO,kBAAkBA,EAAO,KACjK,eAAgB,GAAGC,EAAK,KAAKA,EAAK,GACnC,EACD,CAEA,SAASC,EAAc,EAAc,EAAiC,CACrE,MAAQ,KAAW,CAClB,gBAAiB,mBAAmBH,EAAM,GAAGI,EAAQ,kBAAkBA,EAAQ,KAC/E,eAAgB,GAAGF,EAAK,KAAKA,EAAK,GACnC,EACD,QAEM,EAA6B3C,EAAAA,QAAAA,EACjC,CAAE,iBAAgB,WAAuB,CAEzC,IAAM8C,EAASV,EAAcW,EAAM,iBAAiB,CAAC,EAG/CC,EAAUX,EAAaU,EAAM,aAAa,CAAC,EAG3CE,EAAQpB,EAAYkB,EAAM,OAAO,CAAC,EAGlCG,EAASJ,EAEf,IAAK,GAAM,CAACK,EAAWT,KAAWM,EACjC,IAAK,GAAM,CAACI,EAAST,KAASM,EAC7BI,EACC,EACE,WAAWD,EAAQ,KAAKD,KAAcX,EAAeG,EAAMD,CAAM,GACjE,UAAUU,EAAQ,KAAKD,KAAcP,EAAcD,EAAMD,CAAM,CACjE,EACA,CAAE,SAAQ,KAAM,OAAQ,CACzB,CAGH"}
@@ -1,9 +0,0 @@
1
- type ColorValue = string | ((...args: never[]) => string);
2
- type ColorPalette = {
3
- [key: string]: ColorValue | ColorPalette;
4
- };
5
- export declare function toPx(value: unknown): number | null;
6
- export declare function toPxEntries(section: Record<string, unknown> | undefined): Array<[string, number]>;
7
- export declare function flattenColors(palette: ColorPalette | undefined): Record<string, ColorValue>;
8
- export declare function strokeWidths(borderWidth: Record<string, unknown> | undefined): Array<[string, number]>;
9
- export {};