var-colors 1.0.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.txt +21 -0
- package/README.md +74 -0
- package/package.json +31 -0
- package/scss/_config.scss +16 -0
- package/scss/_constants.scss +26 -0
- package/scss/_functions.scss +720 -0
- package/scss/_maps.scss +592 -0
- package/scss/index.scss +106 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright 2026 Mikhail Vasilev
|
|
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,74 @@
|
|
|
1
|
+
# var-colors
|
|
2
|
+
|
|
3
|
+
**var-colors** is a Sass-based utility designed to create color palettes in the **OKLCH** color space. It allows you to use a palette of preset colors and their shades, and also allows you to flexibly customize a custom palette option.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 25 calibrated **preset colors**.
|
|
8
|
+
- Up to **977 shades** of preset colors.
|
|
9
|
+
- Saturation stabilization for **dynamic temization**.
|
|
10
|
+
- **Flexible configuration** settings for preset and custom colors
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install var-colors
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Import
|
|
19
|
+
|
|
20
|
+
After installation, you can import the SCSS file into your project
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
@import var-colors
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
When imported, 154 shades of 8 colors will be created in the root rule. This is enough for 95% of projects. If the specified shades are not enough for you, you can use a flexible configuration system to create your own palette
|
|
27
|
+
|
|
28
|
+
## Configuration
|
|
29
|
+
|
|
30
|
+
The configuration allows you to set:
|
|
31
|
+
|
|
32
|
+
- Your set of preset colors (out of 25 preset colors)
|
|
33
|
+
- Lightness levels step from 25 to 500
|
|
34
|
+
- Custom set of lightness levels
|
|
35
|
+
- Saturation stabilization of preset colors shades
|
|
36
|
+
- Selecting the gamut from "srgb", "display-p3", "rec2020"
|
|
37
|
+
- Setting a prefix to avoid collisions with other libraries
|
|
38
|
+
- And of course, customizing a set of custom colors
|
|
39
|
+
|
|
40
|
+
You need to create a configuration file and import it before importing the utility.
|
|
41
|
+
|
|
42
|
+
### Configuration file example
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
$colors: (
|
|
46
|
+
"grey",
|
|
47
|
+
"indigo",
|
|
48
|
+
"rose",
|
|
49
|
+
);
|
|
50
|
+
$levels-step: 100;
|
|
51
|
+
$consistent-chroma: true;
|
|
52
|
+
$gamut: "display-p3";
|
|
53
|
+
$prefix: "mv";
|
|
54
|
+
$custom-colors: (
|
|
55
|
+
"primary": (
|
|
56
|
+
hue: 295,
|
|
57
|
+
max-chroma: 0.3,
|
|
58
|
+
max-chroma-lightness: 0.54,
|
|
59
|
+
),
|
|
60
|
+
"secondary": (
|
|
61
|
+
hue: "grey"
|
|
62
|
+
),
|
|
63
|
+
"danger": (
|
|
64
|
+
hue: "red"
|
|
65
|
+
)
|
|
66
|
+
)
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Import example
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
@import configuration.scss
|
|
73
|
+
@import var-colors
|
|
74
|
+
```
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "var-colors",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Sass utility to generate scalable OKLCH color palettes with CSS Custom Properties.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"sass",
|
|
7
|
+
"scss",
|
|
8
|
+
"color",
|
|
9
|
+
"palette",
|
|
10
|
+
"oklch",
|
|
11
|
+
"design-system",
|
|
12
|
+
"css-variables"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://github.com/Archinsk/var-colors#readme",
|
|
15
|
+
"author": "Mikhail Vasilev",
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/Archinsk/var-colors.git"
|
|
20
|
+
},
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/Archinsk/var-colors/issues"
|
|
23
|
+
},
|
|
24
|
+
"main": "scss/index.scss",
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"sass": "^1.70.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"sass": "^1.70.0"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
$colors: (
|
|
2
|
+
"grey",
|
|
3
|
+
"red",
|
|
4
|
+
"orange",
|
|
5
|
+
"yellow",
|
|
6
|
+
"green",
|
|
7
|
+
"cyan",
|
|
8
|
+
"blue",
|
|
9
|
+
"violet"
|
|
10
|
+
) !default;
|
|
11
|
+
$levels: () !default;
|
|
12
|
+
$levels-step: 50 !default;
|
|
13
|
+
$consistent-chroma: false !default;
|
|
14
|
+
$gamut: "srgb" !default;
|
|
15
|
+
$prefix: null !default;
|
|
16
|
+
$custom-colors: () !default;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
@use "sass:math";
|
|
2
|
+
@use "sass:list";
|
|
3
|
+
@use "sass:map";
|
|
4
|
+
|
|
5
|
+
$root-rule: true !default;
|
|
6
|
+
$default-max-chroma: 0.3;
|
|
7
|
+
$default-max-chroma-lightness: 0.75;
|
|
8
|
+
$min-levels-step: 25;
|
|
9
|
+
$steps-total: math.div(1000, $min-levels-step);
|
|
10
|
+
$darkest-levels-lightness-map: (
|
|
11
|
+
925: 0.2029,
|
|
12
|
+
950: 0.1757,
|
|
13
|
+
975: 0.1398,
|
|
14
|
+
);
|
|
15
|
+
$darkest-levels: map.keys($darkest-levels-lightness-map);
|
|
16
|
+
$regular-levels: $steps-total - list.length($darkest-levels);
|
|
17
|
+
$regular-levels-lightness-step: math.div(
|
|
18
|
+
1 - map.get($darkest-levels-lightness-map, 925),
|
|
19
|
+
$regular-levels
|
|
20
|
+
);
|
|
21
|
+
$base-palette: (
|
|
22
|
+
"white": oklch(1 0 none),
|
|
23
|
+
"black": oklch(0 0 none),
|
|
24
|
+
);
|
|
25
|
+
$valid-levels-steps: (25, 50, 100, 125, 200, 250, 500);
|
|
26
|
+
$valid-gamuts: ("srgb", "display-p3", "rec2020");
|