• Stars
    star
    125
  • Rank 286,335 (Top 6 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 9 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Octicon component for Vue.js, using inline SVG.

Vue-Octicon

Octicon component for Vue.js, using inline SVG.

Vue-Octicon is built upon Octicons v5.0.1 and depends on Vue.js v2.0.1+.

Installation

NPM (Recommended)

$ npm install vue-octicon

bower

$ bower install vue-octicon

manual

Just download dist/vue-octicon.js and include it in your HTML file:

<script src="path/to/vue-octicon/dist/vue-octicon.js"></script>

Usage

<!-- basic -->
<octicon name="repo"></octicon>

<!-- with options -->
<octicon name="sync" scale="2" spin></octicon>
<octicon name="comment" flip="horizontal"></octicon>
<octicon name="repo-forked" label="Forked Repository"></octicon>

ES Modules with NPM & vue-loader (Recommended)

import Vue from 'vue'
import Octicon from 'vue-octicon/components/Octicon.vue'

// Pick one way betweem the 2 following ways

// only import the icons you use to reduce bundle size
import 'vue-octicon/icons/repo'

// or import all icons if you don't care about bundle size
import 'vue-octicon/icons'

Heads up

if you are using vue-cli to create your project, the webpack template may exclude node_modules from files to be transpiled by Babel. Change the exclude value from /node_modules/ to /node_modules(?![\\/]vue-octicon[\\/])/ to fix the problem.**

CommonJS with NPM without ES Next support

var Vue = require('vue')

// requiring the UMD module
var Octicon = require('vue-octicon')

// or with vue-loader you can require the src directly
var Octicon = require('vue-octicon/components/Octicon.vue')

// register component to use

AMD

require.config({
  paths: {
    'vue-octicon': 'path/to/vue-octicon'
  }
})

require(['vue-octicon'], function (Octicon) {
  // register component to use...
})

Global variable

The component class is exposed as window.VueOcticon.

Local development

$ npm i
$ npm run dev

Open http://localhost:8080/demo to see the demo.

Updating icons

Don't touch files in src/icons but update assets/icons.json instead and run npm run icons to re-generate icon module files.

Registering custom icons

You can register custom icons like this:

// ES Modules with vue-loader
import Octicon from 'vue-octicon/src/components/Octicon.vue'

Octicon.register({
  taobao: {
    width: 16,
    height: 12.268,
    d: 'M2.786,2.795 C3.580,2.795 4.223,2.223 4.223,1.509 C4.223,0.804 3.580,0.223 2.786,0.223 C1.991,0.223 1.348,0.804 1.348,1.509 C1.348,2.223 1.991,2.795 2.786,2.795 L2.786,2.795 Z M1.589,3.321 L0.688,4.705 L2.357,5.750 C2.357,5.750 3.473,6.313 2.946,7.384 C2.446,8.393 0.018,10.607 0.018,10.607 L2.196,11.964 C3.696,8.696 3.607,9.134 3.982,7.955 C4.366,6.759 4.455,5.839 3.795,5.179 C2.946,4.330 2.848,4.250 1.589,3.321 L1.589,3.321 Z M15.714,2.955 C15.714,2.955 15.250,-0.723 7.196,1.554 C7.536,0.955 7.705,0.563 7.705,0.563 L5.696,0.000 C5.696,0.000 4.884,2.643 3.438,3.884 C3.438,3.884 4.839,4.688 4.821,4.661 C5.223,4.268 5.580,3.857 5.893,3.464 C6.214,3.321 6.527,3.188 6.830,3.063 C6.455,3.741 5.857,4.741 5.250,5.375 L6.098,6.116 C6.098,6.116 6.679,5.554 7.313,4.884 L8.027,4.884 L8.027,6.125 L5.223,6.125 L5.223,7.107 L8.027,7.107 L8.027,9.482 C7.991,9.473 7.955,9.473 7.920,9.473 C7.616,9.455 7.125,9.411 6.946,9.107 C6.714,8.750 6.884,8.080 6.893,7.670 L4.955,7.670 L4.884,7.705 C4.884,7.705 4.179,10.884 6.938,10.813 C9.509,10.884 10.991,10.098 11.696,9.554 L11.982,10.607 L13.571,9.946 L12.491,7.313 L11.205,7.705 L11.446,8.616 C11.116,8.857 10.732,9.045 10.321,9.179 L10.321,7.107 L13.054,7.107 L13.054,6.125 L10.321,6.125 L10.321,4.884 L13.071,4.884 L13.071,3.902 L8.188,3.902 C8.536,3.473 8.813,3.080 8.893,2.830 L8.036,2.598 C11.688,1.295 13.723,1.518 13.705,3.661 L13.705,9.304 C13.705,9.304 13.920,11.241 11.696,11.107 L10.500,10.848 L10.214,11.991 C10.214,11.991 15.402,13.464 15.821,9.482 C16.250,5.491 15.714,2.955 15.714,2.955 L15.714,2.955 Z'
  }
})

Related projects

More Repositories

1

vue-awesome

Awesome SVG icon component for Vue.js, built-in with Font Awesome icons.
JavaScript
2,422
star
2

github-hovercard

Neat hovercards for GitHub.
JavaScript
1,823
star
3

coplay

Synchronizing video play between two peers.
JavaScript
772
star
4

vue-clamp

Clamping multiline text with ease.
Vue
697
star
5

resize-detector

Element resize detection.
JavaScript
156
star
6

kolor

Color manipulation in sexy syntax.
JavaScript
94
star
7

slideshows

My slideshows about techical stuff.
HTML
79
star
8

lucky

A dead simple raffle app.
JavaScript
65
star
9

make-github-greater

Let's make GitHub greater.
JavaScript
57
star
10

makedown

Enable Markdown editing on Zhihu. / 在知乎上使用 Markdown 进行创作。
JavaScript
48
star
11

highlightable-input

A light-weight highlightable input.
TypeScript
38
star
12

fi

A snippet for inspecting font-family usage in a webpage.
JavaScript
34
star
13

color-converters

Tiny modular color converters.
TypeScript
23
star
14

clone-element

Clone HTML elements with styles.
TypeScript
21
star
15

postcss-discard-overridden

PostCSS plugin to discard overridden keyframes or counter-style.
JavaScript
16
star
16

postcss-sort-style-rules

PostCSS plugin to sort style rules according to selector specificity.
JavaScript
12
star
17

vue-directive-normalizer

Normalizing directive binding into an option bag.
JavaScript
11
star
18

vue-coupled

Create coupled parent-child component pairs with composition API.
TypeScript
10
star
19

vue-awesome-material-icons

Material icons for Vue-Awesome.
JavaScript
9
star
20

vue-void

A void Vue component to override a (scoped) slot with nothing.
JavaScript
8
star
21

triangle.less

Handy Less mixin for creating CSS triangles.
CSS
7
star
22

w3c-userstyle

Highly opinionated user stylesheet for W3C specifications.
6
star
23

zhihu-insight

在知乎问题页添加已有回答的索引,方便浏览热门问题。
JavaScript
5
star
24

spotlight

A simplest finder.
JavaScript
5
star
25

veui-theme-spectre

Spectre.css based theme for VEUI.
Vue
4
star
26

esm-pkg

Find all dependent packages with an ESM output.
JavaScript
4
star
27

short-circuit-loader

Short circuit specified side-effect-only modules for webpack.
JavaScript
4
star
28

justineo.github.io

HTML
3
star
29

v-html-svg

Manual test case for v-html support for SVG in Vue.js.
HTML
3
star
30

singles

3
star
31

npmmirror-sync

Triggers sync on npmmirror.com.
TypeScript
2
star
32

nuxt-generate-bug

A reproduction for nuxt/nuxt.js#4562
Vue
1
star
33

simpledark

Automatically exported from code.google.com/p/simpledark
PHP
1
star
34

babel-plugin-import-peer

Import peer dependencies for component modules with ease.
JavaScript
1
star
35

vscode-dls

Baidu DSL tooling for VS Code.
TypeScript
1
star
36

draw

Lucky draw for SSG.
JavaScript
1
star
37

vue-esnext-in-template

A minimal repro for vuejs/vue/#6307.
JavaScript
1
star
38

drag

Super compatible draggable implementation.
JavaScript
1
star