wingsuit-designsystem / wingsuit

Twig for Storybook
GNU General Public License v2.0
90 stars 16 forks source link

Adding settings to variants removes them from args table #279

Closed justintemps closed 10 months ago

justintemps commented 10 months ago

I want to create a variant that illustrates a specific combination of settings and fields. Passing the setting to the variant explicitly has the effect of rendering the component in the state that I want, but it then removes that setting from the args table.

In the below example, I get two Variants of this component. One is called Default and the other is called Wide. The Wide variant is intended to show some combination of settings and fields so users can see at a glance what happens when you combine them in certain ways.

# example.wingsuit.yml

example:
  use: "@components/example/example.twig"
  label: Example
  visibility: storybook
  fields:
    title:
      type: string
      label: Title
      preview: This is some title to use in the preview    
  settings:
    size:
      type: select
      label: size
      description: Sets the size of the Example. If not set, the example will appear as `narrow`.
      required: false
      preview: narrow
      options:
        narrow: narrow
        wide: wide
        fluid: fluid
  variants:
    default:
      label: Default
    wide:
      label: Wide
      settings:
        size: wide

In this instance, Wingsuit correctly renders the Wide component with the settings and fields that I pass to it, but the wide setting is missing from the args table.

Why does this happen and how do I correct it?

christianwiedemann commented 10 months ago

Hi,

The idea behind a variant is to define a preset of settings. So the user can't change them by design. Also not in Drupal. Variants are not previews for components. It is more are spezific configuration of a component. (But there is a lot of discussion around variants.) Actually Figma is thinking in the same direction.

justintemps commented 10 months ago

@christianwiedemann thanks for the clarification