@nauverse/tailwind-dot-grid-backgrounds 1.2.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) 2024 Albert Adler | Naucode
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,167 @@
1
+ <h1 align="center">
2
+ <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
3
+ [![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-)
4
+ <!-- ALL-CONTRIBUTORS-BADGE:END -->
5
+ 🎨 tailwind-dot-grid-backgrounds
6
+ <br>
7
+ </h1>
8
+
9
+ <h4 align="center">A tiny Tailwind plugin to add dot and grid customizable backgrounds fast</h4>
10
+
11
+ <p align="center">
12
+ <a href="https://github.com/TheNaubit/tailwind-dot-grid-backgrounds/actions">
13
+ <img src="https://github.com/TheNaubit/tailwind-dot-grid-backgrounds/actions/workflows/release.yml/badge.svg"
14
+ alt="Build Status">
15
+ </a>
16
+ <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.svg?style=flat" alt="npm version">
18
+ </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">
21
+ </a>
22
+ </p>
23
+
24
+ <p align="center">
25
+ <a href="#what">What?</a> •
26
+ <a href="#guide-and-examples">Guide and examples</a> •
27
+ <a href="#help">Help</a> •
28
+ <a href="#contribute">Contribute</a>
29
+ </p>
30
+
31
+ ## tl;dr
32
+ This is a Tailwind plugin that allows you to add background grids and background dots in an easy and customizable way:
33
+
34
+ ### 1. Installing the dependency:
35
+ ```bash
36
+ npm install --save @nauverse/tailwind-dot-grid-backgrounds
37
+ ```
38
+
39
+ ### 2. Add the plugin to the `tailwind.config.js` file:
40
+ ~~~js
41
+ // ... the rest of your tailwind.config.js file
42
+
43
+ const config: Config = {
44
+ // ... the rest of your config
45
+ plugins: [
46
+ require('@nauverse/tailwind-dot-grid-backgrounds')
47
+ // ... the rest of your Tailwind plugins
48
+ ],
49
+ };
50
+ ~~~
51
+
52
+ ### 3. You are done! 🪄
53
+ Try it by adding this HTML to your UI:
54
+ ```html
55
+ <div class="h-screen w-screen bg-yellow-300 bg-grid-8-s-2-neutral-950"></div>
56
+ ```
57
+
58
+ ## What
59
+ You could achieve the same by just using some Tailwind code but... I found myself adding this kind of background in my projects very often. So I created a small Tailwind plugin to allow me adding these background but at the same allowing all the customization offered by Tailwind.
60
+
61
+ ## Guide and examples
62
+
63
+ ### Background Grid
64
+ Pattern: `bg-grid-<SIZE>-s-<STROKE_WIDTH>-<COLOR>`
65
+
66
+ - `<SIZE>` is the size of the grid squares. It allows the numeric values of the `width` prop in Tailwind. You will see the available options in Intellisense.
67
+ - `<STROKE_WIDTH>` is the width of the strokes of the grid squares. It allows the numeric values of the `borderWidth` prop in Tailwind and also the value `1` (since Tailwind does not have a `border-1` class).
68
+ - `<COLOR>` is the color of the strokes. It allows any valid classname color in Tailwind.
69
+
70
+ #### Examples:
71
+ `bg-grid-8-s-2-neutral-950`
72
+
73
+ `bg-grid-48-s-8-blue-700/80`
74
+
75
+ ### Background Dots
76
+ Pattern: `bg-dot-<SIZE>-s-<DOT_SIZE>-<COLOR>`
77
+
78
+ - `<SIZE>` is the size of the space (in both axis) between the dots. It allows the numeric values of the `width` prop in Tailwind. You will see the available options in Intellisense.
79
+ - `<DOT_SIZE>` is the size of the dots. It allows the numeric values of the `borderWidth` prop in Tailwind and also the value `1` (since Tailwind does not have a `border-1` class).
80
+ - `<COLOR>` is the color of the dots. It allows any valid classname color in Tailwind.
81
+
82
+ #### Examples:
83
+ `bg-dot-8-s-2-neutral-950`
84
+
85
+ `bg-dot-48-s-8-blue-700/80`
86
+
87
+ ## Help
88
+
89
+ Thank you for using *tailwind-dot-grid-backgrounds*!
90
+
91
+ If you need any help using this plugin, feel free to [create a GitHub issue](https://github.com/TheNaubit/tailwind-dot-grid-backgrounds/issues/new/choose), and ask your questions. I'll try to answer as quickly as possible.
92
+
93
+ ## Contribute
94
+
95
+ Contributions of any kind (pull requests, bug reports, feature requests, documentation, design) are more than welcome! If you like this project and want to help, but feel like you are stuck, feel free to contact the maintainers.
96
+
97
+ ### Building from source
98
+
99
+ Building the project should be quick and easy. If it isn't, it's the maintainer's fault. Please report any problems with building in a GitHub issue.
100
+
101
+ You need to have a reasonably recent version of node.js to build *tailwind-dot-grid-backgrounds*.
102
+ Tested on node version 18.0.0 and npm version 8.6.0.
103
+
104
+ First, clone the git repository:
105
+
106
+ ```
107
+ git clone git@github.com:TheNaubit/tailwind-dot-grid-backgrounds.git
108
+ ```
109
+
110
+ Then switch to the newly created tailwind-dot-grid-backgrounds directory and install the dependencies:
111
+
112
+ ```
113
+ cd tailwind-dot-grid-backgrounds
114
+ npm install
115
+ ```
116
+
117
+ You can then run the unit tests to verify that everything works correctly:
118
+
119
+ ```
120
+ npm run test:run
121
+ ```
122
+
123
+ And finally, build the library:
124
+
125
+ ```
126
+ npm run build
127
+ ```
128
+
129
+ The output will appear in the `dist` directory.
130
+
131
+ Happy hacking!
132
+
133
+ ## Contributors ✨
134
+
135
+ <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
136
+ <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
137
+ <!-- prettier-ignore-start -->
138
+ <!-- markdownlint-disable -->
139
+ <table>
140
+ <tbody>
141
+ <tr>
142
+ <td align="center" valign="top" width="14.28%"><a href="https://albertadler.com"><img src="https://avatars.githubusercontent.com/u/22015497?v=4?s=100" width="100px;" alt="Al &#124; Naucode"/><br /><sub><b>Al &#124; Naucode</b></sub></a><br /><a href="https://github.com/TheNaubit/tailwind-dot-grid-backgrounds/issues?q=author%3ATheNaubit" title="Bug reports">🐛</a> <a href="https://github.com/TheNaubit/tailwind-dot-grid-backgrounds/commits?author=TheNaubit" title="Code">💻</a> <a href="https://github.com/TheNaubit/tailwind-dot-grid-backgrounds/commits?author=TheNaubit" title="Documentation">📖</a> <a href="#maintenance-TheNaubit" title="Maintenance">🚧</a> <a href="#infra-TheNaubit" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="https://github.com/TheNaubit/tailwind-dot-grid-backgrounds/commits?author=TheNaubit" title="Tests">⚠️</a></td>
143
+ </tr>
144
+ </tbody>
145
+ </table>
146
+
147
+ <!-- markdownlint-restore -->
148
+ <!-- prettier-ignore-end -->
149
+
150
+ <!-- ALL-CONTRIBUTORS-LIST:END -->
151
+ [![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-)
152
+ <!-- ALL-CONTRIBUTORS-BADGE:END -->
153
+
154
+ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
155
+
156
+ ## Contributors
157
+
158
+ <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
159
+ <!-- prettier-ignore-start -->
160
+ <!-- markdownlint-disable -->
161
+
162
+ <!-- markdownlint-restore -->
163
+ <!-- prettier-ignore-end -->
164
+
165
+ <!-- ALL-CONTRIBUTORS-LIST:END -->
166
+
167
+ This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
@@ -0,0 +1,10 @@
1
+ import { Config } from 'tailwindcss/types/config';
2
+ import { PluginCreator } from 'tailwindcss/types/config';
3
+
4
+ declare const tailwindDotGridBackgrounds: {
5
+ handler: PluginCreator;
6
+ config?: Partial<Config> | undefined;
7
+ };
8
+ export default tailwindDotGridBackgrounds;
9
+
10
+ export { }
@@ -0,0 +1,101 @@
1
+ function f(t) {
2
+ return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
3
+ }
4
+ var s = {}, p = {};
5
+ (function(t) {
6
+ Object.defineProperty(t, "__esModule", {
7
+ value: !0
8
+ }), Object.defineProperty(t, "default", {
9
+ enumerable: !0,
10
+ get: function() {
11
+ return o;
12
+ }
13
+ });
14
+ function a(r, n) {
15
+ return {
16
+ handler: r,
17
+ config: n
18
+ };
19
+ }
20
+ a.withOptions = function(r, n = () => ({})) {
21
+ const e = function(u) {
22
+ return {
23
+ __options: u,
24
+ handler: r(u),
25
+ config: n(u)
26
+ };
27
+ };
28
+ return e.__isOptionsFunction = !0, e.__pluginFunction = r, e.__configFunction = n, e;
29
+ };
30
+ const o = a;
31
+ })(p);
32
+ (function(t) {
33
+ Object.defineProperty(t, "__esModule", {
34
+ value: !0
35
+ }), Object.defineProperty(t, "default", {
36
+ enumerable: !0,
37
+ get: function() {
38
+ return r;
39
+ }
40
+ });
41
+ const a = /* @__PURE__ */ o(p);
42
+ function o(n) {
43
+ return n && n.__esModule ? n : {
44
+ default: n
45
+ };
46
+ }
47
+ const r = a.default;
48
+ })(s);
49
+ let i = s;
50
+ var _ = (i.__esModule ? i : { default: i }).default;
51
+ const g = /* @__PURE__ */ f(_);
52
+ var d = {};
53
+ (function(t) {
54
+ Object.defineProperty(t, "__esModule", {
55
+ value: !0
56
+ }), Object.defineProperty(t, "default", {
57
+ enumerable: !0,
58
+ get: function() {
59
+ return o;
60
+ }
61
+ });
62
+ const a = (r) => Object.assign({}, ...Object.entries(r ?? {}).flatMap(([n, e]) => typeof e == "object" ? Object.entries(a(e)).map(([u, c]) => ({
63
+ [n + (u === "DEFAULT" ? "" : `-${u}`)]: c
64
+ })) : [
65
+ {
66
+ [`${n}`]: e
67
+ }
68
+ ])), o = a;
69
+ })(d);
70
+ const $ = /* @__PURE__ */ f(d), P = 16, O = g(function({
71
+ matchUtilities: t,
72
+ theme: a
73
+ }) {
74
+ const o = $(a("backgroundColor")), r = ["1", ...Object.keys(a("borderWidth"))], n = Object.entries(a("width")).filter(([, e]) => e.endsWith("rem")).map(([e, u]) => [
75
+ e,
76
+ parseFloat(u.replace("rem", "")) * P
77
+ ]);
78
+ r.forEach((e) => {
79
+ n.forEach(([u, c]) => {
80
+ t(
81
+ {
82
+ // This key is for the square grid background
83
+ [`bg-grid-${u}-s-${e}`]: (l) => ({
84
+ backgroundImage: `linear-gradient(to right, ${l} ${e}px, transparent ${e}px),linear-gradient(to bottom, ${l} ${e}px, transparent ${e}px)`,
85
+ backgroundSize: `${c}px ${c}px`
86
+ }),
87
+ // And this key is for the dotted background
88
+ [`bg-dot-${u}-s-${e}`]: (l) => ({
89
+ backgroundImage: `radial-gradient(${l} ${e}px, transparent ${e}px)`,
90
+ backgroundSize: `${c}px ${c}px`
91
+ })
92
+ },
93
+ { values: o, type: "color" }
94
+ );
95
+ });
96
+ });
97
+ });
98
+ export {
99
+ O as default
100
+ };
101
+ //# sourceMappingURL=tailwind-dot-grid-backgrounds.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tailwind-dot-grid-backgrounds.js","sources":["../node_modules/tailwindcss/lib/util/createPlugin.js","../node_modules/tailwindcss/lib/public/create-plugin.js","../node_modules/tailwindcss/plugin.js","../node_modules/tailwindcss/lib/util/flattenColorPalette.js","../src/plugin.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nObject.defineProperty(exports, \"default\", {\n enumerable: true,\n get: function() {\n return _default;\n }\n});\nfunction createPlugin(plugin, config) {\n return {\n handler: plugin,\n config\n };\n}\ncreatePlugin.withOptions = function(pluginFunction, configFunction = ()=>({})) {\n const optionsFunction = function(options) {\n return {\n __options: options,\n handler: pluginFunction(options),\n config: configFunction(options)\n };\n };\n optionsFunction.__isOptionsFunction = true;\n // Expose plugin dependencies so that `object-hash` returns a different\n // value if anything here changes, to ensure a rebuild is triggered.\n optionsFunction.__pluginFunction = pluginFunction;\n optionsFunction.__configFunction = configFunction;\n return optionsFunction;\n};\nconst _default = createPlugin;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nObject.defineProperty(exports, \"default\", {\n enumerable: true,\n get: function() {\n return _default;\n }\n});\nconst _createPlugin = /*#__PURE__*/ _interop_require_default(require(\"../util/createPlugin\"));\nfunction _interop_require_default(obj) {\n return obj && obj.__esModule ? obj : {\n default: obj\n };\n}\nconst _default = _createPlugin.default;\n","let createPlugin = require('./lib/public/create-plugin')\nmodule.exports = (createPlugin.__esModule ? createPlugin : { default: createPlugin }).default\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nObject.defineProperty(exports, \"default\", {\n enumerable: true,\n get: function() {\n return _default;\n }\n});\nconst flattenColorPalette = (colors)=>Object.assign({}, ...Object.entries(colors !== null && colors !== void 0 ? colors : {}).flatMap(([color, values])=>typeof values == \"object\" ? Object.entries(flattenColorPalette(values)).map(([number, hex])=>({\n [color + (number === \"DEFAULT\" ? \"\" : `-${number}`)]: hex\n })) : [\n {\n [`${color}`]: values\n }\n ]));\nconst _default = flattenColorPalette;\n","import plugin from \"tailwindcss/plugin\";\n// @ts-expect-error - flattenColorPalette file does not export a type declaration\nimport flattenColorPalette from \"tailwindcss/lib/util/flattenColorPalette\";\nimport type { PluginAPI } from \"tailwindcss/types/config\";\n\nconst REM_TO_PX = 16; // 1rem = 16px\n\nconst tailwindDotGridBackgrounds = plugin(function ({\n matchUtilities,\n theme\n}: {\n matchUtilities: PluginAPI[\"matchUtilities\"];\n theme: PluginAPI[\"theme\"];\n}) {\n // Obtain the color palette from the theme\n const colorPalette = flattenColorPalette(theme(\"backgroundColor\"));\n\n // The border widths from Tailwind CSS will be the values used for the grid stoke widths. We also add the value \"1\" to the list of border widths (since Tailwind CSS does not include it by default).\n const borderWidths = [\"1\", ...Object.keys(theme(\"borderWidth\"))];\n\n // For the sizes (the size of the squares in the grid or the distance between the dots in the dotted background), we will use the numeric width values from the \"width\" theme object. We will filter out the values that are not in \"rem\" units and convert the remaining values to pixels.\n const numericWidths: Array<[string, number]> = (\n Object.entries(theme(\"width\")) as Array<[string, string]>\n )\n .filter(([, value]) => value.endsWith(\"rem\"))\n .map(([key, value]) => [\n key,\n parseFloat(value.replace(\"rem\", \"\")) * REM_TO_PX\n ]);\n\n // Now iterate to generate all the utility classes\n borderWidths.forEach(borderWidth => {\n numericWidths.forEach(([widthKey, widthValue]) => {\n matchUtilities(\n {\n // This key is for the square grid background\n [`bg-grid-${widthKey}-s-${borderWidth}`]: (colorValue: string) => {\n return {\n backgroundImage: `linear-gradient(to right, ${colorValue} ${borderWidth}px, transparent ${borderWidth}px),linear-gradient(to bottom, ${colorValue} ${borderWidth}px, transparent ${borderWidth}px)`,\n backgroundSize: `${widthValue}px ${widthValue}px`\n };\n },\n // And this key is for the dotted background\n [`bg-dot-${widthKey}-s-${borderWidth}`]: (colorValue: string) => {\n return {\n backgroundImage: `radial-gradient(${colorValue} ${borderWidth}px, transparent ${borderWidth}px)`,\n backgroundSize: `${widthValue}px ${widthValue}px`\n };\n }\n },\n { values: colorPalette, type: \"color\" }\n );\n });\n });\n});\n\nexport default tailwindDotGridBackgrounds;\n"],"names":["exports","_default","createPlugin","plugin","config","pluginFunction","configFunction","optionsFunction","options","_createPlugin","_interop_require_default","require$$0","obj","flattenColorPalette","colors","color","values","number","hex","REM_TO_PX","tailwindDotGridBackgrounds","matchUtilities","theme","colorPalette","borderWidths","numericWidths","value","key","borderWidth","widthKey","widthValue","colorValue"],"mappings":";;;;;AACA,SAAO,eAAwBA,GAAA,cAAc;AAAA,IACzC,OAAO;AAAA,EACX,CAAC,GACD,OAAO,eAAeA,GAAS,WAAW;AAAA,IACtC,YAAY;AAAA,IACZ,KAAK,WAAW;AACZ,aAAOC;AAAA,IACV;AAAA,EACL,CAAC;AACD,WAASC,EAAaC,GAAQC,GAAQ;AAClC,WAAO;AAAA,MACH,SAASD;AAAA,MACT,QAAAC;AAAA,IACR;AAAA,EACC;AACD,EAAAF,EAAa,cAAc,SAASG,GAAgBC,IAAiB,OAAK,CAAE,IAAG;AAC3E,UAAMC,IAAkB,SAASC,GAAS;AACtC,aAAO;AAAA,QACH,WAAWA;AAAA,QACX,SAASH,EAAeG,CAAO;AAAA,QAC/B,QAAQF,EAAeE,CAAO;AAAA,MAC1C;AAAA,IACA;AACI,WAAAD,EAAgB,sBAAsB,IAGtCA,EAAgB,mBAAmBF,GACnCE,EAAgB,mBAAmBD,GAC5BC;AAAA,EACX;AACA,QAAMN,IAAWC;;;AC9BjB,SAAO,eAAwBF,GAAA,cAAc;AAAA,IACzC,OAAO;AAAA,EACX,CAAC,GACD,OAAO,eAAeA,GAAS,WAAW;AAAA,IACtC,YAAY;AAAA,IACZ,KAAK,WAAW;AACZ,aAAOC;AAAA,IACV;AAAA,EACL,CAAC;AACD,QAAMQ,IAA8B,gBAAAC,EAAyBC,CAA+B;AAC5F,WAASD,EAAyBE,GAAK;AACnC,WAAOA,KAAOA,EAAI,aAAaA,IAAM;AAAA,MACjC,SAASA;AAAA,IACjB;AAA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AAClC,IAAAH,EAAc,QAAQ,CAAC,CAACI,GAAUC,CAAU,MAAM;AAChD,MAAAT;AAAA,QACE;AAAA;AAAA,UAEE,CAAC,WAAWQ,CAAQ,MAAMD,CAAW,EAAE,GAAG,CAACG,OAClC;AAAA,YACL,iBAAiB,6BAA6BA,CAAU,IAAIH,CAAW,mBAAmBA,CAAW,kCAAkCG,CAAU,IAAIH,CAAW,mBAAmBA,CAAW;AAAA,YAC9L,gBAAgB,GAAGE,CAAU,MAAMA,CAAU;AAAA,UAAA;AAAA;AAAA,UAIjD,CAAC,UAAUD,CAAQ,MAAMD,CAAW,EAAE,GAAG,CAACG,OACjC;AAAA,YACL,iBAAiB,mBAAmBA,CAAU,IAAIH,CAAW,mBAAmBA,CAAW;AAAA,YAC3F,gBAAgB,GAAGE,CAAU,MAAMA,CAAU;AAAA,UAAA;AAAA,QAGnD;AAAA,QACA,EAAE,QAAQP,GAAc,MAAM,QAAQ;AAAA,MAAA;AAAA,IACxC,CACD;AAAA,EAAA,CACF;AACH,CAAC;","x_google_ignoreList":[0,1,2,3]}
@@ -0,0 +1,2 @@
1
+ (function(i,c){typeof exports=="object"&&typeof module<"u"?module.exports=c():typeof define=="function"&&define.amd?define(c):(i=typeof globalThis<"u"?globalThis:i||self,i["tailwind-dot-grid-backgrounds"]=c())})(this,function(){"use strict";function i(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var c={},s={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return a}});function u(r,n){return{handler:r,config:n}}u.withOptions=function(r,n=()=>({})){const e=function(o){return{__options:o,handler:r(o),config:n(o)}};return e.__isOptionsFunction=!0,e.__pluginFunction=r,e.__configFunction=n,e};const a=u})(s),function(t){Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return r}});const u=a(s);function a(n){return n&&n.__esModule?n:{default:n}}const r=u.default}(c);let d=c;var g=(d.__esModule?d:{default:d}).default;const _=i(g);var p={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return a}});const u=r=>Object.assign({},...Object.entries(r??{}).flatMap(([n,e])=>typeof e=="object"?Object.entries(u(e)).map(([o,l])=>({[n+(o==="DEFAULT"?"":`-${o}`)]:l})):[{[`${n}`]:e}])),a=u})(p);const $=i(p),b=16;return _(function({matchUtilities:t,theme:u}){const a=$(u("backgroundColor")),r=["1",...Object.keys(u("borderWidth"))],n=Object.entries(u("width")).filter(([,e])=>e.endsWith("rem")).map(([e,o])=>[e,parseFloat(o.replace("rem",""))*b]);r.forEach(e=>{n.forEach(([o,l])=>{t({[`bg-grid-${o}-s-${e}`]:f=>({backgroundImage:`linear-gradient(to right, ${f} ${e}px, transparent ${e}px),linear-gradient(to bottom, ${f} ${e}px, transparent ${e}px)`,backgroundSize:`${l}px ${l}px`}),[`bg-dot-${o}-s-${e}`]:f=>({backgroundImage:`radial-gradient(${f} ${e}px, transparent ${e}px)`,backgroundSize:`${l}px ${l}px`})},{values:a,type:"color"})})})})});
2
+ //# sourceMappingURL=tailwind-dot-grid-backgrounds.umd.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tailwind-dot-grid-backgrounds.umd.cjs","sources":["../node_modules/tailwindcss/lib/util/createPlugin.js","../node_modules/tailwindcss/lib/public/create-plugin.js","../node_modules/tailwindcss/plugin.js","../node_modules/tailwindcss/lib/util/flattenColorPalette.js","../src/plugin.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nObject.defineProperty(exports, \"default\", {\n enumerable: true,\n get: function() {\n return _default;\n }\n});\nfunction createPlugin(plugin, config) {\n return {\n handler: plugin,\n config\n };\n}\ncreatePlugin.withOptions = function(pluginFunction, configFunction = ()=>({})) {\n const optionsFunction = function(options) {\n return {\n __options: options,\n handler: pluginFunction(options),\n config: configFunction(options)\n };\n };\n optionsFunction.__isOptionsFunction = true;\n // Expose plugin dependencies so that `object-hash` returns a different\n // value if anything here changes, to ensure a rebuild is triggered.\n optionsFunction.__pluginFunction = pluginFunction;\n optionsFunction.__configFunction = configFunction;\n return optionsFunction;\n};\nconst _default = createPlugin;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nObject.defineProperty(exports, \"default\", {\n enumerable: true,\n get: function() {\n return _default;\n }\n});\nconst _createPlugin = /*#__PURE__*/ _interop_require_default(require(\"../util/createPlugin\"));\nfunction _interop_require_default(obj) {\n return obj && obj.__esModule ? obj : {\n default: obj\n };\n}\nconst _default = _createPlugin.default;\n","let createPlugin = require('./lib/public/create-plugin')\nmodule.exports = (createPlugin.__esModule ? createPlugin : { default: createPlugin }).default\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nObject.defineProperty(exports, \"default\", {\n enumerable: true,\n get: function() {\n return _default;\n }\n});\nconst flattenColorPalette = (colors)=>Object.assign({}, ...Object.entries(colors !== null && colors !== void 0 ? colors : {}).flatMap(([color, values])=>typeof values == \"object\" ? Object.entries(flattenColorPalette(values)).map(([number, hex])=>({\n [color + (number === \"DEFAULT\" ? \"\" : `-${number}`)]: hex\n })) : [\n {\n [`${color}`]: values\n }\n ]));\nconst _default = flattenColorPalette;\n","import plugin from \"tailwindcss/plugin\";\n// @ts-expect-error - flattenColorPalette file does not export a type declaration\nimport flattenColorPalette from \"tailwindcss/lib/util/flattenColorPalette\";\nimport type { PluginAPI } from \"tailwindcss/types/config\";\n\nconst REM_TO_PX = 16; // 1rem = 16px\n\nconst tailwindDotGridBackgrounds = plugin(function ({\n matchUtilities,\n theme\n}: {\n matchUtilities: PluginAPI[\"matchUtilities\"];\n theme: PluginAPI[\"theme\"];\n}) {\n // Obtain the color palette from the theme\n const colorPalette = flattenColorPalette(theme(\"backgroundColor\"));\n\n // The border widths from Tailwind CSS will be the values used for the grid stoke widths. We also add the value \"1\" to the list of border widths (since Tailwind CSS does not include it by default).\n const borderWidths = [\"1\", ...Object.keys(theme(\"borderWidth\"))];\n\n // For the sizes (the size of the squares in the grid or the distance between the dots in the dotted background), we will use the numeric width values from the \"width\" theme object. We will filter out the values that are not in \"rem\" units and convert the remaining values to pixels.\n const numericWidths: Array<[string, number]> = (\n Object.entries(theme(\"width\")) as Array<[string, string]>\n )\n .filter(([, value]) => value.endsWith(\"rem\"))\n .map(([key, value]) => [\n key,\n parseFloat(value.replace(\"rem\", \"\")) * REM_TO_PX\n ]);\n\n // Now iterate to generate all the utility classes\n borderWidths.forEach(borderWidth => {\n numericWidths.forEach(([widthKey, widthValue]) => {\n matchUtilities(\n {\n // This key is for the square grid background\n [`bg-grid-${widthKey}-s-${borderWidth}`]: (colorValue: string) => {\n return {\n backgroundImage: `linear-gradient(to right, ${colorValue} ${borderWidth}px, transparent ${borderWidth}px),linear-gradient(to bottom, ${colorValue} ${borderWidth}px, transparent ${borderWidth}px)`,\n backgroundSize: `${widthValue}px ${widthValue}px`\n };\n },\n // And this key is for the dotted background\n [`bg-dot-${widthKey}-s-${borderWidth}`]: (colorValue: string) => {\n return {\n backgroundImage: `radial-gradient(${colorValue} ${borderWidth}px, transparent ${borderWidth}px)`,\n backgroundSize: `${widthValue}px ${widthValue}px`\n };\n }\n },\n { values: colorPalette, type: \"color\" }\n );\n });\n });\n});\n\nexport default tailwindDotGridBackgrounds;\n"],"names":["exports","_default","createPlugin","plugin","config","pluginFunction","configFunction","optionsFunction","options","_createPlugin","_interop_require_default","require$$0","obj","flattenColorPalette","colors","color","values","number","hex","REM_TO_PX","matchUtilities","theme","colorPalette","borderWidths","numericWidths","value","key","borderWidth","widthKey","widthValue","colorValue"],"mappings":"gXACA,OAAO,eAAwBA,EAAA,aAAc,CACzC,MAAO,EACX,CAAC,EACD,OAAO,eAAeA,EAAS,UAAW,CACtC,WAAY,GACZ,IAAK,UAAW,CACZ,OAAOC,CACV,CACL,CAAC,EACD,SAASC,EAAaC,EAAQC,EAAQ,CAClC,MAAO,CAC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AAWY,oBCZXM,EAAY,UAEiBhB,EAAO,SAAU,CAClD,eAAAiB,EACA,MAAAC,CACF,EAGG,CAED,MAAMC,EAAeT,EAAoBQ,EAAM,iBAAiB,CAAC,EAG3DE,EAAe,CAAC,IAAK,GAAG,OAAO,KAAKF,EAAM,aAAa,CAAC,CAAC,EAGzDG,EACJ,OAAO,QAAQH,EAAM,OAAO,CAAC,EAE5B,OAAO,CAAC,CAAG,CAAAI,CAAK,IAAMA,EAAM,SAAS,KAAK,CAAC,EAC3C,IAAI,CAAC,CAACC,EAAKD,CAAK,IAAM,CACrBC,EACA,WAAWD,EAAM,QAAQ,MAAO,EAAE,CAAC,EAAIN,CAAA,CACxC,EAGHI,EAAa,QAAuBI,GAAA,CAClCH,EAAc,QAAQ,CAAC,CAACI,EAAUC,CAAU,IAAM,CAChDT,EACE,CAEE,CAAC,WAAWQ,CAAQ,MAAMD,CAAW,EAAE,EAAIG,IAClC,CACL,gBAAiB,6BAA6BA,CAAU,IAAIH,CAAW,mBAAmBA,CAAW,kCAAkCG,CAAU,IAAIH,CAAW,mBAAmBA,CAAW,MAC9L,eAAgB,GAAGE,CAAU,MAAMA,CAAU,IAAA,GAIjD,CAAC,UAAUD,CAAQ,MAAMD,CAAW,EAAE,EAAIG,IACjC,CACL,gBAAiB,mBAAmBA,CAAU,IAAIH,CAAW,mBAAmBA,CAAW,MAC3F,eAAgB,GAAGE,CAAU,MAAMA,CAAU,IAAA,EAGnD,EACA,CAAE,OAAQP,EAAc,KAAM,OAAQ,CAAA,CACxC,CACD,CAAA,CACF,CACH,CAAC","x_google_ignoreList":[0,1,2,3]}
package/package.json ADDED
@@ -0,0 +1,81 @@
1
+ {
2
+ "name": "@nauverse/tailwind-dot-grid-backgrounds",
3
+ "description": "🎨 A tiny Tailwind plugin to add dot and grid customizable backgrounds fast",
4
+ "author": {
5
+ "name": "Albert Adler | @albertadler",
6
+ "url": "https://albertadler.com"
7
+ },
8
+ "license": "MIT",
9
+ "homepage": "https://github.com/TheNaubit/tailwind-dot-grid-backgrounds",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/TheNaubit/tailwind-dot-grid-backgrounds.git"
13
+ },
14
+ "bugs": {
15
+ "url": "https://github.com/TheNaubit/tailwind-dot-grid-backgrounds/issues"
16
+ },
17
+ "keywords": [
18
+ "tailwind",
19
+ "tailwindcss",
20
+ "tailwindcss-plugin",
21
+ "tailwindcss-grid-background",
22
+ "tailwindcss-dot-background",
23
+ "grid-background",
24
+ "dot-background"
25
+ ],
26
+ "version": "1.2.0",
27
+ "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": ">=18.0.0"
33
+ },
34
+ "exports": {
35
+ ".": {
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
+ }
45
+ },
46
+ "files": [
47
+ "dist"
48
+ ],
49
+ "scripts": {
50
+ "build": "tsc && vite build",
51
+ "test": "vitest",
52
+ "test:run": "vitest run",
53
+ "test:coverage": "vitest run --coverage",
54
+ "lint": "eslint . --ext .ts --report-unused-disable-directives --max-warnings 0",
55
+ "lint:fix": "eslint --fix . --ext .ts --report-unused-disable-directives --max-warnings 0",
56
+ "prepare": "husky"
57
+ },
58
+ "devDependencies": {
59
+ "@commitlint/cli": "19.2.2",
60
+ "@commitlint/config-conventional": "19.2.2",
61
+ "@types/eslint": "8.56.9",
62
+ "@types/node": "20.12.7",
63
+ "@typescript-eslint/eslint-plugin": "7.7.0",
64
+ "@typescript-eslint/parser": "7.7.0",
65
+ "@vitest/coverage-v8": "1.5.0",
66
+ "eslint": "8.57.0",
67
+ "eslint-config-prettier": "9.1.0",
68
+ "eslint-plugin-prettier": "5.1.3",
69
+ "husky": "9.0.11",
70
+ "prettier": "3.2.5",
71
+ "tailwindcss": "3.4.3",
72
+ "postcss": "8.4.38",
73
+ "typescript": "5.4.5",
74
+ "vite": "5.2.9",
75
+ "vite-plugin-dts": "3.8.3",
76
+ "vitest": "1.5.0"
77
+ },
78
+ "peerDependencies": {
79
+ "tailwindcss": ">=3.4.0"
80
+ }
81
+ }