Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Component Libraries: Theme Server

Security covered Under active development 61 sites

This module allows you to integrate your Drupal project with component libraries like Storybook by rendering components directly within Drupal. This ensures consistent rendering between your component library and your Drupal site, and avoids the limitations of using Twig.js. It supports hot reloading and Drupal-style JavaScript.

Deprecated

Use the newer Storybook module to integrate with Storybook. This module will let you put any arbitrary Twig code in your Storybook stories, including Single Directory Components.

This module lets you use component libraries, like Storybook, in your Drupal project, without Twig.js!

Wait! what's the problem with Twig.js?

Mismatched feature set

According to the Twig.js documentation:

Twig.js is currently a work in progress and supports a limited subset of the Twig templating language (with more coming).

This means that you are left to the following decisions:

  • do I use Twig as I see fit in Drupal, or do I keep to what Tiwg.js supports?
  • do I leverage twig extensions in contrib and core, or do I keep to what Twig.js supports? Do I write the Twig.js compatibility layers myself instead?

Inconsistent rendering between Drupal-Twig and Twig.js

The goal is to develop your components in your component library (like Storybook), and know that there will not be a difference when you render the component in your Drupal site.

You also need to consider the fact that if Drupal is not rendering your components, how is your component library aware of the Drupal theme? The render pipeline in Drupal will change the markup, add & remove CSS, add & remove JS, process images, etc. All this needs to be faked in Twig.js if you want Drupal to render something similar to what Twig.js renders.

This means that you are left to the following decisions:

  • am I optimistic that the templates in Storybook with Twig.js will look the same in Drupal, or do I re-double the QA efforts to ensure?
  • can I ensure that Twig.js will have all the CSS and JS that Drupal adds to the page (now and in the future)?

Leverage Component Libraries: Server

If your solution is to have Drupal render the components, like us, this module lets you do that.

Storybook + Drupal

Even though this module is completely agnostic of the component library, the main integration is Storybook.

Set up Storybook for your Drupal site.

Please see the @lullabot/storybook-drupal-addon, which will make your Storybook aware of Drupal by connecting it to this module.

📋 Step-by-step tutorial 📋

Hot reload of server-side changes


📼 Watch it in high resolution

Rendered in Drupal with your themes


📼 Watch it in high resolution

Always consistent rendering between Drupal and Storybook


📼 Watch it in high resolution

Supports Drupal-style JavaScript


📼 Watch it in high resolution

Storybook knobs and stories


📼 Watch it in high resolution

Usage

Enable the module and set up Storybook according to the instructions here.

It is recommended to disable the component registry cache during development. To do so, add this to your settings.local.php:

$settings['cache']['bins']['discovery'] = 'cache.backend.null';

Additional resources

Remember to disable development mode in production!

Development mode should not be enabled in production. Make sure to disable it by unsetting the cl_server.development container parameter.

What version should I use?

Select the version of this module based on the component solution that you are using.

CL Components SDC SDC from core Use 1.x Use 2.x Use 2.x

Ask your assistant about Component Libraries: Theme Server

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
9
Tracked since
Feb 2023
Latest release
2 years ago
Releases (12 mo)
0
Maintenance
Dormant

Release Timeline

Releases

Version Type Core PHP Release date
2.0.0-beta5 Pre-release 9–10 PHP >=8.1 Nov 24, 2023
2.0.0-beta4 Pre-release 9–10 PHP >=8.1 Nov 23, 2023
2.0.0-beta3 Pre-release 9–10 PHP >=8.1 Jul 31, 2023
2.0.0-beta2 Pre-release 9–10 PHP >=8.1 Jun 19, 2023
2.0.0-beta1 Pre-release 9–10 PHP >=8.1 May 1, 2023
2.0.0-alpha2 Pre-release 9–10 PHP >=8.1 Apr 24, 2023
1.0.0-rc5 Pre-release 9 PHP >=8.1 Mar 7, 2023
2.0.0-alpha1 Pre-release 9–10 PHP >=8.1 Feb 1, 2023
2.x-dev Dev 9–10 PHP >=8.1 Feb 1, 2023