From 40553668200bfe8b2c7ca995f1eea5424c37b780 Mon Sep 17 00:00:00 2001 From: mhenrixon Date: Sat, 8 Nov 2025 08:17:13 +0100 Subject: [PATCH] Add HoverGallery component - Implements HoverGallery component with DaisyUI styling - Adds comprehensive test coverage - Includes responsive class comments for Tailwind --- lib/phlexy_ui/hover_gallery.rb | 23 ++++++++++++++ spec/lib/phlexy_ui/hover_gallery_spec.rb | 39 ++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 lib/phlexy_ui/hover_gallery.rb create mode 100644 spec/lib/phlexy_ui/hover_gallery_spec.rb 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