How to style a component using term reference field containg styling information

Created on 11 December 2023, 11 months ago
Updated 12 September 2024, 2 months ago

We have components and we have a taxonomy which contains styling information.
For a simple example consider CTA component (with a link field) and a taxonomy which container field for BG color (for button display), and text color. On hover the the color switched, BG color is used for text and text color for BG.
We written a preprocessor to fetch values from term reference and set variable. In twig we apply styling.
We have more complex component is similar way.

Now my question how I can utilize the pattern/SDC approach for these kind of scenarios.
How to pass attributes or styles to the components?

💬 Support request
Status

Fixed

Version

1.0

Component

Code

Created by

🇮🇳India Sharique

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

Comments & Activities

  • Issue created by @Sharique
  • Status changed to Postponed: needs info 10 months ago
  • 🇫🇷France pdureau Paris

    So, you have a CTA component with:

    • a link slot (aka "field" in UI Patterns 1.x)
    • a bg_color prop (aka "setting" in UI Patterns 1.x)

    On Drupal side, you ahve a field formatter on a content entity (taxonomy term)/

    You want to inject the data of a field from this entity in the prop. If your setting type allow tokens, it may be the way.
    If not, yes, use a preprocessor.

    Is it clear?.

    PS: This situation will be easier to manage with UI Patterns 2.x

  • Status changed to Fixed 3 months ago
  • 🇫🇷France Grimreaper France 🇫🇷

    Marking as fixed as there is no reply from issue's author.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024