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

@everec/tailwind-patterns

v0.0.3

Published

SVG Background Patterns for Tailwind

Downloads

3

Readme

Tailwind Background Patterns

This plugin allows you to create utility classes for (SVG) background patterns. The patterns can be colored with color combinations of your choice.

Installation

npm install -D @everec/tailwind-patterns

or

yarn add @everec/tailwind-patterns -dev

Then add the plugin to your tailwind.config.js file:

// tailwind.config.js
const tailwindPatterns = require("@everec/tailwind-patterns");

module.exports = {
  theme: {
    // ...
  },
  plugins: [
    tailwindPatterns({
        // ...
    })
    // ...
  ],
}

Configuration

tailwindPatterns({
  patterns: {
      "my-pattern":
          "url(\"data:image/svg+xml,<svg id='patternId' width='100%25' height='100%25' xmlns='http://www.w3.org/2000/svg'><defs><pattern id='a' patternUnits='userSpaceOnUse' width='40' height='40' patternTransform='scale(2) rotate(0)'><rect x='0' y='0' width='100%25' height='100%25' fill='BACKGROUND_FILL'/><path d='M0 0h10v20H0zM30 0v10H10V0zM10 10h10v20H10zM40 10v10H20V10zM20 20h10v20H20zM50 20v10H30V20zM30 30h10v20H30zM20 30v10H0V30zM10 20v10h-20V20zM30-10h10v20H30z'  stroke-width='1' stroke='PATTERN_FILL' fill='none'/></pattern></defs><rect width='800%25' height='800%25' transform='translate(-18,-6)' fill='url(%23a)'/></svg>\")",
  },
  colorCombinations: {
      'green-devil': '#a1fc03|#6ca803',
      'simply-red': 'red',
  },
  patternNameSpace: 'pattern', // optional, default: pattern
})

This configuration will then create utility classes for the 'my-pattern' with all the color combinations:

.pattern-my-pattern-green-devil {
    background-image: url("data:image/svg+xml,<svg width='70' height='40' viewBox='0 0 70 40' fill='none' xmlns='http://www.w3.org/2000/svg'><g clip-path='url(%23clip0_971_236792)'><rect width='69.141' height='40' fill='%23a1fc03'/><path d='M69.2118 40H46.1178L34.5698 20L46.1178 0H69.2118L80.7588 20L69.2118 40ZM57.6648 60H34.5698L23.0228 40L34.5698 20H57.6648L69.2118 40L57.6648 60ZM57.6648 20H34.5698L23.0228 0L34.5698 -20H57.6648L69.2118 0L57.6648 20ZM34.5698 60H11.4758L-0.0701876 40L11.4768 20H34.5718L46.1188 40L34.5698 60ZM34.5698 20H11.4758L-0.0701876 0L11.4768 -20H34.5718L46.1178 0L34.5698 20ZM23.0228 40H-0.0701876L-11.6172 20L-0.0701876 0H23.0238L34.5698 20L23.0228 40Z' stroke='%236ca803'/></g><defs><clipPath id='clip0_971_236792'><rect width='69.141' height='40' fill='PATTERN_FILL'/></clipPath></defs></svg>")'><rect width='69.141' height='40' fill='%23a1fc03'/><path d='M69.2118 40H46.1178L34.5698 20L46.1178 0H69.2118L80.7588 20L69.2118 40ZM57.6648 60H34.5698L23.0228 40L34.5698 20H57.6648L69.2118 40L57.6648 60ZM57.6648 20H34.5698L23.0228 0L34.5698 -20H57.6648L69.2118 0L57.6648 20ZM34.5698 60H11.4758L-0.0701876 40L11.4768 20H34.5718L46.1188 40L34.5698 60ZM34.5698 20H11.4758L-0.0701876 0L11.4768 -20H34.5718L46.1178 0L34.5698 20ZM23.0228 40H-0.0701876L-11.6172 20L-0.0701876 0H23.0238L34.5698 20L23.0228 40Z' stroke='%236ca803'/></g><defs><clipPath id='clip0_971_236792'><rect width='69.141' height='40' fill='PATTERN_FILL'/></clipPath></defs></svg>);
    background-color: #a1fc03;
}
.pattern-my-pattern-simply-red {
    background-image: url("data:image/svg+xml,<svg width='70' height='40' viewBox='0 0 70 40' fill='none' xmlns='http://www.w3.org/2000/svg'><g clip-path='url(%23clip0_971_236792)'><rect width='69.141' height='40' fill='red'/><path d='M69.2118 40H46.1178L34.5698 20L46.1178 0H69.2118L80.7588 20L69.2118 40ZM57.6648 60H34.5698L23.0228 40L34.5698 20H57.6648L69.2118 40L57.6648 60ZM57.6648 20H34.5698L23.0228 0L34.5698 -20H57.6648L69.2118 0L57.6648 20ZM34.5698 60H11.4758L-0.0701876 40L11.4768 20H34.5718L46.1188 40L34.5698 60ZM34.5698 20H11.4758L-0.0701876 0L11.4768 -20H34.5718L46.1178 0L34.5698 20ZM23.0228 40H-0.0701876L-11.6172 20L-0.0701876 0H23.0238L34.5698 20L23.0228 40Z' stroke='red'/></g><defs><clipPath id='clip0_971_236792'><rect width='69.141' height='40' fill='PATTERN_FILL'/></clipPath></defs></svg>")'><rect width='69.141' height='40' fill='red'/><path d='M69.2118 40H46.1178L34.5698 20L46.1178 0H69.2118L80.7588 20L69.2118 40ZM57.6648 60H34.5698L23.0228 40L34.5698 20H57.6648L69.2118 40L57.6648 60ZM57.6648 20H34.5698L23.0228 0L34.5698 -20H57.6648L69.2118 0L57.6648 20ZM34.5698 60H11.4758L-0.0701876 40L11.4768 20H34.5718L46.1188 40L34.5698 60ZM34.5698 20H11.4758L-0.0701876 0L11.4768 -20H34.5718L46.1178 0L34.5698 20ZM23.0228 40H-0.0701876L-11.6172 20L-0.0701876 0H23.0238L34.5698 20L23.0228 40Z' stroke='red'/></g><defs><clipPath id='clip0_971_236792'><rect width='69.141' height='40' fill='PATTERN_FILL'/></clipPath></defs></svg>);
    background-color: red;
}

Known issues

  • SVG URI needs to be manually escaped. Even special characters like "%" or "#" can cause problems, depending on Webpack settings.