color-name-list 13.13.0 → 13.13.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/CONTRIBUTING.md +14 -4
- package/README.md +29 -2
- package/package.json +1 -1
- package/scripts/build.js +2 -2
package/CONTRIBUTING.md
CHANGED
|
@@ -7,17 +7,26 @@ interactions with the project.
|
|
|
7
7
|
|
|
8
8
|
## Adding colors
|
|
9
9
|
|
|
10
|
-
1. Only update the `src/colornames.csv` file and run `npm
|
|
10
|
+
1. Only update the `src/colornames.csv` file and run `npm test`.
|
|
11
11
|
2. Make sure the names you commit are not racist or offensive or a protected
|
|
12
12
|
brand name (No Facebook Blue, Coca Cola Red etc.., no nationality or tan etc..).
|
|
13
13
|
3. Read the "Rules for new color names" directly below
|
|
14
14
|
4. Make sure that neither name nor hex value of your added colors are already
|
|
15
|
-
|
|
16
|
-
5.
|
|
17
|
-
|
|
15
|
+
in use. `npm test` will test that for you.
|
|
16
|
+
5. Do not edit generated files. Do not commit changes to `README.md`,
|
|
17
|
+
`changes.svg` or anything in `dist/`.
|
|
18
|
+
6. Add the source of your colors in the Pull Request description.
|
|
19
|
+
Maintainers will update documentation if needed.
|
|
18
20
|
|
|
19
21
|
**We use automated semantic versioning** make sure to use git cz (or npm run commit).
|
|
20
22
|
|
|
23
|
+
## Generated files and CI
|
|
24
|
+
|
|
25
|
+
- PRs run `npm ci`, `npm run build`, and `npm test` in CI.
|
|
26
|
+
- CI may update `README.md` and `changes.svg` automatically and push
|
|
27
|
+
to your PR branch.
|
|
28
|
+
- Do not include generated files (`dist/`, `README.md`, `changes.svg`) in commits.
|
|
29
|
+
|
|
21
30
|
## Rules for new color names
|
|
22
31
|
|
|
23
32
|
- No duplicate names or hex values.
|
|
@@ -41,6 +50,7 @@ interactions with the project.
|
|
|
41
50
|
**feat(colors): Add fantastic new colors names.** rather then
|
|
42
51
|
feat(colors): Added new names.
|
|
43
52
|
- Make sure to run `npm run test` before committing.
|
|
53
|
+
For color name changes this is the only command you need locally.
|
|
44
54
|
|
|
45
55
|
### Attribution
|
|
46
56
|
|
package/README.md
CHANGED
|
@@ -62,7 +62,18 @@ Please review the [naming rules](CONTRIBUTING.md) before contributing!
|
|
|
62
62
|
### Contributing via Git 🫱🏽🫲🏻
|
|
63
63
|
|
|
64
64
|
To contribute via Git, edit the `src/colornames.csv` file
|
|
65
|
-
and ensure
|
|
65
|
+
and ensure tests pass locally (`npm test`).
|
|
66
|
+
|
|
67
|
+
See the full guidelines in [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
68
|
+
|
|
69
|
+
CI notes:
|
|
70
|
+
|
|
71
|
+
- Pull Requests run `npm ci`, `npm run build`, and `npm test`.
|
|
72
|
+
- CI auto-updates `README.md` and `changes.svg` if needed and pushes to your PR branch.
|
|
73
|
+
- Do not commit generated files (`dist/`, `changes.svg`).
|
|
74
|
+
- For color name changes, only submit updates to `src/colornames.csv`.
|
|
75
|
+
- No need to run `npm run build` locally; CI generates outputs.
|
|
76
|
+
- Optional locally: `npm run lint:markdown` to match CI markdown checks.
|
|
66
77
|
|
|
67
78
|
## Color Count: __29985__ 🎉
|
|
68
79
|
|
|
@@ -144,9 +155,15 @@ only on a few dependencies: [Color-Name-API](https://github.com/meodai/color-nam
|
|
|
144
155
|
|
|
145
156
|
### Usage JS ⌨
|
|
146
157
|
|
|
147
|
-
__Size Warning (1.
|
|
158
|
+
__Size Warning (1.14 MB)__: For browser usage,
|
|
148
159
|
consider the [public rest API](#api-)
|
|
149
160
|
|
|
161
|
+
#### Data Shape
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
type ColorName = { name: string; hex: string };
|
|
165
|
+
```
|
|
166
|
+
|
|
150
167
|
#### Exact Color
|
|
151
168
|
|
|
152
169
|
```javascript
|
|
@@ -159,6 +176,16 @@ let someNamedColor = colornames.find((color) => color.name === 'Eigengrau');
|
|
|
159
176
|
console.log(someColor.hex); // => #16161d
|
|
160
177
|
```
|
|
161
178
|
|
|
179
|
+
#### CommonJS
|
|
180
|
+
|
|
181
|
+
```js
|
|
182
|
+
// Returns the array directly when using CommonJS
|
|
183
|
+
const colornames = require('color-name-list');
|
|
184
|
+
|
|
185
|
+
const white = colornames.find((c) => c.hex === '#ffffff');
|
|
186
|
+
console.log(white.name); // => white
|
|
187
|
+
```
|
|
188
|
+
|
|
162
189
|
#### Closest Named Color
|
|
163
190
|
|
|
164
191
|
With 16,777,216 possible RGB colors, you may want to use a library such as
|
package/package.json
CHANGED
package/scripts/build.js
CHANGED
|
@@ -288,8 +288,8 @@ fs.writeFileSync(
|
|
|
288
288
|
`__${((colorsSrc.entries.length / (256 * 256 * 256)) * 100).toFixed(2)}%__`
|
|
289
289
|
)
|
|
290
290
|
.replace(
|
|
291
|
-
// update file size
|
|
292
|
-
/\d+(\.\d+)? MB\)__
|
|
291
|
+
// update file size (update all occurrences)
|
|
292
|
+
/\d+(\.\d+)? MB\)__+/g,
|
|
293
293
|
`${(
|
|
294
294
|
fs.statSync(path.normalize(`${baseFolder}${folderDist}${fileNameSrc}.json`)).size /
|
|
295
295
|
1024 /
|