Skip to content

Commit 757a521

Browse files
committed
2.0.0
1 parent 6c9e5fc commit 757a521

File tree

712 files changed

+3064
-166
lines changed

Some content is hidden

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

712 files changed

+3064
-166
lines changed

.babelrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"presets": [
3+
["es2015", { "modules": false }]
4+
],
5+
"plugins": [
6+
"add-module-exports"
7+
]
8+
}

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2.0.0
2+
* Switch to Vue.js dependency to `2.0`.
3+
* Added support for users to specify used icons to reduce bundle size.
4+
* Bump major version to 2.
5+
16
0.3.0
27
* Supported registering custom icons.
38

README.md

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,16 @@
22

33
> Font Awesome component for Vue.js, using inline SVG.
44
5-
Vue-Awesome is built upon [Font Awesome](https://github.com/FortAwesome/Font-Awesome) `v4.5.0` and depends on [Vue.js](https://vuejs.org/) `v1.0.17`+.
5+
Vue-Awesome is built upon [Font Awesome](https://github.com/FortAwesome/Font-Awesome) `v4.5.0` and depends on [Vue.js](https://vuejs.org/) `v2.0.1`+.
66

77
## Installation
88

9+
### npm (**Recommended**)
10+
11+
```bash
12+
$ npm install vue-awesome
13+
```
14+
915
### manual
1016

1117
Just download `dist/vue-awesome.js` and include it in your HTML file:
@@ -14,12 +20,6 @@ Just download `dist/vue-awesome.js` and include it in your HTML file:
1420
<script src="path/to/vue-awesome/dist/vue-awesome.js"></script>
1521
```
1622

17-
### npm
18-
19-
```bash
20-
$ npm install vue-awesome
21-
```
22-
2323
### bower
2424

2525
```bash
@@ -38,16 +38,32 @@ $ bower install vue-awesome
3838
<icon name="repo-forked" label="Forked Repository"></icon>
3939
```
4040

41-
### CommonJS
41+
### ES Modules with vue-loader (**Recommended**)
4242

4343
```js
44-
var Vue = require('path/to/vue')
44+
import Vue from 'vue'
45+
import Icon from 'path/to/vue-awesome/src/components/Icon.vue'
46+
47+
// Pick one way betweem the 2 following ways
48+
49+
// only import the icons you use to reduce bundle size
50+
import 'path/to/vue-awesome/src/icons/flag'
51+
52+
// or import all icons if you don't care about bundle size
53+
import 'path/to/vue-awesome/src/icons'
54+
```
55+
56+
57+
### CommonJS with NPM
58+
59+
```js
60+
var Vue = require('vue')
4561

4662
// requiring the UMD module
47-
var Icon = require('path/to/vue-awesome/dist/vue-awesome')
63+
var Icon = require('vue-awesome')
4864

4965
// or with vue-loader you can require the src directly
50-
var Icon = require('path/to/vue-awesome/src/components/Icon.vue')
66+
var Icon = require('vue-awesome/src/components/Icon.vue')
5167

5268
// register component to use
5369
```
@@ -57,7 +73,7 @@ var Icon = require('path/to/vue-awesome/src/components/Icon.vue')
5773
```js
5874
require.config({
5975
paths: {
60-
'vue-awesome': 'path/to/vue-conticon/dist/vue-awesome'
76+
'vue-awesome': 'path/to/vue-awesome'
6177
}
6278
})
6379

@@ -79,12 +95,17 @@ $ npm run dev
7995

8096
Open `http://localhost:8080/demo` to see the demo.
8197

98+
### Updating icons
99+
100+
Don't touch files in `src/icons` but Update `assets/icons.json` instead and run `npm run icons` to re-generate icon module files.
101+
82102
## Customize
83103

84104
You can register custom icons like this:
85105

86106
```js
87-
var Icon = require('path/to/vue-awesome/src/components/Icon.vue')
107+
// ES Modules with vue-loader
108+
import Icon from 'vue-awesome/src/components/Icon.vue'
88109

89110
Icon.register({
90111
taobao: {

src/assets/icons.js renamed to assets/icons.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = {
1+
{
22
"500px": {
33
"width": 1536,
44
"height": 1792,

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-awesome",
3-
"version": "0.3.0",
3+
"version": "2.0.0",
44
"homepage": "https://github.com/Justineo/vue-awesome",
55
"authors": [
66
"Justineo <[email protected]>"

build/icon.tpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import Icon from '../components/Icon.vue'
2+
3+
Icon.register(${icon})

build/icons.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
var fs = require('fs')
2+
var path = require('path')
3+
var icons = require('../assets/icons.json')
4+
5+
var moduleTpl = fs.readFileSync(path.resolve(__dirname, './icon.tpl'), 'utf8')
6+
var ICON_PATH = path.resolve(__dirname, '../src/icons')
7+
8+
var indexModule = ''
9+
var names = Object.keys(icons)
10+
names.forEach(function (name) {
11+
var icon = {}
12+
icon[name] = icons[name]
13+
fs.writeFileSync(ICON_PATH + '/' + name + '.js', moduleTpl.replace('${icon}', JSON.stringify(icon)))
14+
indexModule += 'import \'./' + name + '\'\n'
15+
})
16+
17+
fs.writeFileSync(ICON_PATH + '/index.js', indexModule)
18+
console.log(names.length + ' icon modules generated.')

demo/Demo.vue

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,39 @@
11
<template>
2-
<figure id="logo" @mouseenter="toggle" @mouseleave="toggle" @click="change" :title="logo"><icon :name="logo" scale="4"></icon></figure>
3-
<h1><a href="https://github.com/Justineo/vue-awesome">Vue-Awesome</a></h1>
4-
<p class="desc">Font Awesome component for Vue.js, using inline SVG.</p>
5-
6-
<h2>Basic</h2>
7-
<p><icon name="flag"></icon></p>
8-
<figure><pre><code>&lt;icon <span class="attr">name</span>=<span class="val">"flag"</span>&gt;&lt;/icon&gt;</code></pre></figure>
9-
10-
<h2>Scale</h2>
11-
<p><icon name="language" scale="3"></icon></p>
12-
<figure><pre><code>&lt;icon <span class="attr">name</span>=<span class="val">"language"</span> <span class="attr">scale</span>=<span class="val">"3"</span>&gt;&lt;/icon&gt;</code></pre></figure>
13-
14-
<h2>Spin</h2>
15-
<p><icon name="refresh" spin></icon></p>
16-
<figure><pre><code>&lt;icon <span class="attr">name</span>=<span class="val">"refresh"</span> <span class="attr">spin</span>&gt;&lt;/icon&gt;</code></pre></figure>
17-
18-
<h2>Flip</h2>
19-
<p><icon name="signal" flip="horizontal"></icon></p>
20-
<figure><pre><code>&lt;icon <span class="attr">name</span>=<span class="val">"signal"</span> <span class="attr">flip</span>=<span class="val">"horizontal"</span>&gt;&lt;/icon&gt;</code></pre></figure>
21-
22-
<h2>Label</h2>
23-
<p><small>Accessible for screen readers, etc.</small></p>
24-
<p><icon name="code" label="Source Code"></icon></p>
25-
<figure><pre><code>&lt;icon <span class="attr">name</span>=<span class="val">"code"</span> <span class="attr">label</span>=<span class="val">"Source Code"</span>&gt;&lt;/icon&gt;</code></pre></figure>
26-
27-
<h2>Custom icons</h2>
28-
<p><small>You can register your own icons.</small></p>
29-
<p><icon name="taobao"></icon></p>
30-
<figure><pre><code>&lt;icon <span class="attr">name</span>=<span class="val">"taobao"</span>&gt;&lt;/icon&gt;</code></pre></figure>
31-
32-
<footer>
33-
<a href="//github.com/Justineo">@Justineo</a>|<a href="//github.com/Justineo/vue-awesome/blob/master/LICENSE">MIT License</a>|<a href="//github.com/Justineo/vue-awesome">View on GitHub</a>
34-
</footer>
2+
<main>
3+
<figure id="logo" @mouseenter="toggle" @mouseleave="toggle" @click="change" :title="logo"><icon :name="logo" scale="4"></icon></figure>
4+
<h1><a href="https://github.com/Justineo/vue-awesome">Vue-Awesome</a></h1>
5+
<p class="desc">Font Awesome component for Vue.js, using inline SVG.</p>
6+
7+
<h2>Basic</h2>
8+
<p><icon name="flag"></icon></p>
9+
<figure><pre><code>&lt;icon <span class="attr">name</span>=<span class="val">"flag"</span>&gt;&lt;/icon&gt;</code></pre></figure>
10+
11+
<h2>Scale</h2>
12+
<p><icon name="language" scale="3"></icon></p>
13+
<figure><pre><code>&lt;icon <span class="attr">name</span>=<span class="val">"language"</span> <span class="attr">scale</span>=<span class="val">"3"</span>&gt;&lt;/icon&gt;</code></pre></figure>
14+
15+
<h2>Spin</h2>
16+
<p><icon name="refresh" spin></icon></p>
17+
<figure><pre><code>&lt;icon <span class="attr">name</span>=<span class="val">"refresh"</span> <span class="attr">spin</span>&gt;&lt;/icon&gt;</code></pre></figure>
18+
19+
<h2>Flip</h2>
20+
<p><icon name="signal" flip="horizontal"></icon></p>
21+
<figure><pre><code>&lt;icon <span class="attr">name</span>=<span class="val">"signal"</span> <span class="attr">flip</span>=<span class="val">"horizontal"</span>&gt;&lt;/icon&gt;</code></pre></figure>
22+
23+
<h2>Label</h2>
24+
<p><small>Accessible for screen readers, etc.</small></p>
25+
<p><icon name="code" label="Source Code"></icon></p>
26+
<figure><pre><code>&lt;icon <span class="attr">name</span>=<span class="val">"code"</span> <span class="attr">label</span>=<span class="val">"Source Code"</span>&gt;&lt;/icon&gt;</code></pre></figure>
27+
28+
<h2>Custom icons</h2>
29+
<p><small>You can register your own icons.</small></p>
30+
<p><icon name="taobao"></icon></p>
31+
<figure><pre><code>&lt;icon <span class="attr">name</span>=<span class="val">"taobao"</span>&gt;&lt;/icon&gt;</code></pre></figure>
32+
33+
<footer>
34+
<a href="//github.com/Justineo">@Justineo</a>|<a href="//github.com/Justineo/vue-awesome/blob/master/LICENSE">MIT License</a>|<a href="//github.com/Justineo/vue-awesome">View on GitHub</a>
35+
</footer>
36+
</main>
3537
</template>
3638

3739
<style>
@@ -157,29 +159,30 @@ footer a:hover {
157159
</style>
158160

159161
<script>
160-
import icons from '../src/assets/icons';
161-
const keys = Object.keys(icons);
162+
import Icon from '../src/components/Icon.vue'
163+
import '../src/icons'
164+
const keys = Object.keys(Icon.icons);
162165
163166
function randomIcon() {
164167
return keys[Math.floor(Math.random() * keys.length)];
165168
}
166169
167170
export default {
168-
data: function () {
171+
data() {
169172
return {
170173
logo: randomIcon(),
171174
running: true
172175
}
173176
},
174177
methods: {
175-
change: function () {
178+
change() {
176179
this.logo = randomIcon()
177180
},
178181
toggle: function () {
179182
this.running = !this.running
180183
}
181184
},
182-
ready: function () {
185+
mounted() {
183186
setInterval(() => {
184187
if (this.running) {
185188
this.change()

demo/bundle.js

Lines changed: 16 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<link href="//fonts.googleapis.com/css?family=Dosis:300,500&amp;text=Vue-Awesome" rel="stylesheet">
88
</head>
99
<body>
10-
<demo></demo>
10+
<div id="demo"></div>
1111
<script src="bundle.js"></script>
1212
</body>
1313
</html>
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
var Vue = require('vue')
2-
var Demo = require('./Demo.vue')
3-
var Icon = require('../src/components/Icon.vue')
1+
import Vue from 'vue'
2+
import Demo from './Demo.vue'
3+
import Icon from '../src/components/Icon.vue'
44

55
Vue.component('icon', Icon)
66

@@ -13,8 +13,9 @@ Icon.register({
1313
})
1414

1515
new Vue({
16-
el: 'body',
16+
el: '#demo',
1717
components: {
1818
demo: Demo
19-
}
19+
},
20+
render: h => h(Demo)
2021
})

dist/vue-awesome.js

Lines changed: 14 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
{
22
"name": "vue-awesome",
3-
"version": "0.3.1",
3+
"version": "2.0.0",
44
"description": "Font Awesome component for Vue.js, using inline SVG.",
55
"main": "dist/vue-awesome.js",
66
"scripts": {
7-
"dev": "webpack-dev-server --inline --hot",
8-
"build": "webpack -p"
7+
"dev": "cross-env NODE_ENV=development webpack-dev-server --inline --hot",
8+
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules",
9+
"icons": "node build/icons.js"
910
},
1011
"keywords": [
1112
"Font Awesome",
1213
"Vue.js"
1314
],
1415
"author": "Justineo ([email protected])",
1516
"license": "MIT",
16-
"devDependencies": {
17-
"babel-core": "^6.7.2",
18-
"babel-loader": "^6.2.4",
19-
"babel-plugin-transform-runtime": "^6.6.0",
20-
"babel-preset-es2015": "^6.6.0",
21-
"babel-runtime": "^6.6.1",
22-
"css-loader": "^0.23.1",
23-
"vue-hot-reload-api": "^1.3.2",
24-
"vue-html-loader": "^1.2.0",
25-
"vue-loader": "^8.2.1",
26-
"vue-style-loader": "^1.0.0",
27-
"webpack": "^1.12.14",
28-
"webpack-dev-server": "^1.14.1"
29-
},
3017
"dependencies": {
31-
"vue": "^1.0.17"
18+
"vue": "^2.0.1"
19+
},
20+
"devDependencies": {
21+
"babel-core": "^6.17.0",
22+
"babel-loader": "^6.2.5",
23+
"babel-plugin-add-module-exports": "^0.2.1",
24+
"babel-preset-es2015": "^6.16.0",
25+
"cross-env": "^3.1.1",
26+
"css-loader": "^0.25.0",
27+
"file-loader": "^0.9.0",
28+
"vue-loader": "^9.5.1",
29+
"webpack": "2.1.0-beta.22",
30+
"webpack-dev-server": "^2.1.0-beta.8",
31+
"webpack-merge": "^0.14.1"
3232
}
3333
}

0 commit comments

Comments
 (0)