Sha256: 2a54b616b467d3bfac03b42def2ddd2081c628d048273dfb2ffa1b4134141275

Contents?: true

Size: 1.9 KB

Versions: 2

Compression:

Stored size: 1.9 KB

Contents

# frozen_string_literal: true

module Yattho
  module Beta
    # @label Truncate
    class TruncatePreview < ViewComponent::Preview
      # @label Playground
      #
      # @param text [String] text
      def playground(text: "branch-name-that-is-really-long")
        render(Yattho::Beta::Truncate.new) { text }
      end

      # @label Default options
      #
      # @param text [String] text
      def default(text: "branch-name-that-is-really-long")
        render(Yattho::Beta::Truncate.new) { text }
      end

      # @label Multiple items
      def multiple_items
        render(Yattho::Beta::Truncate.new) do |component|
          component.with_item do
            "really-long-repository-owner-name"
          end
          component.with_item(font_weight: :bold) do
            "really-long-repository-name"
          end
        end
      end

      # @label Advanced multiple items
      def advanced_multiple_items
        render(Yattho::Beta::Truncate.new(tag: :ol)) do |component|
          component.with_item(tag: :li) { "yattho" }
          component.with_item(tag: :li, priority: true) { "/ css" }
          component.with_item(tag: :li) { "/ Issues" }
          component.with_item(tag: :li) { "/ #123" }
          component.with_item(tag: :li, priority: true) { "Visual bug on yattho.com found in lists" }
        end
      end

      # @label Max widths
      def max_widths
        render(Yattho::Beta::Truncate.new) do |component|
          component.with_item(max_width: 300) { "branch-name-that-is-really-long-branch-name-that-is-really-long-branch-name-that-is-really-long" }
          component.with_item(max_width: 200) { "branch-name-that-is-really-long-branch-name-that-is-really-long-branch-name-that-is-really-long" }
          component.with_item(max_width: 100) { "branch-name-that-is-really-long-branch-name-that-is-really-long-branch-name-that-is-really-long" }
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
yattho_view_components-0.1.1 previews/yattho/beta/truncate_preview.rb
yattho_view_components-0.0.1 previews/yattho/beta/truncate_preview.rb