antonreshetov / vue-unicons

1000+ Pixel-perfect svg icons for your next project as Vue components
https://antonreshetov.github.io/vue-unicons/
MIT License
1k stars 56 forks source link

Remove 'uni' prefix and make icon names camel case #33

Closed davestewart closed 4 years ago

davestewart commented 4 years ago

Hey,

Looks like a great lib! Just about to switch to Unicons and up this pops.

I don't see the point of the uni prefix. I suspect most people will move their setup to a plugin file (you have to in Nuxt by default) so this just seems like extra code.

Additionally, if both the imports and the names were camelCase, it would make it much easier to copy / paste icon names as they are needed:

import { checkCircle } from 'vue-unicons/src/icons'

Unicon.add([ checkCircle ])
<unicon name="checkCircle"/>

Looking forward to using.

:D

davestewart commented 4 years ago

If you don't want to do the camel-casing, it turns out it's pretty simple to optimize the declarations with an interim functional component:

Vue.component('icon', {
  functional: true,

  props: {
    name: {
      type: String,
      required: true,
    },

    size: {
      type: [Number, String],
      default: 12,
    },

    fill: {
      type: String,
      default: '#8795a1'
    }
  },

  render (h, context) {
    const { name, size, fill } = context.props
    const props = {
      name: name.replace(/([a-z])([A-Z])/g, (match, a, b) => a + '-' + b.toLowerCase()),
      width: size,
      height: size,
      fill: fill,
    }
    return h('unicon', { props })
  }
})
antonreshetov commented 4 years ago

Duplicate #20

atilkan commented 2 years ago

Export is not reserved. @antonreshetov