Code Monkey home page Code Monkey logo

vue-icon's Introduction

vue-icon

https://img.shields.io/npm/v/vue-icon.svg https://img.shields.io/npm/dm/vue-icon.svg https://img.shields.io/npm/l/vue-icon.svg

vue2 svg icon component

Maybe it is the smallest vue component library that contains all the feather icons

Icons

https://qinshenxue.github.io/vue-icon/

Usage

using npm

$ npm install vue-icon

The default component name is icon, you can specify a new component name with Vue.use(plugin,customName).

import Vue from 'vue';
import App from './app.vue';
import feather from 'vue-icon'
Vue.use(feather, 'v-icon')
new Vue({
    el: '#app',
    render: h => h(App)
});

Or configure an object to change the name and the default icon class.

Vue.use(feather, {
    name: 'v-icon',
    props: {
        baseClass: {
            type: String,
            default: 'v-icon'
        },
        classPrefix: {
            type: String,
            default: 'v-icon-'
        }
    }
})
// or
Vue.use(feather, {
    name: 'v-icon',
    data(){
        return {
            baseClass: 'v-icon',
            classPrefix: 'v-icon-'
        }
    }
})

The configured objects are treated as mixins, so you can define it like normal Vue instance objects.

using in .vue file

<template>
    <div>
        <v-icon name="eye"></v-icon>
        <v-icon name="x"></v-icon>
        <custom-icon name="activity" base-class="custom-icon"></custom-icon>
    </div>
</template>

<script>
    import customIcon from 'vue-icon/lib/vue-feather.esm'
    export default{
        components: {
            customIcon
        },
        data: function () {
            return {
                baseClass: 'v-icon'
            }
        }
    }
</script>
<style>
    .v-icon,
    .custom-icon {
        width: 24px;
    }
</style>

Or using script tag

<script type="text/javascript" src="vue.js"></script>
<script type="text/javascript" src="https://unpkg.com/vue-icon/lib/vue-feather.min.js"></script>

<!-- component name is icon by default -->
<icon name="close"></icon>

Icon Style

Components don't contain any style definitions, you can define styles based on baseClass:'icon' and classPrefix:'icon-'.

.icon{
    color:#666
}
.icon:hover{
    color:#000
}
.icon-close{
	color:red
}

Component Attributes

Attribute Description Type Default
name The name of icon string --
base-class icon base class string icon
class-prefix icon class prefix string icon-

Changelog

Detailed changes for each release are documented in the release notes.

vue-icon's People

Contributors

qinshenxue avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

vue-icon's Issues

Where is the "?"

Really awesome looking icons, but.... where is the question icon?

'Unexpected token export' error when using vue-icon in Jest unit testing

Version

2.0.0

Steps to reproduce

<v-icon v-if="item.icon" v-bind:name="item.icon"></v-icon>
  • Running the following test:
import Vue from 'vue'
import { mount } from '@vue/test-utils'

import router from '@/router'
import VueI18n from 'vue-i18n'
import Vuelidate from 'vuelidate'
import BootstrapVue from 'bootstrap-vue'
import feather from 'vue-icon'

import DropdownIcon from '@/components/molecules/DropdownIcon'

describe('DropdownIcon', () => {

    const wrapper = mount(DropdownIcon)
    const vm = wrapper.vm

    it('should be a Vue instance', () => {
        expect(wrapper.isVueInstance()).toBeTruthy()
    })

})

What is expected

vue-icon is imported and used in component - so component can be tested correctly.

What is actually happening

 FAIL  test\unit\specs\DropdownIcon.spec.js
  โ— Test suite failed to run

    C:\Users\User\Development\project_name\node_modules\vue-icon\lib\vue-feather-plugin.esm.js:133
    export default install;
    ^^^^^^

    SyntaxError: Unexpected token export

       6 | import Vuelidate from 'vuelidate'
       7 | import BootstrapVue from 'bootstrap-vue'
    >  8 | import feather from 'vue-icon'
       9 |
      10 | import DropdownIcon from '@/components/molecules/DropdownIcon'
      11 |

      at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:316:17)
      at Object.<anonymous> (test/unit/specs/DropdownIcon.spec.js:8:16)

Other information

When I run npm run dev the code compiles and builds out correctly, and vue-icon works as intended.
I only get this problem when I run npm run unit.

My other tests on components which don't use vue-icon work as intended. I believe this has something to do with vue-icon using uncompiled ES6 code? Please correct me if I'm wrong.

Thank you for your time!

Your demo website is broken

Hi there. I was looking for relevant icons for my VR/WebXR section of the website,
and noticed that your website is no more working properly

https://qinshenxue.github.io/vue-icon/

Failed to load resource: the server responded with a status of 404 () (index):1539 Uncaught ReferenceError: Vue is not defined at (index):1539:5

Missing icons

There have been a few new icons added since this repo was created, is it possible to add the new ones?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.