Sha256: 1fa0fd9806f3b8e52d7ff704421835bf02f66ffcf7962b364dd5ccee0ca0c6c4

Contents?: true

Size: 1.14 KB

Versions: 3

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

module Ariadne
  module Behaviors
    module Captionable
      def with_caption(text, **options)
        @caption_id = ::Ariadne.generate_id

        Ariadne::Behaviors::Caption.new(id: @caption_id, text: text, component: self, **options)
      end
    end

    class Caption < Ariadne::BaseComponent
      option :id
      option :text
      option :component
      option :size, default: -> { :sm }

      erb_template <<~ERB
        <div data-controller="ariadne-tooltip",>
          <%= render(component) { content } %>
          <p class="<%= style(:text) %>"><%= text %></p>
        </div>
      ERB

      style do
        base do
          [
            "ariadne-text-gray-500",
          ]
        end

        variants do
          size do
            # w-36
            sm { "max-w-[min(144px,90vw)]" }
            # w-52
            md { "max-w-[min(208px,90vw)]" }
            # w-96
            lg { "max-w-[min(384px,90vw)]" }
          end
        end
      end

      style :text do
        base do
          [
            "text-sm",
            "ariadne-text-gray-500",
          ]
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ariadne_view_components-0.0.82 app/components/ariadne/behaviors/captionable.rb
ariadne_view_components-0.0.81 app/components/ariadne/behaviors/captionable.rb
ariadne_view_components-0.0.80.3 app/components/ariadne/behaviors/captionable.rb