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

flamingo-carotene-webpack-svg-sprite

v9.0.0-alpha.13

Published

Flamingo Carotene svg sprite solution

Downloads

33

Readme

Module flamingo-carotene-webpack-svg-sprite

This module simplifies the setup, generating and using svg sprites for icons in the Flamingo Carotene environment. During the build step of Flamingo Carotene we use external-svg-sprite-loader webpack module to extract all required svg files into an single svg sprite.

How to setup

1. npm

npm i -D flamingo-carotene-webpack-svg-sprite

2. In your pug

In your base template file you'll need to include the svgIconSprite.pug from this module.

include ~flamingo-carotene-webpack-svg-sprite/dist/svgIconSprite

3. In your sass

If you would like to style your icons then you'll need to @import this in your main index.[sass|scss] file.

@import '~flamingo-carotene-webpack-svg-sprite/dist/svgIconSprite'

4. Register sprite behavior and require svg files

Create app/js/svgIconSprite.js file and import this in your index.js file:

import behavior from './behavior'
import svgIconSpriteBehavior from 'flamingo-carotene-webpack-svg-sprite/dist/svgIconSprite.behavior'

behavior.registerBehaviorClasses({
  svgIconSpriteBehavior: svgIconSpriteBehavior
});

import './svgIconSprite/*.svg'

The import './svgIconSprite/*.svg' is the setup for external-svg-sprite-loader webpack module, which collects all svg files in all js files in your project and extracts them into single svgIconSprite.svg file. All svg icons should live in frontend/src/app/js/svgIconSprite/*.js

How to use

pug

| Parameter name | Description | |:---------------|:------------| |$iconName | Here you should provide the file name of the svg icon you would like to use. |

For example if you have chevron.svg in your svg icons folder then you can use this icon like this in your pug:

+svgIcon('chevron')

You could use this as a normal pug mixin and pass any attribute you would like.

sass

After correctly setting it up, this module provides a sass mixin called +svgSpriteIcon with following parameters:

| Parameter name | Default value | Description |:---------------|:--------------|:-----------| |$width |false | Width in px can be provided | |$height |false | Height in px can be provided | |$userRatio |false | Useful if you would like to have the icon scaled based on the ratio |

For example this will style element with class name .myLogo, with 25px width and 25px height and svg filled red:

.myLogo
  +svgSpriteIcon(25, 25)
    fill: red

What is $useRatio for?

If turned on, the wrapping element will get padding-top with percentage based ratio calculated from the provided width and height.