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

generator-pattern-library

v0.0.22

Published

Yeoman generator

Downloads

29

Readme

Pattern Library Generator

Requirements

Pattern Library Generator

The Pattern Library Yeoman Generator is used to scaffold out a complete pattern library structure.

To install generator-pattern-library from npm, run:

npm install -g generator-pattern-library

Finally, initiate the generator:

yo pattern-library

Generator Setup Steps

  1. Pattern Library Project Name?

This name will be used at the Title of the Readme as in "[Project Name] Pattern Library"

NOTE: If this not explicitly set, your current directory name will be added by default. If you decide to change this, you can update the README directly in your project

  1. If this pattern library has been added to Github, please provide the repo name:

Adding the repo name lets you share your project with others (yay!) and allows you to push to gh-pages (more to come on this)

Example: if your github repo url is "github.com/organization/org-pattern-library", then your repository name here would be added as "org-pattern-library"

NOTE: If you skip this question and decide you want/need to add this later, you will need to update the following files with "repo-name" values:

package.json

"name": "repo-name"

config.yml

githubrepo: 'repo-name'

Build, install, and serve your new pattern library

Once the library has been scaffolded by Yeoman, you'll need to run these commands. NOTE: these instructions are in the README of your new pattern library

  • Install Pattern Lab, then import ALL Pattern Libraries and local site files into Pattern Lab

    gulp build

  • Populate Pattern Lab's public directory, run server, watch files

    gulp serve

Pattern Subgenerator: Create a new pattern

This subgenerator will create a new pattern and it's supporting files inside the local patterns folder (./patterns)

yo pattern-library:pattern

Where are my files? Where do I work?

DO NOT EDIT FILES IN PATTERN-LAB (./patternlab).

All changes made in the patternlab directory will be overwritten by gulp.

Patterns

./patterns

All html patterns in your pattern library will be located in ./patterns. They should be in subfolders according to their category & subcategory.

Any changes to files in the ./patterns directory will automatically be imported into your local Pattern Lab instance as long as you have run the gulp serve command and your server is running.

Global Assets/Files

./global-assets

You may also have files that aren't directly associated with a single pattern. These could include site-wide css, fonts, images, etc.

Any changes to files in the ./global-assets directory will automatically be imported into your local Pattern Lab instance as long as you have run the gulp serve command and your server is running.

Can I include one pattern in another?

as a twig include, yes.

{% include "[category]-[patternName]" %} eg: {% include 'molecules-circle' %}

ref: how to twig includes

How to clone a pattern

...or... "Can I modify a pattern imported from the NPM-based pattern library (for example, the existing "promo" pattern)?"

Version 0.1.3 of pattern-library-utilities added a cloning feature. It's rudimentary, but it works.

NOTE: If the pattern folder already exists in your ./patterns directory, the system will not overwrite your local folder. It will exit without cloning.

To clone a pattern from NPM to your local ./patterns directory

You'll type three items:

  • gulp task: gulp clone
  • a flag: --pattern
  • a pattern path: node_modules/path/to/category/subcategory/pattern

If you were going to import the h1 atoms/text pattern into your local pattern directory to make changes to it, your final gulp line would look like this:

gulp clone --pattern node_modules/pattern-library/patterns/atoms/text/h1

How to add your Github repo information to your project

See Generator Setup Steps (step 2) above

How to import a new pattern library from a GitHub repo into your pattern library

NOTE: turn off gulp serve before importing a new library

  1. Use NPM to import the library

    • inside the main directory of your pattern library, run this command:
    npm install git+ssh://[email protected]:scottnath/scottnath-pattern-library.git
    • the above line imports the pattern library "scottnath-pattern-library" into your library's node_modules directory
    • change the git ssh link to whatever pattern library you're trying to import from github
  2. Change your config.yml file to include this new pattern library.

    • inside ./config.yml, near the top, you'll add this new library to npmPatternRepos:
    npmPatternRepos:
      -
        name: 'base'
        repoDir: 'pattern-library'
      -
        name: 'scottnath'
        repoDir: 'scottnath-pattern-library'
  3. Run the import task for all libraries

    gulp patterns-import-all
    • alternatively, you can import just this one library into Pattern Lab
    gulp patterns-import-npm-scottnath
  4. Start the server

    gulp serve

License

MIT