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

grid-spriter

v1.3.4

Published

A mixin to help using svg sprites

Downloads

4

Readme

GridSpriter

A mixin to help using svg sprites.

Installation

yarn add grid-spriter

Constructor

@include GridSpriter($name, $col, $row, $params);

| Parameter | Type | Is required | Default | Description | |-----------|--------|-------------|---------|-------------------------------------------| | $name | string | ✔ | | The name of your sprite set | | $col | number | ✔ | | The number of columns in your sprite grid | | $row | number | ✔ | | The number of rows in your sprite grid | | $params | map | | () | A map of optional parameters. |

Optional parameters

| Parameter | Type | Default | Description | |--------|--------|-----------------------------|----------------------------------------------------------| | path | string | '/assets/images/sprites/' | The base path to your sprite image | | format | string | 'svg' | The extension of your sprite image | | def | map | null | A map with icon indexes as keys and icon names as values | | modes | list | ['is', 'prepend', 'append'] | The modes for which to generate class definitions | | type | string | 'mask' | The type of images to use |

Output

// Generated classes will look like this
// .#{$mode}-#{$name}-#{$id}-icon[-mask][::before|::after] {}

// For example if you used the mixin like so
$twitchParams: (
  def: (1: 'follow'), 
  modes: ['is', 'append']
);

@include GridSpriter('twitch', 3, 2, $twitchParams);

// The resulting classes would look like this
.is-twitch-follow-icon-mask {}
.append-twitch-follow-icon-mask::after {}

Usage

Any element or pseudo-element containing a sprite image must have a set width and height. Any pseudo-element containing a sprite image must have a set content. An empty string will do. Any element or pseudo-element containing a sprite image as a mask must have a set background or background-color.

The default path for images is /assets/images/sprites/, the default format is svg. In our example, the image must be located at /assets/images/sprites/twitch.svg.

@import 'grid-spriter';

$twitchParams: (
  def: (0: 'follow', 1: 'sub'),
  modes: ['is', 'prepend']
);

@include GridSpriter('twitch', 3, 2, $twitchParams);

// Twitch follow icon as background image
// The class can be anything as long as its target element also has a GridSpriter generated class
.is-twitch-follow-icon { 
  width: 64px;
  height: 64px;
}

// Twitch sub icon as a before pseudo-element with mask image
.prepend-twitch-sub-icon-mask::before {
  content: '';
  display: inline-block;
  width: 64px;
  height: 64px;
  background-color: #6441A5;
}
<!-- twitch follow icon as background image -->
<div class="is-twitch-follow-icon"></div>

<!-- twitch follow icon as mask image -->
<div class="is-twitch-follow-icon-mask"></div>

<!-- twitch follow icon as a before pseudo-element with background image -->
<div class="prepend-twitch-follow-icon"></div>