blade-ui-kit / blade-icons

A package to easily make use of SVG icons in your Laravel Blade views.
https://blade-ui-kit.com/blade-icons
MIT License
2.19k stars 144 forks source link

Document usage in Vue #38

Closed basepack closed 4 years ago

basepack commented 5 years ago

Hi guys,

After some fiddling and reading these links https://calebporzio.com/using-inline-svgs-in-vue-compoments/ and https://laravel-mix.com/extensions/vue-svgicon I thought it could be easier if you just import the generated HTML into you component.

In blade view:

@php
$svgIcon = svg_image('cog', 'icon icon-lg');
@endphp

<product icon="{{$svgIcon->renderInline() }} "></product>

Please note the missing : before icon.

In Vue:

<template>
    <div v-html="icon"></div>
</template>

 export default {
        props: ['icon'],
}

Is it an idea to document this approach for Vue in the readme?

driesvints commented 4 years ago

The difference with the above and your example is that Caleb is loading in the SVG in JS while your example places the SVG inside the HTML element which would lead to invalid HTML being generated.

This is a bit out of scope of the package I'm afraid, sorry.