-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vue.use() options #35
Comments
Additionally, you could consider something like this to reduce duplication / potential errors in choosing and adding icons: // icons.js
export {
uniCheck,
uniCheckCircle,
uniExclamationCircle,
uniTimes,
uniTimesCircle
} from 'vue-unicons/src/icons' // plugin.js
import Unicon from 'vue-unicons'
import * as icons from './icons'
Vue.use(Unicon, {
width: 20,
height: 20,
fill: '#FF0000',
icons,
}) This would be backwards compatible with |
I support this ideia. Btw, would be awesome to define |
Funny you should mention that! I've just written this which doesn't require any setup or imports, camel-casing or prefixes, and will work with any SVG icons. Prerequisites:
<script>
export default {
functional: true,
props: {
icon: {
type: String,
required: true
},
size: {
type: [Number, String],
default: 24
},
color: {
type: String,
default: 'currentColor'
}
},
render (h, context) {
// input
const { props, data, listeners } = context
const { icon, size, color } = props
// svg
const svg = require(`!raw-loader!assets/icons/${icon}.svg`).default
const html = svg
.replace(/fill="#.+?"/g, `fill="${color}"`)
.replace(/<svg.+?>|<\/svg>/g, '')
// options
// TODO parse attributes from original SVG
const attrs = {
xmlns: 'http://www.w3.org/2000/svg',
width: size,
height: size,
viewBox: '0 0 24 24',
class: 'uiIcon',
'aria-hidden': true,
}
const domProps = {
innerHTML: html
}
// shape
return h('svg', { ...data, attrs, domProps, listeners })
}
}
</script>
<style>
.uiIcon {
pointer-events: bounding-box;
}
</style>
|
Closed because it was added in #37 |
Would be good to be able to set defaults:
The text was updated successfully, but these errors were encountered: