Sha256: 788818ae62abaab80e86712fb71be287de3bc2620d981b06949d3fbbc1054333

Contents?: true

Size: 887 Bytes

Versions: 300

Compression:

Stored size: 887 Bytes

Contents

# frozen_string_literal: true

module Ariadne
  # `Text` is a wrapper component that will apply typography styles to the text inside.
  class Text < Ariadne::Component
    DEFAULT_TAG = :span

    # @example Default
    #   <%= render(Ariadne::Text.new(tag: :p, attributes: { font_weight: :bold })) { "Bold Text" } %>
    #   <%= render(Ariadne::Text.new(tag: :p, attributes: { color: :danger })) { "Danger Text" } %>
    #
    # @param tag [Symbol, String] The rendered tag name
    # @param classes [String] <%= link_to_classes_docs %>
    # @param attributes [Hash] <%= link_to_attributes_docs %>
    def initialize(tag: DEFAULT_TAG, classes: "", attributes: {})
      @tag = tag
      @classes = classes
      @attributes = attributes
    end

    def call
      render(Ariadne::BaseComponent.new(tag: @tag, classes: @classes, attributes: @attributes)) { content }
    end
  end
end

Version data entries

300 entries across 300 versions & 1 rubygems

Version Path
ariadne_view_components-0.0.59-x64-mingw-ucrt app/components/ariadne/text.rb
ariadne_view_components-0.0.59-aarch64-linux app/components/ariadne/text.rb
ariadne_view_components-0.0.59-x86_64-darwin app/components/ariadne/text.rb
ariadne_view_components-0.0.59-x86_64-linux app/components/ariadne/text.rb
ariadne_view_components-0.0.59-arm64-darwin app/components/ariadne/text.rb
ariadne_view_components-0.0.59 app/components/ariadne/text.rb
ariadne_view_components-0.0.58-x86_64-darwin app/components/ariadne/text.rb
ariadne_view_components-0.0.58-aarch64-linux app/components/ariadne/text.rb
ariadne_view_components-0.0.58-arm64-darwin app/components/ariadne/text.rb
ariadne_view_components-0.0.58-x64-mingw-ucrt app/components/ariadne/text.rb
ariadne_view_components-0.0.58 app/components/ariadne/text.rb
ariadne_view_components-0.0.58-x86_64-linux app/components/ariadne/text.rb
ariadne_view_components-0.0.57-arm64-darwin app/components/ariadne/text.rb
ariadne_view_components-0.0.57-aarch64-linux app/components/ariadne/text.rb
ariadne_view_components-0.0.57-x86_64-darwin app/components/ariadne/text.rb
ariadne_view_components-0.0.57-x86_64-linux app/components/ariadne/text.rb
ariadne_view_components-0.0.57-x64-mingw-ucrt app/components/ariadne/text.rb
ariadne_view_components-0.0.57 app/components/ariadne/text.rb
ariadne_view_components-0.0.55-x86_64-linux app/components/ariadne/text.rb
ariadne_view_components-0.0.55-arm64-darwin app/components/ariadne/text.rb