Sha256: b5a4b889646fd66b15be1b8c57deb907caf7814bb480fecb58179482a3e796d6

Contents?: true

Size: 1.13 KB

Versions: 13

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

module Ariadne
  module Behaviors
    module Captionable
      def with_caption(text, **options)
        @caption_id = 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

13 entries across 13 versions & 1 rubygems

Version Path
ariadne_view_components-0.0.79.2 app/components/ariadne/behaviors/captionable.rb
ariadne_view_components-0.0.79.1 app/components/ariadne/behaviors/captionable.rb
ariadne_view_components-0.0.79 app/components/ariadne/behaviors/captionable.rb
ariadne_view_components-0.0.78 app/components/ariadne/behaviors/captionable.rb
ariadne_view_components-0.0.77 app/components/ariadne/behaviors/captionable.rb
ariadne_view_components-0.0.76.1 app/components/ariadne/behaviors/captionable.rb
ariadne_view_components-0.0.76 app/components/ariadne/behaviors/captionable.rb
ariadne_view_components-0.0.75 app/components/ariadne/behaviors/captionable.rb
ariadne_view_components-0.0.74.1 app/components/ariadne/behaviors/captionable.rb
ariadne_view_components-0.0.74 app/components/ariadne/behaviors/captionable.rb
ariadne_view_components-0.0.73 app/components/ariadne/behaviors/captionable.rb
ariadne_view_components-0.0.72 app/components/ariadne/behaviors/captionable.rb
ariadne_view_components-0.0.71 app/components/ariadne/behaviors/captionable.rb