You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The render(Views::Phlex::Item.new) { "Help!" } returns a hash because it is using render from Lookbook::Preview and the component isn't rendered. To solve that I could write something like this:
On source tab, will display component usage list.render ..., but it isn't required, so other devs could understand that unnecessary code is required to build the component
I cannot use my component helpers. I added helpers to Lookbook::Preview, eg.:
moduleDesignSystemHelpersdefmy_button(*args, **kwargs, &block)renderDesignSystem::ButtonComponent.new(*args, **kwargs, &block)enddefmy_card(...)
...
end
...
end# on initializersconfig.to_preparedoLookbook::Preview.includeDesignSystemHelpersend
So something like this doesn't work on Lookbook:
defdefaultmy_carddo |card| # this will be renderedcard.actionsdo# this will be renderedmy_button(...)# this will NOT be rendered because Lookbook::Preview `#render`my_button(...)# this will NOT be rendered because Lookbook::Preview `#render`endendend
This is important because I think Lookbook is a source of how developers should use our components.
And the other problem is that I cannot do that on preview files:
I'm facing a issue with Lookbook + Phlex:
Phlex allows you to write something like this:
But when I write this example on a Lookbook::Preview class, it doesn't work. To reproduce the error, paste the code above into
builder
scenario on this file: https://github.com/ViewComponent/lookbook/blob/main/spec/dummy/test/components/previews/phlex_example_preview.rb#L10.The
render(Views::Phlex::Item.new) { "Help!" }
returns a hash because it is usingrender
from Lookbook::Preview and the component isn't rendered. To solve that I could write something like this:Then I will have two problems:
list.render ...
, but it isn't required, so other devs could understand that unnecessary code is required to build the componentSo something like this doesn't work on Lookbook:
This is important because I think Lookbook is a source of how developers should use our components.
And the other problem is that I cannot do that on preview files:
It will raise
undefined method 'h1' for an instance of MyComponentPreview
.Originally posted by @stephannv in #400 (comment)
The text was updated successfully, but these errors were encountered: