Skip to content

Instantly share code, notes, and snippets.

@jeffam
Last active February 26, 2019 13:44
Show Gist options
  • Save jeffam/270ff20f810e3028dd8987e76ec5acf8 to your computer and use it in GitHub Desktop.
Save jeffam/270ff20f810e3028dd8987e76ec5acf8 to your computer and use it in GitHub Desktop.
ILR/CU Design System

ILR/CU Design System

  • Monorepo for components. Templates are twig, CSS preprocessor is Sass.
  • Each component is a package. Probably npm. Each package has its dependencies, compiled CSS, optional js, documentation, and twig template.
  • Projects can install components a-la-carte. e.g. npm install @cu-design/component-button.

An installed component might look like this:

node_modules/@cu-design/component-button/
├── README.md
├── button.scss
├── button.css
├── button.js
├── button.twig
├── button.ui_patterns.yml
└── package.json

Drupal integration example:

  • Contrib or custom module (cu-design?) that:
  • npm install @cu-design/component-button

A twig template could then use the following:

{{ attach_library('cu-design/component-button') }}

{% include "@cu-design/component-button/button.twig" with {
  "text": content.field_paragraph_button_text,
} %}
@jeffam
Copy link
Author

jeffam commented Feb 25, 2019

The installation location in node_modules/ isn't great, and there isn't anything like https://github.com/composer/installers for node that I know of.

@jeffam
Copy link
Author

jeffam commented Feb 25, 2019

The installation location in node_modules/ isn't great, and there isn't anything like https://github.com/composer/installers for node that I know of.

Possible solution, use Asset Packagist and install via composer to a custom location like web/libraries/. See https://lightning.acquia.com/blog/round-your-front-end-javascript-libraries-composer

@a-fro
Copy link

a-fro commented Feb 26, 2019

If you define a library in a node_modules package using a libraries.yml file, would Drupal know of it? Or do we need the namespacing module for our design system to somehow handle that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment