bullet-train-co / showcase

Showcase lets you build previews for your partials, components, view helpers, Stimulus controllers and more.
MIT License
86 stars 3 forks source link

Some assorted Phlex support sketches #36

Open kaspth opened 1 year ago

kaspth commented 1 year ago
"showcase/previews/#{path.id}".classify
"Showcase::Previews::Box".constantize.render_in(@view_context)

# Require Zeitwerk naming conventions so `constantize` works.
# showcase/previews/box.rb
class Showcase::Previews::Box < Showcase::Phlex::Preview
  def template
    description do

    end

    sample "Basic" do

    end
  end
end

showcase.sample "Basic" do
  render Phlex::View
end

class Showcase::Phlex::Preview < Phlex::HTML
  attr_reader :showcase

  def initialize(showcase)
    @showcase = showcase
  end

  def template
    yield
  end
end

preview = Showcase::Preview.new
Showcase::Phlex::Preview.new(self).render_in(@view_context)

Showcase.phlex do

end
kaspth commented 1 year ago

Just to be clear: we do support Phlex out of the box already, users will just have to write their Showcase previews in ERB. This is about passing control to Phlex so users can write that directly, possibly in app/views/showcase/previews/x.rb files.