Problem/Motivation

CivicTheme uses the Components module which uses Twig namespaces to support includes/embeds, e.g.

{% include '@atoms/button/button.twig' with {

SDC expects you to use "theme:component-name" (or "module:component-name"), e.g.

{% include 'civictheme:button' with {

Switching from Components to SDC namespaces means:

  1. UI Kit Twig files will diverge from Drupal implementation
  2. Non-Drupal Storybook will not run on components

Steps to reproduce

Proposed resolution

Note related issues:

#3444321: make SDC respect *.info.yml namespaces
#3390717: Allow declaration of template path in SDC

For now, this could be handled with build rules where all UI Kit includes/embeds Component namespaces are replaced with the SDC convention.

Then we'd need to ensure:

  1. Storybook uses the original UI Kit components (and custom ones)
  2. Drupal only finds the components tweaked for SDC

Remaining tasks

TBD

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

kristen pol created an issue. See original summary.

kristen pol’s picture

Assigned: kristen pol » Unassigned
Status: Active » Postponed

Waiting to hear back from @Wim Leers and @lauriii on if we need to yank the components modules and hardcode SDC namespaces for demo, so postponing for now.

kristen pol’s picture

Wim would prefer not to have the dependency though Lauri says it's okay for the demo if we need it.

kristen pol’s picture

Assigned: Unassigned » kristen pol
Status: Postponed » Active

Reopening for consideration.

kristen pol’s picture

Assigned: kristen pol » Unassigned
Status: Active » Postponed

Moving to postponed for now until we sort out the components working properly in XB.

kristen pol’s picture

Priority: Critical » Normal

Given we are working through a lot of critical issues, I'm doubtful this will be worked on before Barcelona so leaving this as postponed and lowering priority given Lauri was okay with this being a dependency for Barcelona. We can remove afterwards if we don't get to it beforehand.

kristen pol’s picture

Title: Reconcile components vs SDC namespaces for SDDS includes/embeds » Reconcile components module vs SDC namespaces for SDDS includes/embeds
Status: Postponed » Active

Someone could work on this. Once this work is done though, we can't look at the components with Storybook, unless we do:

#3466372: Create SDDS build rules for merging SDC metadata files with UI Kit code

so that we take the UI Kit components and combine with SDC metadata YAMLs and README.md files such that these components are what are picked up by XB rather than how we've manually combined everything.

I'd say that this issue can be focused just on replacing the components module namespaces with the SDC namespaces so that we can test that once we are unblocked.

annmarysruthy’s picture

Assigned: Unassigned » annmarysruthy
kristen pol’s picture

Thanks!

annmarysruthy’s picture

Assigned: annmarysruthy » Unassigned
Status: Active » Needs review

Raised MR for replacing the components module namespaces with the SDC namespaces. Kindly review MR !38

kristen pol’s picture

Assigned: Unassigned » jacobadeutsch

Thanks! Assigning to Jacob for review.

kristen pol’s picture

I've merged in recent changes and fixes and did a quick test.

I switched to this MR branch and ran `npm run build` and get fatal errors for storybook (expected).

I get these when trying to use XB:

Drupal\Core\Render\Component\Exception\InvalidComponentException: [theme] NULL value found, but a string or an object is required. This may be because the property is empty instead of having data present. If possible fix the source data, use the |default() twig filter, or update the schema to allow multiple types./n[theme] Does not have a value in the enumeration ["light","dark"] in Drupal\Core\Theme\Component\ComponentValidator->validateProps() (line 206 of /var/www/html/web/core/lib/Drupal/Core/Theme/Component/ComponentValidator.php).
Twig\Error\RuntimeError: An exception has been thrown during the rendering of a template ("[level] NULL value found, but a string or an object is required. This may be because the property is empty instead of having data present. If possible fix the source data, use the |default() twig filter, or update the schema to allow multiple types./n[level] Does not have a value in the enumeration ["h1","h2","h3","h4","h5","h6"]"). in Twig\Template->yield() (line 1 of themes/contrib/demo_design_system/components/01-atoms/heading/heading.twig).
kristen pol’s picture

Assigned: jacobadeutsch » Unassigned
Status: Needs review » Postponed

Given this is a distraction from our current work which is much more pressing, I'm moving this back to postponed and this won't likely make it into the demo but can be worked on post-Barcelona. Thanks for trying to get it to work!

kristen pol’s picture

Priority: Normal » Major

Bumping to major but keeping postponing for more visibility in backlog.

kristen pol’s picture

kristen pol’s picture

Assigned: Unassigned » jacobadeutsch
Status: Postponed » Needs work

Assigning to Jacob for looking at this further.

kristen pol’s picture

Assigned: jacobadeutsch » Unassigned
Status: Needs work » Postponed (maintainer needs more info)

It would be good for us to understand what's the advantage of using:

{% include 'civictheme:button' with {

rather than:

{% include '@civictheme/../components/00-atoms/button/button.twig' with {

(which is being used in #3479191: Replace components module namespaces with fully-qualified paths)

other than it being more succinct. The latter works with non-SDC Drupal code.

jcandan’s picture

I am playing with this same problem space. I am building an organization-specific USWDS (like design.va.gov), with a concept similar to how Emulsify demo’d Western U with multiple in-house brands. The plan is to have Storybooks at those multiple levels, and then at the individual project instance level (Drupal and non-Drupal projects).

So, the Drupal-specific twig muddies the waters.

Still playing. Curious how this pans out.

kristen pol’s picture

Gotcha. We will need create build rules that updates the components with the Drupal-y bits as we are starting with a non-Drupal-specific design system: https://github.com/civictheme/uikit

pdureau’s picture

It would be good for us to understand what's the advantage of using:

{% include 'civictheme:button' with {

rather than:

{% include '@civictheme/../components/00-atoms/button/button.twig' with {

I am not fond of include 'civictheme:button':

  • it doesn't trigger the component render element (but kind of "simulate" it)
  • If used outside of a component (in a "normal" Drupal template), it is often replaceable by a better use of the render API and the display builders: https://www.youtube.com/watch?v=75wRtmpczOM
  • if used inside a component template, it is often replaceable by a better use of the slot system

But it is better than include '@civictheme/.../button.twig' (which share the same issues) because it helps us to stop thinking about templates (and its path) and let us focus on components as proper UI objects. The component template (Twig file) must be an implementation detail which must stay opaque. What is really meaningful is the component definition (YAML file).

kristen pol’s picture

Thanks so much 🙏 I’ll watch the video (it was on my list!)