npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

laravel-mix-vue-svgicon

v3.0.1

Published

Laravel Mix extension that provides loading svgs as a vue component named icon, compatible with Adam Wathan's Blade extension.

Downloads

45

Readme

laravel-mix-vue-svgicon

Laravel Mix extension that provides loading svgs as a vue component named icon, compatible with Adam Wathan's Blade extension. This package is inspired by the post by Caleb Porzio - Using inline SVGs in Vue components.

Installation

npm install laravel-mix-vue-svgicon

Setup

In your webpack.mix.js to the top of the file, add: require('laravel-mix-vue-svgicon'); .

Then in your mix method chain add: .svgicon('your path here').

If you do not provide a path to the method, the default path is ./../public/resources/svg to provide compatability with Adam Wathan's Blade SVG package.

Note the path that .svgicon() takes is relative to the root directory where your webpack.mix.js file resides. If your path is incorrect then the extension will not work and webpack will throw an error that it cannot load the module SVGPATH.

Usage

Default

Once you have the package installed and the mix extension active you may use the icon component like anyother vue.js component. The sole property that the component takes is the name of the file under the svg directory you provided to the mix method. E.g., file is resources/svg/close.svg, webpack.mix.js includes mix.svgicon(resources/svg) and the consuming vue component looks like this:

<template>
    <div class="w-1/4 flex flex-row justify-end" v-tooltip.right-start="{content: 'Cancel', classes: 'tooltip'}">
        <button class="text-black hover:text-white w-6 h-6 p-1 rounded hover:bg-red-dark" v-on:click.stop="cancel">
            <icon icon="close" class="w-full fill-current stroke-current"></icon>               
        </button>
    </div>
</template>
<script>

import Icon from 'laravel-mix-vue-svgicon/IconComponent.vue';

export default {
    props: [
        'route'
    ],
    data: function() {
        return {
        
        }
    },
    methods:{
        cancel: function(event) {
            var vm = this;
            window.location.href = vm.route;
        }
    },
    components: {
        Icon,
    }
}
</script>

Additional Child Directories

Additionally, nested folders of svg's under the svg root directory provided to the mix method can be accessed by simply giving the component the relative path & file name, minus the file extension. E.g., the resources/svg folder contains a folder zondicons.

<template>
    <div class="w-1/4 flex flex-row justify-end" v-tooltip.right-start="{content: 'Cancel', classes: 'tooltip'}">
        <button class="text-black hover:text-white w-6 h-6 p-1 rounded hover:bg-red-dark" v-on:click.stop="cancel">
            <icon icon="zondicons/close" class="w-full fill-current stroke-current"></icon>               
        </button>
    </div>
</template>
<script>

import Icon from 'laravel-mix-vue-svgicon/IconComponent.vue';

export default {
    props: [
        'route'
    ],
    data: function() {
        return {
        
        }
    },
    methods:{
        cancel: function(event) {
            var vm = this;
            window.location.href = vm.route;
        }
    },
    components: {
        Icon,
    }
}
</script>
<style lang="scss">

</style>