From a6a4f01660b746eec48c30b3f3ecb5e3efbb1257 Mon Sep 17 00:00:00 2001 From: Nicholas Barone Date: Sat, 10 Aug 2024 14:19:15 -0700 Subject: [PATCH] Shim for rendering partials --- lib/storybook.rb | 1 + lib/storybook/partial_preview_component.rb | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 lib/storybook/partial_preview_component.rb diff --git a/lib/storybook.rb b/lib/storybook.rb index 4f126f6..f8e38c4 100644 --- a/lib/storybook.rb +++ b/lib/storybook.rb @@ -1,5 +1,6 @@ require "storybook/version" require "storybook/preview" +require "storybook/partial_preview_component" require "storybook/railtie" if defined?(Rails::Railtie) module Storybook; end diff --git a/lib/storybook/partial_preview_component.rb b/lib/storybook/partial_preview_component.rb new file mode 100644 index 0000000..e7889b4 --- /dev/null +++ b/lib/storybook/partial_preview_component.rb @@ -0,0 +1,13 @@ +require 'view_component' + +module Storybook + class PartialPreviewComponent < ViewComponent::Base + slim_template <<~SLIM + = render partial: @partial + SLIM + + def initialize(partial:) + @partial = partial + end + end +end