Skip to content

Commit 707dfee

Browse files
author
Irfan Maulana
committed
v2.0.0 move to Ionicons branch 4.0
1 parent 4070c17 commit 707dfee

File tree

1,343 files changed

+48725
-31039
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,343 files changed

+48725
-31039
lines changed

.gitmodules

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[submodule "ionicons"]
22
path = ionicons
3-
# url = git@github.com:ionic-team/ionicons.git
4-
url = https://github.com:ionic-team/ionicons.git
3+
url = git@github.com:ionic-team/ionicons.git
4+
# url = https://github.com:ionic-team/ionicons.git
5+
branch = 4.0

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
Design icons sourced from the
88
[Ionicons](https://github.com/ionic-team/ionicons) project.
99

10+
> Warning!!! Vue-Ionicons v2.0.0 we will move to ionicons branch [4.0](https://github.com/ionic-team/ionicons/tree/4.0) for better icons naming
11+
1012
## 🎉 Demo
1113

1214
https://mazipan.github.io/vue-ionicons
@@ -60,7 +62,7 @@ https://mazipan.github.io/vue-ionicons
6062
<AlertIcon />
6163
```
6264

63-
1. You can add props for height and width icon
65+
1. You can add props
6466

6567
```html
6668
<AlertIcon w="30px" h="30px"/>
@@ -75,7 +77,7 @@ Checkout with submodule :
7577
```bash
7678
git clone git@github.com:mazipan/vue-ionicons.git
7779
git submodule init
78-
git submodule update
80+
git submodule update --remote
7981
```
8082

8183
Run demo

demo/App.vue

Lines changed: 3361 additions & 3562 deletions
Large diffs are not rendered by default.

dist.js

Lines changed: 60 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const ora = require('ora')
77
const SVGO = require('svgo/lib/svgo')
88

99
const dist = path.resolve(__dirname, 'dist')
10-
const svgPath = path.resolve(__dirname, 'ionicons/src')
10+
const svgPath = path.resolve(__dirname, 'ionicons/src/svg')
1111

1212
const svgs = fs.readdirSync(svgPath)
1313
const svgo = new SVGO()
@@ -21,59 +21,77 @@ shell.config.silent = false
2121
shell.rm('-rf', dist)
2222
shell.rm('-rf', path.resolve(__dirname, 'demo/dist'))
2323

24+
shell.exec(`svgo ${svgPath}/*.svg`, {silent:true});
25+
2426
const getSVGString = (svg) => {
2527
return new Promise((resolve, reject) => {
28+
2629
let filepath = path.join(svgPath, svg)
27-
fs.readFile(filepath, { encoding: 'utf8'}, (err, stream) => {
28-
svgo.optimize(stream, { path: filepath })
29-
.then(function(result) {
30-
resolve(result.data);
31-
})
30+
console.log(chalk.yellow(`proccess ${svg}...`))
31+
fs.readFile(filepath, { encoding: 'utf8' }, (err, stream) => {
32+
try {
33+
let newStream = sanitizeSVG(stream)
34+
resolve(newStream)
35+
} catch (error) {
36+
reject(newStream)
37+
}
3238
})
3339
})
3440
}
3541

36-
const makeHumanReadable = (name) => {
37-
let array = name.split('-')
38-
let tempArray = array.map(elm => {
39-
return elm.charAt(0).toUpperCase() + elm.slice(1)
40-
})
41-
return tempArray.join(' ')
42-
}
43-
4442
const sanitizeSVG = (stream) => {
43+
4544
let newStream = stream
45+
.replace('<?xml version="1.0" encoding="utf-8"?>', '')
46+
.replace('<!-- Generator: Adobe Illustrator 16.2.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->', '')
47+
.replace('<!-- Generator: Adobe Illustrator 18.1.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->', '')
48+
.replace('<!-- Generator: Adobe Illustrator 22.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->', '')
4649
.replace(' xmlns="http://www.w3.org/2000/svg"', '')
47-
.replace('width=', ':width=')
48-
.replace('height=', ':height=')
49-
.replace('512', 'w')
50-
.replace('512', 'h')
5150
.replace('<style>.st0{fill:#010101}</style>', '')
5251
.replace('<style>', '<data-style>')
5352
.replace('</style>', '</data-style>')
54-
.replace('<svg', '<svg viewBox="0 0 512 512" class="ion__svg"')
53+
.replace('width="512" height="512"', '')
54+
.replace('<svg', '<svg :width="w" :height="h" class="ion__svg"')
55+
56+
if (newStream.indexOf('viewBox="0 0 512 512"') < 0){
57+
newStream = newStream.replace('<svg', '<svg viewBox="0 0 512 512" ')
58+
}
5559

5660
return newStream
5761
}
5862

63+
const makeHumanReadable = (name) => {
64+
let array = name.split('-')
65+
let tempArray = array.map(elm => {
66+
return elm.charAt(0).toUpperCase() + elm.slice(1)
67+
})
68+
return tempArray.join(' ')
69+
}
70+
5971
const generateTemplateData = () => {
6072
let templateData = [];
6173
let promises = svgs.map(svgPath => {
62-
let name = svgPath.slice(0, -4)
63-
let readableName = makeHumanReadable(name)
64-
let libraryName = readableName.split(' ').join('')
65-
66-
return new Promise((resolve, reject) => {
67-
getSVGString(svgPath).then((result) => {
68-
templateData.push({
69-
name: name,
70-
readableName: readableName,
71-
libraryName: libraryName + 'Icon',
72-
svg: sanitizeSVG(result)
74+
if (svgPath.indexOf('.svg') >= 0) {
75+
return new Promise((resolve, reject) => {
76+
getSVGString(svgPath).then((result) => {
77+
try {
78+
let name = svgPath.slice(0, -4)
79+
let readableName = makeHumanReadable(name)
80+
let libraryName = readableName.split(' ').join('')
81+
82+
templateData.push({
83+
name: name,
84+
readableName: readableName,
85+
libraryName: libraryName + 'Icon',
86+
svg: result
87+
})
88+
resolve(templateData);
89+
} catch (error) {
90+
reject(templateData)
91+
}
7392
})
74-
resolve(templateData);
7593
})
76-
})
94+
}
7795
})
7896

7997
return new Promise((resolve, reject) => {
@@ -85,12 +103,12 @@ const generateTemplateData = () => {
85103

86104
const generateBuildFile = (template, extension, templateData) => {
87105
return new Promise((resolve, reject) => {
88-
fs.readFile(template, { encoding: 'utf8'}, (err, componentFile) => {
106+
fs.readFile(template, { encoding: 'utf8' }, (err, componentFile) => {
89107
for (data of templateData) {
90108
let component = mustache.render(componentFile, data)
91109
let filename = data.name + "." + extension
92110
fs.writeFile(path.resolve(dist, filename), component, (err) => {
93-
if(err) {
111+
if (err) {
94112
reject(err)
95113
}
96114
resolve()
@@ -105,7 +123,7 @@ const generatePluginFile = (template, templateData) => {
105123
spinner.stop()
106124
console.log(chalk.yellow('Generating plugin file...'))
107125
spinner.start()
108-
fs.readFile(template, { encoding: 'utf8'}, (err, componentFile) => {
126+
fs.readFile(template, { encoding: 'utf8' }, (err, componentFile) => {
109127
let data = {
110128
data: []
111129
};
@@ -114,7 +132,7 @@ const generatePluginFile = (template, templateData) => {
114132
let component = mustache.render(componentFile, data)
115133
let filename = "ionicons.js"
116134
fs.writeFile(path.resolve(dist, filename), component, (err) => {
117-
if(err) {
135+
if (err) {
118136
reject(err)
119137
}
120138
spinner.stop()
@@ -131,7 +149,7 @@ const generateDemoAppFile = (template, templateData) => {
131149
spinner.stop()
132150
console.log(chalk.yellow('Generating demo App.vue file...'))
133151
spinner.start()
134-
fs.readFile(template, { encoding: 'utf8'}, (err, componentFile) => {
152+
fs.readFile(template, { encoding: 'utf8' }, (err, componentFile) => {
135153
let data = {
136154
data: []
137155
};
@@ -140,7 +158,7 @@ const generateDemoAppFile = (template, templateData) => {
140158
let component = mustache.render(componentFile, data)
141159
let filename = "App.vue"
142160
fs.writeFile(path.resolve('demo', filename), component, (err) => {
143-
if(err) {
161+
if (err) {
144162
reject(err)
145163
}
146164
spinner.stop()
@@ -158,7 +176,7 @@ const generateVersionFile = () => {
158176
spinner.start()
159177
return new Promise((resolve, reject) => {
160178
fs.writeFile(path.resolve('dist', `VERSION-${VERSION}`), `VERSION: ${VERSION}`, (err) => {
161-
if(err) {
179+
if (err) {
162180
reject(err)
163181
}
164182
spinner.stop()
@@ -186,5 +204,8 @@ generateTemplateData().then((templateData) => {
186204
]).then(() => {
187205
spinner.stop()
188206
console.log(chalk.green('Build completed: ' + templateData.length + ' icons'))
207+
}).catch(() => {
208+
spinner.stop()
209+
console.log(chalk.red('Error when build templateData'))
189210
})
190211
})

dist/VERSION-1.1.4

Lines changed: 0 additions & 1 deletion
This file was deleted.

dist/VERSION-2.0.0

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
VERSION: 2.0.0

dist/alert-circled.vue

Lines changed: 0 additions & 40 deletions
This file was deleted.

dist/alert.vue

Lines changed: 0 additions & 40 deletions
This file was deleted.

dist/android-add-circle.vue

Lines changed: 0 additions & 40 deletions
This file was deleted.

dist/android-add.vue

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)