Feedbacks about SDC components

Created on 14 March 2025, 19 days ago

Hello Kristen and demo_design_system team,

I am very happy to see you are working on this theme again, and I am excited to see your talk in Atlanta.

As a follow-up of πŸ“Œ Test UI Suite SDC validator for SDDS project Fixed , here are some feedbacks done with https://www.drupal.org/project/sdc_devel β†’ which is still providing a drush command and a report page to audit SDC components.

Unused variables

Every slot or prop from the component definition must be used in templates.

 $ vendor/bin/drush sdcv starshot_demo | grep  "Unused variables:"
  starshot_demo:starshot-cta              Unused variables: attributes     -                                                                                                    
  starshot_demo:starshot-case-study       Unused variables: attributes     -                                                                                                    
  starshot_demo:starshot-hero             Unused variables: attributes     -                                                                                                    
  starshot_demo:starshot-columns          Unused variables: attributes     -                                                                                                    
  starshot_demo:starshot-two-col          Unused variables: attributes     -                                                                                                    
  starshot_demo:starshot-grid             Unused variables: attributes     -                                                                                                    
  starshot_demo:starshot-four-col         Unused variables: attributes     -                                                                                                    
  starshot_demo:starshot-one-col          Unused variables: attributes     -                                                                                                    
  starshot_demo:starshot-three-col        Unused variables: attributes     -                                                                                                    
  starshot_demo:temp-contributors         Unused variables: attributes     -                                                                                                    
  starshot_demo:starshot-testimonial      Unused variables: attributes     -                                                                                                    
  starshot_demo:starshot-statistic-card   Unused variables: attributes     -                                                                                                    
  starshot_demo:starshot-slide-card       Unused variables: attributes     -                                                                                                    
  starshot_demo:starshot-slider           Unused variables: attributes     -                                                                                                    
  starshot_demo:starshot-testimonial-card Unused variables: attributes     -                                                                                                    
  starshot_demo:starshot-icon-card        Unused variables: attributes     -                                                                                                    
  starshot_demo:starshot-image            Unused variables: attributes     -                                                                                                    
  starshot_demo:starshot-button           Unused variables: attributes     -                                                                                                    
  starshot_demo:starshot-header-panel     Unused variables: attributes     -     

$ vendor/bin/drush sdcv civictheme | grep  "Unused variables:"
  civictheme:footer                    Unused variables: attributes                                                                                                                   
  civictheme:skip-link                 Unused variables: attributes                                                                                                                   
  civictheme:mobile-navigation         Unused variables: attributes                                                                                                                   
  civictheme:mobile-navigation-menu    Unused variables: parent_key, key                                                                                                                   
  civictheme:mobile-navigation-trigger Unused variables: attributes                                                                                                                   
  civictheme:header                    Unused variables: attributes                                                                                                                   
  civictheme:video-player              Unused variables: url, oembed                                                                                                                       
  civictheme:back-to-top               Unused variables: attributes                                                                                                                   
  civictheme:subject-card              Unused variables: is_external                                                                                                                       
  civictheme:tooltip                   Unused variables: symbol, text           

Most of them are attributes. I know there are currently some philosophical talks about this, but the technical/operational relaity is clear: default attributes object is not always defined in the YAML, but always injected in template and expected because:

  • SEO modules can insert tagging attributes through it
  • Accessibility modules can alter/insert some attributes values (aria-*, role, alt...) through it
  • Translation modules can add the lang attribute when needed
  • Styles utilities modules (like UI Styles β†’ , Style Options...) can insert helpers classes through it
  • Hypermedia modules (HTMX, Hotwire/Turbo...) can insert triggers and behaviours attributes through it
  • Drupal Core's |add_class() and |set_attribute() Twig filters rely on it
  • Display builders (like Paragraph Layout, Layout Builder, ) can insert annotation through it
  • ...

There is currently no replacement for this in Drupal, neither in the ThemeManager, not in the SDC API.

Unknown variables

