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-mc-d9-theme

v2.7.1

Published

Yeoman generator for creating Drupal 9 component based themes.

Downloads

171

Readme

Mediacurrent Theme Generator

The Theme Generator is a scafolding tool built by your friends at Mediacurrent, which lets you quickly set up a Drupal 8 or 9 theme with sensible defaults and best practices.

Using the Theme Generator

While the theme generator can be run anywhere, it's happiest when it's run from an empty directory you'd like to become your theme.

While not a requirement we like to use NVM to manage the version of Node per project.

Creating a new Drupal theme

  1. Create a new directory. Example:

    themes/custom/my_awesome_theme

Setup NodeJS & NPM

  1. Move into the new directory and install Node:

    cd my_awesome_theme
    nvm install 14 && node -v > .nvmrc
    • This will install the latest release of NodeJS v14.

    • It will create .nvmrc in the root of your project.

  2. Theme Generator is compatible with npm v6.

    npm install -g [email protected]

    From now on, when working on this theme change into its directory and run nvm use and NVM will switch to the specified version for you.

Create the theme

  1. Run the generator (Do not change this command):

    npm create yo mc-d9-theme
    • You should be taken through a series of questions that allow you to pick the best options for your theme.

IMPORTANT: Your theme's machine name should always match the directory name you created above.

More info if you're interested in how this stuff works:

npm create is an alias of npm init and uses npx under the hood. Find out more about npm init.

Note about Drupal 9

If you are building a Drupal 9 theme, make the following updates after your theme has been created:

  • Update Pattern Lab to v5.14.0 by updating package.json as follows:

    "@pattern-lab/core": "5.14.0",
    "@pattern-lab/engine-twig-php": "5.14.0",
    "@pattern-lab/uikit-workshop": "5.14.0",
  • Remove node_modules

  • Run npm install

About the New Theme

Drupal Module Dependencies

This theme uses Twig namespaces. In order for these to work in Drupal you must install the Components Library module.

Support

The following is supported by your new theme.

  • Pattern Lab (Node)
  • Component-Based Workflow
  • ES6+ (With Source Maps)
  • Sass
  • Image Compression
  • Live reloading
  • Sass and JavaScript linting

Starter Kit

The theme generator allows you to (optionally) add example components / templates.

  • Element - Body Text
  • Element - Button
  • Element - Eyebrow
  • Element - Heading
  • Layout - L-Flex
  • Layout - Page Layout (dependencies: Breadcrumb, L-Flex, Main Menu, Site Branding, Site Footer, Utility Nav)
  • Layout - Site Branding
  • Layout - Site Footer (dependencies: Body Text, Menu, Site Branding, Social Menu, Utility Nav)
  • Layout - Site Header (dependencies: Breadcrumb, L-Flex, Main Menu, Site Branding, Utility Nav)
  • Layout - Social Menu (dependencies: Icons)
  • Layout - Utility Nav / Account (dependencies: Menu)
  • Drupal - Breadcrumb
  • Drupal - Font Awesome
  • Drupal - Menu
  • Drupal - Main Menu
  • Drupal - Messages
  • Drupal - Page Title (dependencies: Heading)
  • Drupal - Pager (dependencies: Icons)
  • Drupal - Search API Results
  • Drupal - Search Box (dependencies: Icons)
  • Drupal - Tabs
  • Node - Rain Templates
  • Block - Accordion (dependencies: Heading, Icons)
  • Block - Breaker (dependencies: Card)
  • Block - Card (dependencies: Body Text, Heading)
  • Block - Card List (dependencies: Button, Card)
  • Block - Carousel / Slider (dependencies: Heading, Hero)
  • Block - Embed (dependencies: Heading)
  • Block - Gallery Carousel (dependencies: Body Text, Heading)
  • Block - Gallery + Lightbox (dependencies: Body Text, Heading, Icons)
  • Block - Hero (dependencies: Body Text, Button, Eyebrow, Heading, Media)
  • Block - Latest News (dependencies: Card, Heading)
  • Block - Map (dependencies: Eyebrow)
  • Block - Media (dependencies: Heading, Media)
  • Block - Quote
  • Block - Teaser (dependencies: Card)
  • Block - Views (dependencies: Button, Heading)

These can include both component and Drupal templates that are added to the appropriate place during theme generation. Your theme.libraries.yml is also updated to include the relevant libraries.

This can also be run within a pre-existing theme using:

npx yo mc-d9-theme:starter-kit

Create new Components

You can also generate base components with the right files in place using:

npm run generate

This is helpful if you are building out a new theme and would like to quickly create lots of new components with the libraries already wired up.

A Word About Commiting ./dist Files

TLDR: Don't do it if you can avoid it.

Every time Pattern Lab is rebuilt the cache busting strings will change on CSS and JS files. dependencyGraph.json will also be updated every single time which makes reviewing pull requests rather difficult.

Optimally we want to gitignore all /.dist files and run npm run build as part of a continuous integration process.

Stuff You Might Want To Change

Supported Browsers

Change what browsers your theme supports by updating browserslist within package.json. For options take a look at browserslist.

This impacts CSS browser prefixes and JavaScript compiled files.

Demo Files

  • Swap out screenshot.png with your own theme image.
  • Remove or replace the font files in ./src/patterns/global/fonts/.
  • Change the colors in ./src/patterns/global/colors/.

Go Team

Provided by default are seven npm scripts that point to Gulp tasks. We run gulp through npm scripts.

  1. Run the default build task (gulp in this instance) and everything in it. This is the equivalent to running gulp on the command line with Gulp installed globally.

    npm run build
  2. Compile Sass and JS.

    npm run compile
  3. Watch files and run tasks when they change.

    npm run watch
  4. Compress png and svg assets.

    npm run compress
  5. Build Pattern Lab.

    npm run styleguide
  6. Lint Sass and JS files.

    npm run lint
  7. Delete compiled Sass, JS and style guide files from the /dist directory.

    npm run clean

Links

Contributing

Would you like to contribute? Want to make a few changes or fix a bug? COME ON OVER!

Clone down this repo

git clone [email protected]:mediacurrent/theme_generator_9.git
cd theme_generator_9

Remove generator-mc-d9-theme if you have previously installed it:

Tip: use npm ls -g -depth=0 to see what global node modules are installed.

npm uninstall generator-mc-d9-theme -g

Use the node version of the generator

nvm install

nvm use

Install the generator's dependencies

npm install

Link your local generator files to npm:

npm link

Now whenever you run yo mc-d9-theme it'll use your locally cloned mc-d9-theme generator. Any updates done to the generator can be tested in real time.

Break off a feature branch dive right in. After you've got something you'd like to add, push back to the repo and pull request against develop.

IMPORTANT

To test the changes you've made locally, ensure your new theme uses the same version of node as the generator.