chromaui / storybook-addon-pseudo-states

CSS pseudo-classes for Storybook
MIT License
88 stars 28 forks source link

Not working with Lit for component states #38

Open leventozen opened 2 years ago

leventozen commented 2 years ago

Hi, We are trying to create some stories for our components states like hover but no luck. Here you can look at our other issue before using this addon.

Code:


export const SingleButtonTemplate = (args) => html`<bl-button
    variant=${ifDefined(args.variant)}
    kind=${ifDefined(args.kind)}
    href=${ifDefined(args.href)}
    target=${ifDefined(args.target)}
    size=${ifDefined(args.size)}
    icon="${ifDefined(args.icon)}"
    label="${ifDefined(args.label)}"
    ?disabled=${args.disabled}
    style=${ifDefined(args.styles ? styleMap(args.styles) : undefined)}
      >${unsafeHTML(args.content)}</bl-button>`

export const Template = (args) => html`
${SingleButtonTemplate({content: 'Primary Button', ...args})}
${SingleButtonTemplate({variant: 'secondary', content: 'Secondary Button', ...args})}
${SingleButtonTemplate({variant: 'success', content: 'Success Button', ...args})}
${SingleButtonTemplate({variant: 'danger', content: 'Danger Button', ...args})}`;

export const states = {
  pseudo: {
    hover: "bl-button"
  }
}

<Canvas isColumn>
  <Story name="Primary Buttons Hover" args={{ content: 'Save', icon: 'info' }} parameters={states}>
    {ButtonTypesTemplate.bind({})}
  </Story>
  <Story name="Secondary Buttons Hover" args={{ variant: 'secondary', content: 'Save', icon: 'info' }} parameters={states}>
    {ButtonTypesTemplate.bind({})}
  </Story>
  <Story name="Success Buttons Hover" args={{ variant: 'success', content: 'Save', icon: 'info' }} parameters={states}>
    {ButtonTypesTemplate.bind({})}
  </Story>
  <Story name="Danger Buttons Hover" args={{ variant: 'danger', content: 'Save', icon: 'info' }} parameters={states}>
    {ButtonTypesTemplate.bind({})}
  </Story>
</Canvas>

It will not work well in Chromatic. Here you can see that our first button has no pseudo-class or Chromatic took a screenshot of this story like that. However, if you react to those stories in the storybook, everything seems fine. Unless, if you open canvas and go back to docs again (maybe twice), it will not work. Additionally, after you open canvas and use the left menu and reach the hover story, it will work for only that story.

I am using Chrome (Version 104.0.5112.101)

PS: If there is no parameter, simply returning StoryFn() may be considered as a performance improvement.

Thanks in advance

ghengeveld commented 2 years ago

I would really appreciate if you could get to the bottom of this. I have close to zero experience with Lit so I'm not really able to debug this.

muratcorlu commented 2 years ago

@ghengeveld, I want to ask some questions about the intention of this plugin-in to be able to debug this issue: