tailwindcss-custom-colors 1.0.11 → 1.0.13
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 +21 -21
- package/README.md +208 -173
- package/dist/index.d.ts +1 -0
- package/dist/index.js +40 -36
- package/dist/index.js.map +1 -1
- package/package.json +36 -36
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2023 Quentin Juarez
|
|
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.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Quentin Juarez
|
|
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
CHANGED
|
@@ -1,173 +1,208 @@
|
|
|
1
|
-
## Installation
|
|
2
|
-
|
|
3
|
-
```bash
|
|
4
|
-
# With npm
|
|
5
|
-
npm i tailwindcss-custom-colors@latest
|
|
6
|
-
|
|
7
|
-
# With yarn
|
|
8
|
-
yarn add tailwindcss-custom-colors@latest
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
[](https://badge.fury.io/js/tailwindcss-custom-colors)
|
|
12
|
-
|
|
13
|
-
<!-- 
|
|
14
|
-

|
|
15
|
-

|
|
16
|
-

|
|
17
|
-

|
|
18
|
-
 -->
|
|
19
|
-
|
|
20
|
-
## Usage
|
|
21
|
-
|
|
22
|
-
### Import
|
|
23
|
-
|
|
24
|
-
```js
|
|
25
|
-
import { generateConfig } from "tailwindcss-custom-colors";
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
```js
|
|
29
|
-
import { generateStyleVariables } from "tailwindcss-custom-colors";
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
###
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
- `
|
|
41
|
-
- `
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
)
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
--
|
|
138
|
-
--
|
|
139
|
-
--
|
|
140
|
-
--
|
|
141
|
-
--
|
|
142
|
-
|
|
143
|
-
--
|
|
144
|
-
--
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
1
|
+
## Installation
|
|
2
|
+
|
|
3
|
+
```bash
|
|
4
|
+
# With npm
|
|
5
|
+
npm i tailwindcss-custom-colors@latest
|
|
6
|
+
|
|
7
|
+
# With yarn
|
|
8
|
+
yarn add tailwindcss-custom-colors@latest
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
[](https://badge.fury.io/js/tailwindcss-custom-colors)
|
|
12
|
+
|
|
13
|
+
<!-- 
|
|
14
|
+

|
|
15
|
+

|
|
16
|
+

|
|
17
|
+

|
|
18
|
+
 -->
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
### Import
|
|
23
|
+
|
|
24
|
+
```js
|
|
25
|
+
import { generateConfig } from "tailwindcss-custom-colors";
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
```js
|
|
29
|
+
import { generateStyleVariables } from "tailwindcss-custom-colors";
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Options
|
|
33
|
+
|
|
34
|
+
The `Options` interface allows you to customize the behavior of the package. Below are the available options and their default values.
|
|
35
|
+
|
|
36
|
+
#### Available Options
|
|
37
|
+
|
|
38
|
+
- `suffixMultiplier` (optional): Determines the multiplier for suffixes. Possible values are `100`, `10`, or `1`. Default is `100`.
|
|
39
|
+
- `variablePrefix` (optional): Specifies a prefix for variable names. Default is `undefined`.
|
|
40
|
+
- `contrast` (optional): If set to `true`, calculates the contrast. Default is `true`.
|
|
41
|
+
- `complement` (optional): If set to `true`, calculates the complementary color. Default is `true`.
|
|
42
|
+
- `classification` (optional): An object containing color classifications for light and dark themes. Default is `{ light: "#FFFFFF", dark: "#000000" }`.
|
|
43
|
+
- `light`: Hex color for light theme. Default is `"#FFFFFF"`.
|
|
44
|
+
- `dark`: Hex color for dark theme. Default is `"#000000"`.
|
|
45
|
+
- `steps` (optional): Determines the step values for shades. Possible values are `100` or `50`. Default is `100`.
|
|
46
|
+
- `default` (optional): If set to `true`, uses the default configuration. Default is `true`.
|
|
47
|
+
|
|
48
|
+
#### Default Options
|
|
49
|
+
|
|
50
|
+
The `defaultOptions` object represents the default configuration for the package:
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
const defaultOptions: DefaultOptions = {
|
|
54
|
+
suffixMultiplier: 100,
|
|
55
|
+
variablePrefix: undefined,
|
|
56
|
+
contrast: true,
|
|
57
|
+
complement: true,
|
|
58
|
+
classification: {
|
|
59
|
+
light: "#FFFFFF",
|
|
60
|
+
dark: "#000000",
|
|
61
|
+
},
|
|
62
|
+
steps: 100,
|
|
63
|
+
default: true,
|
|
64
|
+
};
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### generateConfig()
|
|
68
|
+
|
|
69
|
+
```js
|
|
70
|
+
const extendedColors = generateConfig(colorNames, options);
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
#### The generateConfig function takes the following parameters:
|
|
74
|
+
|
|
75
|
+
- `colorNames`: An array of color names or a single color name.
|
|
76
|
+
- `options` (optional): An object of options that allows you to customize the generated colors. The available options are `suffixMultiplier` (default: `100`), which determines the suffix used to generate variables names (e.g `[1, 10, 100]`) and `variablePrefix` (default: `undefined`), which determines the prefix for the css variable name, none by default.
|
|
77
|
+
|
|
78
|
+
The function returns a config object for Tailwind CSS with the specified color names and their respective tints.
|
|
79
|
+
|
|
80
|
+
### generateStyleVariables()
|
|
81
|
+
|
|
82
|
+
```js
|
|
83
|
+
const variables = generateStyleVariables(colorParams, options);
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
#### The generateStyleVariables function takes the following parameters:
|
|
87
|
+
|
|
88
|
+
- `colorParams`: An array of color params or a single color params including a color (hex) and a name.
|
|
89
|
+
- `options` (optional): An object of options that allows you to customize the generated colors. The available options are `suffixMultiplier` (default: `100`), which determines the suffix used to generate variables names (e.g `[1, 10, 100]`) and `variablePrefix` (default: `undefined`), which determines the prefix for the css variable name, none by default.
|
|
90
|
+
|
|
91
|
+
## Example
|
|
92
|
+
|
|
93
|
+
Extend your tailwind config
|
|
94
|
+
|
|
95
|
+
_tailwind.config.js_
|
|
96
|
+
|
|
97
|
+
```js
|
|
98
|
+
/** @type {import('tailwindcss').Config} */
|
|
99
|
+
import { generateConfig } from "tailwindcss-custom-colors";
|
|
100
|
+
|
|
101
|
+
const extendedColors = generateConfig(["primary", "secondary"]);
|
|
102
|
+
|
|
103
|
+
module.exports = {
|
|
104
|
+
content: ["./src/**/*.{index,vue,js,ts,jsx,tsx}"],
|
|
105
|
+
theme: {
|
|
106
|
+
extend: {
|
|
107
|
+
colors: extendedColors,
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
plugins: [],
|
|
111
|
+
};
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
#### Output for `extendedColors`:
|
|
115
|
+
|
|
116
|
+
```json
|
|
117
|
+
{
|
|
118
|
+
"primary": {
|
|
119
|
+
"100": "rgb(var(--primary-100) / <alpha-value>)",
|
|
120
|
+
"200": "rgb(var(--primary-200) / <alpha-value>)",
|
|
121
|
+
"300": "rgb(var(--primary-300) / <alpha-value>)",
|
|
122
|
+
"400": "rgb(var(--primary-400) / <alpha-value>)",
|
|
123
|
+
"500": "rgb(var(--primary-500) / <alpha-value>)",
|
|
124
|
+
"600": "rgb(var(--primary-600) / <alpha-value>)",
|
|
125
|
+
"700": "rgb(var(--primary-700) / <alpha-value>)",
|
|
126
|
+
"800": "rgb(var(--primary-800) / <alpha-value>)",
|
|
127
|
+
"900": "rgb(var(--primary-900) / <alpha-value>)",
|
|
128
|
+
"DEFAULT": "rgb(var(--primary) / <alpha-value>)",
|
|
129
|
+
"contrast": "rgb(var(--primary-contrast) / <alpha-value>)",
|
|
130
|
+
"complement": "rgb(var(--primary-complement) / <alpha-value>)"
|
|
131
|
+
},
|
|
132
|
+
"secondary": {
|
|
133
|
+
"100": "rgb(var(--secondary-100) / <alpha-value>)",
|
|
134
|
+
"200": "rgb(var(--secondary-200) / <alpha-value>)",
|
|
135
|
+
"300": "rgb(var(--secondary-300) / <alpha-value>)",
|
|
136
|
+
"400": "rgb(var(--secondary-400) / <alpha-value>)",
|
|
137
|
+
"500": "rgb(var(--secondary-500) / <alpha-value>)",
|
|
138
|
+
"600": "rgb(var(--secondary-600) / <alpha-value>)",
|
|
139
|
+
"700": "rgb(var(--secondary-700) / <alpha-value>)",
|
|
140
|
+
"800": "rgb(var(--secondary-800) / <alpha-value>)",
|
|
141
|
+
"900": "rgb(var(--secondary-900) / <alpha-value>)",
|
|
142
|
+
"DEFAULT": "rgb(var(--secondary) / <alpha-value>)",
|
|
143
|
+
"contrast": "rgb(var(--secondary-contrast) / <alpha-value>)",
|
|
144
|
+
"complement": "rgb(var(--secondary-complement) / <alpha-value>)"
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Variables
|
|
150
|
+
|
|
151
|
+
Generate css variables
|
|
152
|
+
|
|
153
|
+
```js
|
|
154
|
+
import { generateStyleVariables } from "tailwindcss-custom-colors";
|
|
155
|
+
|
|
156
|
+
const variables = generateStyleVariables(
|
|
157
|
+
{
|
|
158
|
+
color: "#940BDF",
|
|
159
|
+
name: "primary",
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
color: "#FFD534",
|
|
163
|
+
name: "secondary",
|
|
164
|
+
}
|
|
165
|
+
);
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
#### Output for `variables`:
|
|
169
|
+
|
|
170
|
+
```css
|
|
171
|
+
--primary: 148 11 223;
|
|
172
|
+
--primary-contrast: 255 255 255;
|
|
173
|
+
--primary-complement: 0 0 0;
|
|
174
|
+
--primary-100: 223 172 251;
|
|
175
|
+
--primary-200: 207 128 249;
|
|
176
|
+
--primary-300: 188 80 247;
|
|
177
|
+
--primary-400: 172 36 245;
|
|
178
|
+
--primary-500: 148 11 223;
|
|
179
|
+
--primary-600: 120 8 180;
|
|
180
|
+
--primary-700: 91 6 136;
|
|
181
|
+
--primary-800: 58 4 88;
|
|
182
|
+
--primary-900: 29 2 44;
|
|
183
|
+
--secondary: 255 213 52;
|
|
184
|
+
--secondary-contrast: 0 0 0;
|
|
185
|
+
--secondary-complement: 255 255 255;
|
|
186
|
+
--secondary-100: 255 263 296;
|
|
187
|
+
--secondary-200: 255 251 235;
|
|
188
|
+
--secondary-300: 255 239 173;
|
|
189
|
+
--secondary-400: 255 226 112;
|
|
190
|
+
--secondary-500: 255 213 52;
|
|
191
|
+
--secondary-600: 245 196 0;
|
|
192
|
+
--secondary-700: 184 147 0;
|
|
193
|
+
--secondary-800: 122 98 0;
|
|
194
|
+
--secondary-900: 61 49 0;
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### Import variables
|
|
198
|
+
|
|
199
|
+
```js
|
|
200
|
+
const style = document.createElement("style");
|
|
201
|
+
style.innerHTML = `
|
|
202
|
+
@layer base {
|
|
203
|
+
:root {
|
|
204
|
+
${variables}
|
|
205
|
+
}
|
|
206
|
+
}`;
|
|
207
|
+
document.head.appendChild(style);
|
|
208
|
+
```
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -25,6 +25,7 @@ const defaultOptions = {
|
|
|
25
25
|
dark: "#000000",
|
|
26
26
|
},
|
|
27
27
|
steps: 100,
|
|
28
|
+
default: true,
|
|
28
29
|
};
|
|
29
30
|
const computeOptions = (options) => {
|
|
30
31
|
const computedOptions = {
|
|
@@ -40,22 +41,23 @@ const computeOptions = (options) => {
|
|
|
40
41
|
* @returns {TailwindColorsConfig} A config object for tailwindcss
|
|
41
42
|
*/
|
|
42
43
|
const generateConfig = (colorNames, options) => {
|
|
43
|
-
const { suffixMultiplier, variablePrefix, contrast, complement, steps } = computeOptions(options || {});
|
|
44
|
+
const { suffixMultiplier, variablePrefix, contrast, complement, steps, default: defaultOption, } = computeOptions(options || {});
|
|
44
45
|
const colors = Array.isArray(colorNames) ? colorNames : [colorNames];
|
|
45
46
|
const config = {};
|
|
46
47
|
colors.forEach((colorName) => {
|
|
47
|
-
const
|
|
48
|
+
const defaultColor = {
|
|
48
49
|
DEFAULT: `rgb(var(${(0, variableName_1.default)(colorName, variablePrefix)}) / <alpha-value>)`,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
50
|
+
};
|
|
51
|
+
const contrastColor = {
|
|
52
|
+
contrast: `rgb(var(${(0, variableName_1.default)(colorName, variablePrefix, "contrast")}) / <alpha-value>)`,
|
|
53
|
+
};
|
|
54
|
+
const complementColor = {
|
|
55
|
+
complement: `rgb(var(${(0, variableName_1.default)(colorName, variablePrefix, "complement")}) / <alpha-value>)`,
|
|
56
|
+
};
|
|
57
|
+
const colorTints = {
|
|
58
|
+
...(defaultOption ? defaultColor : {}),
|
|
59
|
+
...(contrast ? contrastColor : {}),
|
|
60
|
+
...(complement ? complementColor : {}),
|
|
59
61
|
};
|
|
60
62
|
shades[steps].forEach((shade) => {
|
|
61
63
|
const tintSuffix = `${shade * suffixMultiplier}`;
|
|
@@ -73,22 +75,23 @@ exports.generateConfig = generateConfig;
|
|
|
73
75
|
* @returns {string} A string of css variables
|
|
74
76
|
*/
|
|
75
77
|
const generateStyleVariables = (colorParams, options) => {
|
|
76
|
-
const { suffixMultiplier, variablePrefix, contrast, complement, classification, steps, } = computeOptions(options || {});
|
|
78
|
+
const { suffixMultiplier, variablePrefix, contrast, complement, classification, steps, default: defaultOption, } = computeOptions(options || {});
|
|
77
79
|
const colors = Array.isArray(colorParams) ? colorParams : [colorParams];
|
|
78
80
|
const styles = colors.map(({ color, name }) => {
|
|
79
81
|
const hslColor = (0, hexToHsl_1.default)(color);
|
|
80
|
-
const
|
|
82
|
+
const defaultTintColor = [
|
|
81
83
|
`${(0, variableName_1.default)(name, variablePrefix)}: ${(0, hexToRgb_1.hexToRgbString)(color)}`,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
84
|
+
];
|
|
85
|
+
const contrastTintColor = [
|
|
86
|
+
`${(0, variableName_1.default)(name, variablePrefix, "contrast")}: ${(0, chroma_1.contrast)(hslColor, classification)}`,
|
|
87
|
+
];
|
|
88
|
+
const complementTintColor = [
|
|
89
|
+
`${(0, variableName_1.default)(name, variablePrefix, "complement")}: ${(0, chroma_1.complement)(hslColor, classification)}`,
|
|
90
|
+
];
|
|
91
|
+
const tintsString = [
|
|
92
|
+
...(defaultOption ? defaultTintColor : []),
|
|
93
|
+
...(contrast ? contrastTintColor : []),
|
|
94
|
+
...(complement ? complementTintColor : []),
|
|
92
95
|
];
|
|
93
96
|
shades[steps].forEach((shade) => {
|
|
94
97
|
const tintSuffix = `${shade * suffixMultiplier}`;
|
|
@@ -116,23 +119,24 @@ exports.generateStyleVariables = generateStyleVariables;
|
|
|
116
119
|
* @returns {TailwindColorsConfig} A config object for tailwindcss
|
|
117
120
|
*/
|
|
118
121
|
const generateConfigWithColors = (colorParams, options) => {
|
|
119
|
-
const { suffixMultiplier, variablePrefix, contrast, complement, classification, steps, } = computeOptions(options || {});
|
|
122
|
+
const { suffixMultiplier, variablePrefix, contrast, complement, classification, steps, default: defaultOption, } = computeOptions(options || {});
|
|
120
123
|
const colors = Array.isArray(colorParams) ? colorParams : [colorParams];
|
|
121
124
|
const config = {};
|
|
122
125
|
colors.forEach(({ color, name }) => {
|
|
123
126
|
const hslColor = (0, hexToHsl_1.default)(color);
|
|
124
|
-
const
|
|
127
|
+
const defaultColor = {
|
|
125
128
|
DEFAULT: `rgb(${(0, hexToRgb_1.hexToRgbString)(color)} / <alpha-value>)`,
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
129
|
+
};
|
|
130
|
+
const contrastColor = {
|
|
131
|
+
contrast: `rgb(${(0, chroma_1.contrast)(hslColor, classification)} / <alpha-value>)`,
|
|
132
|
+
};
|
|
133
|
+
const complementColor = {
|
|
134
|
+
complement: `rgb(${(0, chroma_1.complement)(hslColor, classification)} / <alpha-value>)`,
|
|
135
|
+
};
|
|
136
|
+
const colorTints = {
|
|
137
|
+
...(defaultOption ? defaultColor : {}),
|
|
138
|
+
...(contrast ? contrastColor : {}),
|
|
139
|
+
...(complement ? complementColor : {}),
|
|
136
140
|
};
|
|
137
141
|
shades[steps].forEach((shade) => {
|
|
138
142
|
const tintSuffix = `${shade * suffixMultiplier}`;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,2CAKwB;AACxB,+CAAkD;AAClD,gEAAwC;AACxC,0DAAkC;AAClC,wEAAgD;AAEhD,MAAM,MAAM,GAAG;IACb,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C,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC;YAClC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC;SACvC,CAAC;QAEF,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;YAC9B,MAAM,UAAU,GAAG,GAAG,KAAK,GAAG,gBAAgB,EAAE,CAAC;YACjD,IAAI,KAAK,KAAK,CAAC,EAAE;gBACf,UAAU,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC,OAAO,CAAC;aAC7C;iBAAM,IAAI,KAAK,GAAG,CAAC,EAAE;gBACpB,IAAI,KAAK,GAAG,IAAA,eAAK,EAAC,CAAC,GAAG,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC;gBACpC,UAAU,CAAC,UAAU,CAAC,GAAG,OAAO,IAAA,gBAAO,EACrC,QAAQ,EACR,KAAK,CACN,mBAAmB,CAAC;aACtB;iBAAM;gBACL,IAAI,KAAK,GAAG,IAAA,eAAK,EAAC,GAAG,GAAG,KAAK,GAAG,GAAG,CAAC,CAAC;gBACrC,UAAU,CAAC,UAAU,CAAC,GAAG,OAAO,IAAA,eAAM,EACpC,QAAQ,EACR,KAAK,CACN,mBAAmB,CAAC;aACtB;QACH,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC;IAC5B,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAE+C,4DAAwB"}
|
package/package.json
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "tailwindcss-custom-colors",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Reactive color shades generator for TailwindCSS",
|
|
5
|
-
"author": "quentinjuarez",
|
|
6
|
-
"repository": {
|
|
7
|
-
"type": "git",
|
|
8
|
-
"url": "https://github.com/quentinjuarez/tailwindcss-custom-colors"
|
|
9
|
-
},
|
|
10
|
-
"main": "dist/index.js",
|
|
11
|
-
"files": [
|
|
12
|
-
"dist/**/*"
|
|
13
|
-
],
|
|
14
|
-
"scripts": {
|
|
15
|
-
"test": "jest",
|
|
16
|
-
"build": "tsc",
|
|
17
|
-
"patch": "yarn build && npm version patch && git push --follow-tags"
|
|
18
|
-
},
|
|
19
|
-
"keywords": [
|
|
20
|
-
"tailwind",
|
|
21
|
-
"tailwindcss",
|
|
22
|
-
"colors",
|
|
23
|
-
"palette",
|
|
24
|
-
"shades",
|
|
25
|
-
"tints"
|
|
26
|
-
],
|
|
27
|
-
"devDependencies": {
|
|
28
|
-
"@types/jest": "^29.5.3",
|
|
29
|
-
"@types/node": "^20.4.4",
|
|
30
|
-
"jest": "^29.6.1",
|
|
31
|
-
"ts-jest": "^29.1.1",
|
|
32
|
-
"typescript": "^5.1.6"
|
|
33
|
-
},
|
|
34
|
-
"license": "MIT",
|
|
35
|
-
"packageManager": "yarn@3.5.0"
|
|
36
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "tailwindcss-custom-colors",
|
|
3
|
+
"version": "1.0.13",
|
|
4
|
+
"description": "Reactive color shades generator for TailwindCSS",
|
|
5
|
+
"author": "quentinjuarez",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/quentinjuarez/tailwindcss-custom-colors"
|
|
9
|
+
},
|
|
10
|
+
"main": "dist/index.js",
|
|
11
|
+
"files": [
|
|
12
|
+
"dist/**/*"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"test": "jest",
|
|
16
|
+
"build": "tsc",
|
|
17
|
+
"patch": "yarn build && npm version patch && git push --follow-tags"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"tailwind",
|
|
21
|
+
"tailwindcss",
|
|
22
|
+
"colors",
|
|
23
|
+
"palette",
|
|
24
|
+
"shades",
|
|
25
|
+
"tints"
|
|
26
|
+
],
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/jest": "^29.5.3",
|
|
29
|
+
"@types/node": "^20.4.4",
|
|
30
|
+
"jest": "^29.6.1",
|
|
31
|
+
"ts-jest": "^29.1.1",
|
|
32
|
+
"typescript": "^5.1.6"
|
|
33
|
+
},
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"packageManager": "yarn@3.5.0"
|
|
36
|
+
}
|