Surface is a custom Drupal theme built from the ground up and is compatible with Drupal 9 & 10.
Surface is built with Storybook and Vite, and the help of many NodeJS packages to improve automation and make use of the latest Front-End tooling.
There are several custom npm commands that allows developers to build and run different
tasks during and after development. These commands can be found in package.json
.
The most common ones to use include:
npm run build
: This is the "do it all" command which runs vite build
and storybook build -o storybook
. In addition to building your FE environment, it also generates a static version of Storybook for prodcution release (storybook
directory). Run this command for a full project build including prod.
npm run watch
: This will run both vite build --watch
and stroybook dev -p 6006
. This is the most common command to run while using Surface for development. Among the task configured in vite.config.js
, you will find:
dist
folder to ensure a there are fresh files each time.Surface uses Storybook as its design system and that's where all components
on the sites are originally built and maintained. Storybook can be accessed on its own by running npm run storybook
and navigating to http://localhost:6006
. It can also be accessed through Drupal's URL for example https://your-site.ddev.site:6006
.
Although Surface adheres to the Atomic Design methodology, it does not use the same naming conventions for naming its patterns. Our naming convention for the top level categories are:
For a simple demonstration of how to build components in Storybook and integrate them with Drupal, we are sharing a couple of components we use on our projects. These components are:
Surface is built using the latest development practices for CSS, JS, Twig, and React. Within Surface's Storybook, all components are built using BEM methodology for selector classes and ES6 for Javascript. Components are built using the Atomic Design methodology but not necessarily using the same naming convention like atoms, molecules, organisms, etc. Instead, it uses more friendly names like elements, components, collections, layouts, and pages.
For demo purposes, we have included Drupal template suggestions inside templates/
, which also include examples of how a particular Drupal entity (i.e. content type) is integrated with a Storybook component.
For more information, see Drupal.org theming guide.
Surface was built with 🩵 by the good folks at UCLA Health.
For details on how this project came about and how to use its features, take a look a the blog series available at mariohernandez.io.