iberdinsky-skilld / sdc-addon

Drupal Single Directory Components as stories
MIT License
3 stars 0 forks source link

Add variants to YML without repeating all slots in each variant #9

Open lunarfusion opened 3 days ago

lunarfusion commented 3 days ago

NOTE: Related issue on Drupal.org may need to be resolved before attempting to resolve how to format the YML for this issue.

In order to include child components (such as adding atom components inside of molecules and organisms), they are added as slots under thirdPartySettings in the yml file.

However, if a component with child components has variants, all of the slots content must be repeated under each variant, creating code redundancies.

thirdPartySettings:

sdcStorybook:

Default:

Slot 1 info Slot 2 info Slot 3 info

Variant 1 Slot 1 info Slot 2 info Slot 3 info

Variant 2 Slot 1 info Slot 2 info Slot 3 info

Could we change this so that only slots which have some change per variant must be repeated? Such as:

thirdPartySettings:

sdcStorybook:

Default:

Slot 1 info Slot 2 info Slot 3 info

Variant 1 Slot 2 info (for example, if different from default)

Variant 2 Slot 3 info (for example, if different from default)

Reference to a card component where this problem may be found: https://github.com/lunarfusion/storybook-university/blob/main/components/03-organisms/card/card.component.yml

iberdinsky-skilld commented 2 days ago

I don't have plans for supporting variants for now, maybe just experimental

But you can take a look at better option. Instead of using variants, you can use created stories:

https://github.com/iberdinsky-skilld/sdc-addon?tab=readme-ov-file#example-configuration

and result:

https://iberdinsky-skilld.github.io/sdc-addon/?path=/story/sdc-paragraph--grid