phenixdigital/phoenix_storybook

`theme` Attribute does not render in the example code

dsrees opened this issue · 4 comments

dsrees commented

If I declare a component with the attr :theme, :string, then the variation will properly style the example, but the code block next to the example will not include the theme. I haven't had the chance yet to look over the source, but I'm assuming that theme may be some special term in storybook.

# My functional component
attr :theme, :string, default: "primary"
def button(assigns) do
    ...
end


# In the .story.exs
%Variation{
    id: :button,
    attributes: %{
        text: "Button text",
        theme: "red"
    }
}

Resulting storybook file renders as such
Screen Shot 2023-09-28 at 11 20 59 AM

Hey Daniel,

theme has indeed a special meaning in the storybook. I recommend you read this guide

But it shouldn't be removed from your code unless you explicitly use the theming assign strategy.

I'll have a look into it

dsrees commented

Thanks @cblavier for pointing out those docs and taking a look. We are not making use of any theming as described. Happy to provide more details if helpful.

I just fixed the issue, would you mind testing your code against storybook's main branch to make sure this is ok now?

(if you have any issues with assets while testing an unreleased version of the library, please make sure you have read https://github.com/phenixdigital/phoenix_storybook#contributing)

dsrees commented

👍🏼 Looking good locally. Thanks for quickly resolving this, I appreciate it.

(I didn't bother getting assets to work locally, but the code examples render correctly)
Screen Shot 2023-10-03 at 11 21 40 AM