proto-tailwindcss-pxls 0.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/.editorconfig ADDED
@@ -0,0 +1,10 @@
1
+ # editorconfig.org
2
+ root = true
3
+
4
+ [*]
5
+ indent_style = space
6
+ indent_size = 2
7
+ end_of_line = lf
8
+ charset = utf-8
9
+ trim_trailing_whitespace = true
10
+ insert_final_newline = true
package/.eslintignore ADDED
@@ -0,0 +1,2 @@
1
+ .next
2
+ out
package/.eslintrc ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "env": {
3
+ "browser": true,
4
+ "node": true,
5
+ "es6": true,
6
+ "commonjs": true
7
+ },
8
+ "plugins": ["react"],
9
+ "extends": [
10
+ "eslint:recommended",
11
+ "plugin:react/recommended",
12
+ "plugin:prettier/recommended"
13
+ ],
14
+ "settings": {
15
+ "react": {
16
+ "version": "detect" // React version. "detect" automatically picks the version you have installed.
17
+ // You can also use `16.0`, `16.3`, etc, if you want to override the detected value.
18
+ // default to latest and warns if missing
19
+ // It will default to "detect" in the future
20
+ },
21
+ "import/resolver": {
22
+ "node": {
23
+ "paths": ["./"]
24
+ }
25
+ }
26
+ },
27
+ "parser": "babel-eslint",
28
+ "parserOptions": {
29
+ "ecmaVersion": 6,
30
+ "sourceType": "module",
31
+ "ecmaFeatures": {
32
+ "jsx": true,
33
+ "experimentalObjectRestSpread": true,
34
+ "modules": true
35
+ }
36
+ },
37
+ "rules": {
38
+ "react/prefer-stateless-function": 0,
39
+ "linebreak-style": 0,
40
+ "jsx-a11y/heading-has-content": 0,
41
+ "jsx-a11y/href-no-hash": 0,
42
+ "jsx-a11y/anchor-is-valid": 0,
43
+ "no-underscore-dangle": 0,
44
+ "react/no-find-dom-node": 0,
45
+ "react/prop-types": 0,
46
+ "no-nested-ternary": 0
47
+ }
48
+ }
package/.noBuild ADDED
File without changes
package/CHANGELOG.md ADDED
@@ -0,0 +1,21 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
9
+
10
+ ## [v1.0.2](https://github.com/robksawyer/tailwindcss-pixel-dimensions/compare/v1.0.1...v1.0.2) - 2020-07-22
11
+
12
+ ### Commits
13
+
14
+ - Updated README [`11d7d89`](https://github.com/robksawyer/tailwindcss-pixel-dimensions/commit/11d7d8978a69e52a85f0da986d8682d36aed9eb5)
15
+
16
+ ## v1.0.1 - 2020-07-22
17
+
18
+ ### Commits
19
+
20
+ - Initial release [`0899011`](https://github.com/robksawyer/tailwindcss-pixel-dimensions/commit/08990110273d68951eb1ebc6e990a21038891944)
21
+ - Release 1.0.1 [`01dd012`](https://github.com/robksawyer/tailwindcss-pixel-dimensions/commit/01dd012aea13aad8346326e12bda8971db38f1bd)
package/LICENSE.md ADDED
@@ -0,0 +1,7 @@
1
+ # ISC License
2
+
3
+ Copyright (c) Rob Sawyer
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,147 @@
1
+ # proto-tailwindcss-pxls
2
+
3
+ - *Pixel Dimensions for Tailwind CSS*
4
+
5
+ This plugin allows you to quickly generate pixel classes for Tailwind CSS.
6
+
7
+ ## Requirements
8
+
9
+ This plugin requires Tailwind CSS 2.2.2 or later.
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ yarn add proto-tailwindcss-pxls
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ The following plugin options are available. See below how these are passed (via an object) to the plugin in your `tailwind.config.js`.
20
+
21
+ ## Supported Tags
22
+
23
+ This plugin currently support the following tags in Options:
24
+
25
+ ```
26
+ const tags = [
27
+ 'fontSize',
28
+ 'height',
29
+ 'lineHeight',
30
+ 'maxHeight',
31
+ 'maxWidth',
32
+ 'minHeight',
33
+ 'minWidth',
34
+ 'spacing',
35
+ 'width',
36
+ ]
37
+ ```
38
+
39
+ Specifying any of those in options will generate pixel classes as shown below.
40
+
41
+ > CAVEAT: if you want the full 900 pixel variations to be generated, you have to pass an empty object in the options:
42
+ >
43
+ > ```
44
+ > width: {},
45
+ > ```
46
+ >
47
+ > The plugin no longer generates width & height by default, you must specify which tags you want to generate...
48
+
49
+ ## Options Available
50
+
51
+ You can pass along number values to define the range of the generated sizes.
52
+
53
+ ```
54
+ start: number, // defaults to 0
55
+ stop: number, // defaults to 900
56
+ ```
57
+
58
+ For example:
59
+
60
+ ```js
61
+ // tailwind.config.js
62
+ module.exports = {
63
+ plugins: [
64
+ // Generate 10 widths and 3 heights in pxs
65
+ require('proto-tailwindcss-pxls')({
66
+ width: {
67
+ stop: 10,
68
+ },
69
+ height: {
70
+ stop: 10,
71
+ start: 8,
72
+ },
73
+ }),
74
+ ],
75
+ };
76
+ ```
77
+
78
+ The above configuration would roughly generate the following CSS:
79
+
80
+ ```css
81
+ .w-0px {
82
+ width: 0;
83
+ }
84
+
85
+ .w-1px {
86
+ width: 1px;
87
+ }
88
+
89
+ .w-2px {
90
+ width: 2px;
91
+ }
92
+
93
+ .w-3px {
94
+ width: 3px;
95
+ }
96
+
97
+ .w-4px {
98
+ width: 4px;
99
+ }
100
+
101
+ .w-5px {
102
+ width: 5px;
103
+ }
104
+
105
+ .w-6px {
106
+ width: 6px;
107
+ }
108
+
109
+ .w-7px {
110
+ width: 7px;
111
+ }
112
+
113
+ .w-8px {
114
+ width: 8px;
115
+ }
116
+
117
+ .w-9px {
118
+ width: 9px;
119
+ }
120
+
121
+ .w-10px {
122
+ width: 10px;
123
+ }
124
+
125
+ .h-8px {
126
+ height: 8px;
127
+ }
128
+
129
+ .h-9px {
130
+ height: 9px;
131
+ }
132
+
133
+ .h-10px {
134
+ height: 10px;
135
+ }
136
+ /* etc. */
137
+ ```
138
+
139
+ Which you can then use in your HTML like this:
140
+
141
+ ```html
142
+ <div class="h-10px">
143
+ I'm a div with a height of 10 pixels or pickles depending on how you pronounce it.
144
+ </div>
145
+ ```
146
+
147
+ The above depends on the order of the generated CSS.
package/index.js ADDED
@@ -0,0 +1,76 @@
1
+ /**
2
+ * TailwindCSS Pixels Sizes
3
+ * Generates pixel sizes via plugin... [ height, width, lineHeight ]
4
+ * @file index.js
5
+ */
6
+ const plugin = require('tailwindcss/plugin')
7
+
8
+ /**
9
+ * getSizes
10
+ * Handles getting sizes in pixels...
11
+ * @param {int} stop
12
+ * @param {int} start
13
+ * @return {object}
14
+ */
15
+ const getSizes = (stop = 900, start = 0) => {
16
+ // The following generates an array of increasing values from the totalSizes above.
17
+ const sizeArray = Array.from(Array(stop + 1).keys())
18
+ const sliced = sizeArray.slice(start, sizeArray.length)
19
+ // Traverse the array and generate sizes in pxs.
20
+ const sizes = sliced.map((x) =>
21
+ x > 0 ? { [`${x}px`]: `${x}px;` } : { [`${x}px`]: `${x};` }
22
+ )
23
+ // Merge the array of objects into a single one
24
+ const sizeObj = Object.assign.apply(Object, sizes)
25
+ // console.log('sizeObj', sizeObj)
26
+ return sizeObj
27
+ }
28
+
29
+ const generate = (options) => {
30
+ const tags = [
31
+ 'fontSize',
32
+ 'height',
33
+ 'lineHeight',
34
+ 'maxHeight',
35
+ 'maxWidth',
36
+ 'minHeight',
37
+ 'minWidth',
38
+ 'spacing',
39
+ 'width',
40
+ ]
41
+
42
+ const output = {
43
+ theme: {
44
+ extend: {},
45
+ },
46
+ }
47
+
48
+ if (options) {
49
+ const keys = Object.keys(options)
50
+
51
+ keys.forEach((key) => {
52
+ if (tags.includes(key)) {
53
+ // NOTE: support the new and old option props...
54
+ const stop = options[key].stop || options[key].total || 900
55
+ const start = options[key].start || options[key].startingValue || 0
56
+
57
+ const results = getSizes(stop, start)
58
+
59
+ output.theme.extend[key] = { ...results }
60
+ }
61
+ })
62
+ }
63
+
64
+ return output
65
+ }
66
+
67
+ module.exports = plugin.withOptions(
68
+ function (_options) {
69
+ return function () {
70
+ // ...
71
+ }
72
+ },
73
+ function (options) {
74
+ return generate(options)
75
+ }
76
+ )
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "proto-tailwindcss-pxls",
3
+ "version": "0.0.1",
4
+ "description": "Tailwind CSS 3.x plugin that generates pixel classes for tricky pixel-perfect layouts.",
5
+ "main": "index.js",
6
+ "author": "Rob Sawyer <robksawyer@gmail.com>",
7
+ "contributors": [
8
+ {
9
+ "name": "Richard Hess",
10
+ "email": "eswat2@gmail.com",
11
+ "url": "https://eswat2.dev"
12
+ }
13
+ ],
14
+ "license": "ISC",
15
+ "repository": "https://github.com/eswat2/proto-tailwindcss-pxls.git",
16
+ "bugs": "https://github.com/eswat2/proto-tailwindcss-pxls/issues",
17
+ "homepage": "https://github.com/eswat2/proto-tailwindcss-pxls",
18
+ "engines": {
19
+ "node": "~22"
20
+ },
21
+ "private": false,
22
+ "scripts": {
23
+ "test": "jest",
24
+ "deploy": "yarn test; echo -- run [ np patch ]",
25
+ "format": "prettier --write *.js cSpell.json"
26
+ },
27
+ "dependencies": {},
28
+ "publishConfig": {
29
+ "registry": "https://registry.npmjs.org/"
30
+ },
31
+ "devDependencies": {
32
+ "autoprefixer": "10.4.20",
33
+ "jest": "29.7.0",
34
+ "jest-matcher-css": "1.1.0",
35
+ "lodash": "4.17.21",
36
+ "postcss": "8.4.49",
37
+ "rollup": "4.27.3",
38
+ "tailwindcss": "3.4.15"
39
+ }
40
+ }