@rokkit/icons 1.0.0-next.11
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/LICENCE.md +22 -0
- package/README.md +1 -0
- package/package.json +37 -0
- package/src/convert.js +59 -0
- package/src/index.js +6 -0
package/LICENCE.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Pictogrammers Free License
|
|
2
|
+
|
|
3
|
+
This icon collection is released as free, open source, and GPL friendly by
|
|
4
|
+
the [Pictogrammers](http://pictogrammers.com/) icon group. You may use it
|
|
5
|
+
for commercial projects, open source projects, or anything really.
|
|
6
|
+
|
|
7
|
+
## Icons: [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0)
|
|
8
|
+
|
|
9
|
+
Some of the icons are redistributed under the Apache 2.0 license. All other
|
|
10
|
+
icons are either redistributed under their respective licenses or are
|
|
11
|
+
distributed under the Apache 2.0 license.
|
|
12
|
+
|
|
13
|
+
## Fonts: [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0)
|
|
14
|
+
|
|
15
|
+
All web and desktop fonts are distributed under the Apache 2.0 license. Web
|
|
16
|
+
and desktop fonts contain some icons that are redistributed under the Apache
|
|
17
|
+
2.0 license. All other icons are either redistributed under their respective
|
|
18
|
+
licenses or are distributed under the Apache 2.0 license.
|
|
19
|
+
|
|
20
|
+
## Code: [MIT](https://opensource.org/licenses/MIT)
|
|
21
|
+
|
|
22
|
+
The MIT license applies to all non-font and non-icon files.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Icons
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rokkit/icons",
|
|
3
|
+
"version": "1.0.0-next.11",
|
|
4
|
+
"description": "A minimal icon set for use in applications.",
|
|
5
|
+
"author": "Jerry Thomas <me@jerrythomas.name>",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"bin": "src/index.js",
|
|
8
|
+
"main": "src/index.js",
|
|
9
|
+
"module": "src/index.js",
|
|
10
|
+
"type": "module",
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@mdi/svg": "^7.1.96"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@iconify/tools": "2.2.1",
|
|
19
|
+
"@iconify/types": "^2.0.0",
|
|
20
|
+
"iconify": "^1.4.0"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"src/**/*.js",
|
|
24
|
+
"!src/**/*.spec.js"
|
|
25
|
+
],
|
|
26
|
+
"exports": {
|
|
27
|
+
"./lib": "./lib",
|
|
28
|
+
"./package.json": "./package.json",
|
|
29
|
+
"./states.json": "./lib/states.json",
|
|
30
|
+
"./components.json": "./lib/components.json",
|
|
31
|
+
"./auth.json": "./lib/auth.json",
|
|
32
|
+
".": "./lib/states.json"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "node src/index.js"
|
|
36
|
+
}
|
|
37
|
+
}
|
package/src/convert.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import {
|
|
2
|
+
importDirectory,
|
|
3
|
+
cleanupSVG,
|
|
4
|
+
runSVGO,
|
|
5
|
+
parseColors,
|
|
6
|
+
isEmptyColor
|
|
7
|
+
} from '@iconify/tools'
|
|
8
|
+
import fs from 'fs'
|
|
9
|
+
|
|
10
|
+
export async function convert(folder, prefix, color = false) {
|
|
11
|
+
// Import icons
|
|
12
|
+
const iconSet = await importDirectory(folder, {
|
|
13
|
+
prefix
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
// Validate, clean up, fix palette and optimise
|
|
17
|
+
await iconSet.forEach(async (name, type) => {
|
|
18
|
+
if (type !== 'icon') {
|
|
19
|
+
return
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const svg = iconSet.toSVG(name)
|
|
23
|
+
if (!svg) {
|
|
24
|
+
// Invalid icon
|
|
25
|
+
iconSet.remove(name)
|
|
26
|
+
return
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Clean up and optimise icons
|
|
30
|
+
try {
|
|
31
|
+
// Clean up icon code
|
|
32
|
+
await cleanupSVG(svg)
|
|
33
|
+
|
|
34
|
+
if (!color) {
|
|
35
|
+
await parseColors(svg, {
|
|
36
|
+
defaultColor: 'currentColor',
|
|
37
|
+
callback: (attr, colorStr, color) => {
|
|
38
|
+
return !color || isEmptyColor(color) ? colorStr : 'currentColor'
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Optimise
|
|
44
|
+
await runSVGO(svg)
|
|
45
|
+
} catch (err) {
|
|
46
|
+
// Invalid icon
|
|
47
|
+
console.error(`Error parsing ${name}:`, err)
|
|
48
|
+
iconSet.remove(name)
|
|
49
|
+
return
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Update icon
|
|
53
|
+
iconSet.fromSVG(name, svg)
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
// Export
|
|
57
|
+
const collection = JSON.stringify(iconSet.export(), null, 2)
|
|
58
|
+
fs.writeFileSync(`./lib/${prefix}.json`, collection, 'utf8')
|
|
59
|
+
}
|