diff --git a/lib/phlexy_ui/hover_gallery.rb b/lib/phlexy_ui/hover_gallery.rb new file mode 100644 index 0000000..88aec84 --- /dev/null +++ b/lib/phlexy_ui/hover_gallery.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +module PhlexyUI + # @component html class="hover-gallery" + class HoverGallery < Base + def initialize(*, as: :figure, **) + super(*, **) + @as = as + end + + def view_template(&) + generate_classes!( + # "hover-gallery" + component_html_class: :"hover-gallery", + modifiers_map: modifiers, + base_modifiers:, + options: + ).then do |classes| + public_send(as, class: classes, **options, &) + end + end + end +end diff --git a/spec/lib/phlexy_ui/hover_gallery_spec.rb b/spec/lib/phlexy_ui/hover_gallery_spec.rb new file mode 100644 index 0000000..012c0e7 --- /dev/null +++ b/spec/lib/phlexy_ui/hover_gallery_spec.rb @@ -0,0 +1,39 @@ +require "spec_helper" + +describe PhlexyUI::HoverGallery do + subject(:output) { render described_class.new } + + it "is expected to match the formatted HTML" do + expected_html = html <<~HTML + + HTML + + is_expected.to eq(expected_html) + end + + describe "data" do + subject(:output) do + render described_class.new(data: {foo: "bar"}) + end + + it "renders it correctly" do + expected_html = html <<~HTML + + HTML + + expect(output).to eq(expected_html) + end + end + + describe "passing :as option" do + subject(:output) { render described_class.new(as: :div) } + + it "renders as the given tag" do + expected_html = html <<~HTML + + HTML + + expect(output).to eq(expected_html) + end + end +end