Reconcile components module vs SDC namespaces for SDDS includes/embeds

Created on 23 August 2024, 3 months ago
Updated 9 September 2024, 3 months ago

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:

make SDC respect *.info.yml namespaces Active
Allow declaration of template path in SDC Active

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

📌 Task
Status

Postponed

Version

1.0

Component

Code

Created by

🇺🇸United States Kristen Pol Santa Cruz, CA, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @Kristen Pol
  • Issue was unassigned.
  • Status changed to Postponed 3 months ago
  • 🇺🇸United States Kristen Pol Santa Cruz, CA, USA

    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.

  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
  • 🇺🇸United States Kristen Pol Santa Cruz, CA, USA

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

  • Assigned to Kristen Pol
  • Status changed to Active 3 months ago
  • 🇺🇸United States Kristen Pol Santa Cruz, CA, USA

    Reopening for consideration.

  • Issue was unassigned.
  • Status changed to Postponed 3 months ago
  • 🇺🇸United States Kristen Pol Santa Cruz, CA, USA

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

  • 🇺🇸United States Kristen Pol Santa Cruz, CA, USA

    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.

  • Status changed to Active 3 months ago
  • 🇺🇸United States Kristen Pol Santa Cruz, CA, USA

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

    📌 Create SDDS build rules for merging SDC metadata files with UI Kit code Postponed

    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.

  • Assigned to annmarysruthy
  • 🇺🇸United States Kristen Pol Santa Cruz, CA, USA

    Thanks!

  • Pipeline finished with Success
    3 months ago
    Total: 165s
    #273131
  • Pipeline finished with Success
    3 months ago
    Total: 437s
    #273459
  • Pipeline finished with Success
    3 months ago
    Total: 328s
    #274321
  • Issue was unassigned.
  • Status changed to Needs review 3 months ago
  • 🇮🇳India annmarysruthy

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

  • Assigned to jacobadeutsch
  • 🇺🇸United States Kristen Pol Santa Cruz, CA, USA

    Thanks! Assigning to Jacob for review.

  • Pipeline finished with Success
    3 months ago
    Total: 166s
    #274972
  • Pipeline finished with Success
    3 months ago
    Total: 166s
    #274986
  • Pipeline finished with Success
    3 months ago
    Total: 223s
    #274991
  • Pipeline finished with Success
    3 months ago
    Total: 175s
    #275016
  • 🇺🇸United States Kristen Pol Santa Cruz, CA, USA

    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).
    
  • Issue was unassigned.
  • Status changed to Postponed 3 months ago
  • 🇺🇸United States Kristen Pol Santa Cruz, CA, USA

    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!

  • 🇺🇸United States Kristen Pol Santa Cruz, CA, USA

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

  • 🇺🇸United States Kristen Pol Santa Cruz, CA, USA
  • 🇺🇸United States Kristen Pol Santa Cruz, CA, USA

    Assigning to Jacob for looking at this further.

  • 🇺🇸United States Kristen Pol Santa Cruz, CA, USA

    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 📌 Replace components module namespaces with fully-qualified paths Active )

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

  • 🇺🇸United States jcandan

    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.

  • 🇺🇸United States Kristen Pol Santa Cruz, CA, USA

    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

  • 🇫🇷France pdureau Paris

    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).

  • 🇺🇸United States Kristen Pol Santa Cruz, CA, USA

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

Production build 0.71.5 2024