Every slot or prop used in the template must be found in the component definition (except the ones automatically injected: attributes, componentMetadata...)

 $ vendor/bin/drush sdcv starshot_demo | grep  "Unknown variable:"
  starshot_demo:starshot-hero           Unknown variable: `summary`.   
  starshot_demo:starshot-hero           Unknown variable: `summary`.   
  starshot_demo:old-starshot-case-study Unknown variable: `content`.   
  starshot_demo:old-starshot-case-study Unknown variable: `data_panel`.
  starshot_demo:old-starshot-case-study Unknown variable: `data_panel`.
  starshot_demo:old-starshot-case-study Unknown variable: `data_panel`.
  starshot_demo:old-starshot-case-study Unknown variable: `data_panel`.
  starshot_demo:old-starshot-case-study Unknown variable: `data_panel`.
  starshot_demo:starshot-columns        Unknown variable: `gap`.       
  starshot_demo:starshot-columns        Unknown variable: `gap`.       
  starshot_demo:starshot-columns        Unknown variable: `vertical`.  
  starshot_demo:starshot-columns        Unknown variable: `vertical`.  
  starshot_demo:starshot-columns        Unknown variable: `horizontal`.
  starshot_demo:starshot-columns        Unknown variable: `horizontal`.
  starshot_demo:starshot-columns        Unknown variable: `direction`. 
  starshot_demo:starshot-columns        Unknown variable: `direction`. 
  starshot_demo:starshot-columns        Unknown variable: `wrap`.      
  starshot_demo:starshot-columns        Unknown variable: `wrap`.      
  starshot_demo:starshot-grid           Unknown variable: `col`.       
  starshot_demo:starshot-grid           Unknown variable: `col`.       
  starshot_demo:starshot-grid           Unknown variable: `col`.       
  starshot_demo:starshot-container      Unknown variable: `gap`.       
  starshot_demo:starshot-container      Unknown variable: `gap`.       
  starshot_demo:starshot-container      Unknown variable: `gap`.       
  starshot_demo:starshot-container      Unknown variable: `constrain`. 
  starshot_demo:old-starshot-data-panel Unknown variable: `panels`.    
  starshot_demo:old-starshot-data-panel Unknown variable: `link`.      
  starshot_demo:old-starshot-data-panel Unknown variable: `link`.      
  starshot_demo:old-starshot-data-panel Unknown variable: `link_theme`.
  starshot_demo:old-starshot-data-panel Unknown variable: `link`.      
  starshot_demo:old-starshot-data-panel Unknown variable: `link`.      
  starshot_demo:old-starshot-data-panel Unknown variable: `display`.   
  starshot_demo:starshot-statistic-card Unknown variable: `align`.     
  starshot_demo:starshot-statistic-card Unknown variable: `align`.     
  starshot_demo:old-starshot-card       Unknown variable: `tags`.      
  starshot_demo:old-starshot-card       Unknown variable: `tags`.      
  starshot_demo:old-starshot-card       Unknown variable: `link`.      
  starshot_demo:old-starshot-card       Unknown variable: `link`.      
  starshot_demo:old-starshot-card       Unknown variable: `link`.      
  starshot_demo:old-starshot-card       Unknown variable: `link`.      
  starshot_demo:old-starshot-card       Unknown variable: `link`.      
  starshot_demo:old-starshot-card       Unknown variable: `link`.      
  starshot_demo:old-starshot-card       Unknown variable: `link`.      
  starshot_demo:starshot-testimonial-card   Error      Unknown variable: `theme`.     
  starshot_demo:starshot-testimonial-card   Error      Unknown variable: `theme`.     
  starshot_demo:button                  Unknown variable: `is_dismissable`.                            
  starshot_demo:starshot-button         Unknown variable: `theme`.     
  starshot_demo:starshot-button         Unknown variable: `theme`.     
  starshot_demo:starshot-button         Unknown variable: `color_class`. 

And 49 unknown variables in civitheme.

Incomplete prop definitions

Empty objects or array are not enough to be understood by components users and processed by display builders ( UI Patterns 2 β†’ , the upcoming Experience Builder...):

In starshot_demo, there is no such case πŸ‘, but this logos prop in civictheme:logo may look loosely defined;

 {"properties":{"breakpoint":{"type":"object"}},"type":"object"}

Careful with json-schema-definitions://experience_builder.module references

There is nothing wrong in using JSON Schema references to definitions belonging to experience_builder module. I am sure most of them will be useful for components authors.

But the two references currently used by starshot_demo are problematic:

experience_builder module is still in an early shape, many months away of being released, so maybe it is only for the upcoming Atlanta demo and those references will be removed/updated later.

Usage of |raw() Twig filter

This filter is used 32 times in starshot_demo and 199 time in civictheme

Twig templates escape special characters to prevent potential hacking. Twig raw puts out the data without escaping it, meaning that if it is user-supplied data, it's insecure and could be used for hacking.

With Drupal Render API, there is no reason to use this filter.

It may be the signal something else is must be fixed, maybe slots instead, maybe the component is not called properly.

πŸ“Œ Task
Status

Active

Version

1.0

Component

Feedback

Created by

πŸ‡«πŸ‡·France pdureau Paris

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

Comments & Activities

Production build 0.71.5 2024