Skip to content

Commit

Permalink
Update icons
Browse files Browse the repository at this point in the history
  • Loading branch information
surunzi committed Jun 29, 2018
1 parent 2d90406 commit b97c774
Show file tree
Hide file tree
Showing 19 changed files with 190 additions and 546 deletions.
7 changes: 2 additions & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ module.exports = {
ENV: true
},
rules: {
quotes: [
'error',
'single'
]
quotes: ['error', 'single']
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"format": "prettier *.js eustia/*.js src/**/*.js src/*.js script/*.js test/*.js src/**/*.scss src/**/*.css --write",
"lint": "eslint src/**/*.js",
"setup": "node script/cpTestLib",
"genIcon": "node script/icomoon",
"genIcon": "node script/genIcon",
"genUtilDoc": "eustia doc src/lib/util.js -f md -o doc/UTIL_API.md -t \"Eruda Util Documentation\""
},
"husky": {
Expand Down
58 changes: 58 additions & 0 deletions script/genIcon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
const fs = require('fs')
const path = require('path')
const util = require('./util')

const nameMap = {
Clearsearch: 'clear',
Fill: 'error',
arrow: 'arrow-left',
right: 'arrow-right'
}

fs.readFile(path.resolve(__dirname, 'icon/iconfont.woff'), function(err, data) {
if (err) return console.log(err)

genCssFile(data.toString('base64'))
})

function genCssFile(fontData) {
fs.readFile(path.resolve(__dirname, 'icon/iconfont.css'), 'utf-8', function(
err,
data
) {
if (err) return console.log(err)

data = data.split('\n')
data.splice(
2,
5,
" src: url('data:application/x-font-woff;charset=utf-8;base64," +
fontData +
"') format('woff');"
)
data = data.join('\n')
data = data.replace(
/\.eruda-icon/g,
"[class^='eruda-icon-'],\n[class*=' eruda-icon-']"
)

util.each(nameMap, (val, key) => {
data = data.replace('icon-' + key + ':', 'icon-' + val + ':')
})

writeCssFile(data)
})
}

function writeCssFile(data) {
fs.writeFile(
path.resolve(__dirname, '../src/style/icon.css'),
data,
'utf-8',
function(err, data) {
if (err) return console.log(err)

console.log('icon.css generated!')
}
)
}
49 changes: 0 additions & 49 deletions script/icomoon.js

This file was deleted.

Loading

0 comments on commit b97c774

Please sign in to comment.