phenixdigital / phoenix_storybook

A pluggable storybook for your Phoenix components.
MIT License
708 stars 54 forks source link

Boolean rendering seems to be broken + `nil`. #482

Closed sodapopcan closed 3 weeks ago

sodapopcan commented 3 months ago

Hey Christian!

Thanks so much for Storybook, it's very awesome.

Related to this #169, this appears not to be working anymore. I'm seeing attr={true} in all my components. Furthermore, would it be possible to ignore any attributes that are nil as this is how HEEx works (passing nil to an attribute will not render the whole attribute). I was looking for a setting for this but can't seem to find it.

Thanks again, Andrew

cblavier commented 2 months ago

hey there 👋

this is weird, as this shorthand boolean rendering does seem to work properly here and is thoroughly tested in this file

Are your attributes properly declared as boolean before your function component? https://hexdocs.pm/phoenix_live_view/Phoenix.Component.html#module-attributes

I will have a look at nil attributes, I'm not sure this is properly handled

sodapopcan commented 2 months ago

Ohhhhhh I see, it only works on declared attributes.

Yes, I was seeing it with globals mainly on <.input disabled>. I tried it like this:

attr :rest, :global, include: ~w[disabled]

but it still does not pick it up.

I'm happy to take a look myself, though it'll be a week or so before I can.

Thanks!

cblavier commented 2 months ago

I'd appreciate, if you could look into it by yourself :)

cblavier commented 1 month ago

Hey @sodapopcan, did you get a chance to take a look?

sodapopcan commented 3 weeks ago

Sorry, no I have not as I have a bunch on my list and this is a "nice to have." I'm still planning on a PR, though.

cblavier commented 3 weeks ago

sure, feel free to reopen whenever you want