Skip to content

Commit c586545

Browse files
committed
#174 feat(material): Merge old and new tags and add tags for new ones
1 parent fea73b3 commit c586545

File tree

5 files changed

+8405
-8396
lines changed

5 files changed

+8405
-8396
lines changed

ui/build/icons/build.material-icons-base.js

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const path = require('path')
2-
const { green, blue, red } = require('kolorist')
3-
const { readFile, writeFile } = require('../utils')
2+
const {green, blue, red} = require('kolorist')
3+
const {readFile, writeFile} = require('../utils')
44

55
const themeMap = {
66
baseline: '',
@@ -9,14 +9,26 @@ const themeMap = {
99
sharp: 's_'
1010
}
1111

12-
function run (googleIcons, theme) {
12+
function run(googleIcons, theme) {
1313
const name = 'material-icons' + (theme === 'baseline' ? '' : '-' + theme)
1414
// console.log(`${blue('[building]')} ${name}...`)
1515
const inputLocation = `../../src/components/icon-set/${name}.js`
1616
const outputLocation = `../../src/components/icon-set/${name}.js`
1717
const oldIcons = {}
1818
const icons = []
1919
const blacklisted = [
20+
'grade',
21+
'grading',
22+
'dynamic_feed',
23+
'o_dynamic_feed',
24+
'r_dynamic_feed',
25+
's_dynamic_feed',
26+
's_grade',
27+
's_grading',
28+
'r_grade',
29+
'r_grading',
30+
'o_grade',
31+
'o_grading'
2032
]
2133
const whiteListed = {
2234
baseline: [
@@ -74,15 +86,15 @@ function run (googleIcons, theme) {
7486
fa.forEach(f => {
7587
const name = f.name
7688
const tags = f.tags
77-
oldIcons[name] = { tags: Array(tags).join(',') }
89+
oldIcons[name] = {tags: Array(tags).join(',')}
7890
})
7991

8092
googleIcons.forEach(gi => {
8193
gi.name = themeMap[theme] + gi.name
8294
})
8395

8496
whiteListed[theme].forEach(name => {
85-
googleIcons.push({ name: themeMap[theme] + name })
97+
googleIcons.push({name: themeMap[theme] + name})
8698
})
8799

88100
googleIcons.sort((a, b) => {
@@ -94,14 +106,22 @@ function run (googleIcons, theme) {
94106
const name = gi.name
95107
if (blacklisted.includes(name) === false) {
96108
if (oldIcons[name]) {
97-
const tags = oldIcons[name].tags.split(',').map(tag => {
98-
if (tag === '') return tag
99-
return "'" + tag + "'"
100-
}).join(', ')
101-
icons.push(`{ name: '${name}', tags: [${tags}] }`)
102-
}
103-
else {
104-
icons.push(`{ name: '${name}', tags: [] }`)
109+
110+
const oldTags = oldIcons[name].tags
111+
.split(',')
112+
113+
// Merge old and new tags
114+
const tagsWithoutDuplicates = [...new Set(oldTags.concat(gi.tags))];
115+
const newTags = tagsWithoutDuplicates
116+
.filter(tag => tag !== "")
117+
.map(tag => "'" + tag + "'")
118+
.join(', ')
119+
120+
// Add merged tags old/new
121+
icons.push(`{ name: '${name}', tags: [${newTags}] }`)
122+
} else {
123+
// Add new tags
124+
icons.push(`{ name: '${name}', tags: [${gi.tags}] }`)
105125
}
106126
}
107127
})
@@ -127,6 +147,7 @@ function run (googleIcons, theme) {
127147
output += '}\n'
128148

129149
writeFile(path.resolve(__dirname, outputLocation), output)
150+
.catch(exception => console.error(exception))
130151
console.log(`${blue('[icon]')} ${green(name + ':')} ${icons.length} generated`)
131152
}
132153

0 commit comments

Comments
 (0)