breadcrumbs_on_rails icon indicating copy to clipboard operation
breadcrumbs_on_rails copied to clipboard

Breadcrumbs outside controllers (like storybook previews)

Open 0x7466 opened this issue 3 years ago • 1 comments

Since the breadcrumbs gem is tightly coupled with controllers, I wonder if there is a way to use it outside a controller by explicitly including it in a class. This would be especially useful for previews.

We use the view_component gem and I haven't found a way to use this gem inside the ViewComponent::Preview.

Something like this would be useful:

class BreadcrumbsComponentPreview < ViewComponent::Preview
  include BreadcrumbsOnRails  # Include gem in another class

  add_breadcrumb :home, "/"

  def default
    render BreadcrumbsComponent.new
  end
end

0x7466 avatar Apr 28 '21 09:04 0x7466

I recommend the lookbook gem for view component previews.

mateuszbialowas avatar Jun 02 '23 02:06 mateuszbialowas