Sha256: 8f6462da5ddf2cfa8977a01de260ccb1d2bc8ac2246f1bb79c23d60cb60dfb86

Contents?: true

Size: 1.9 KB

Versions: 32

Compression:

Stored size: 1.9 KB

Contents

# frozen_string_literal: true

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

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

      # @label Multiple items
      def multiple_items
        render(Primer::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(Primer::Beta::Truncate.new(tag: :ol)) do |component|
          component.with_item(tag: :li) { "primer" }
          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 primer.style found in lists" }
        end
      end

      # @label Max widths
      def max_widths
        render(Primer::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

32 entries across 32 versions & 1 rubygems

Version Path
primer_view_components-0.3.1 previews/primer/beta/truncate_preview.rb
primer_view_components-0.3.0 previews/primer/beta/truncate_preview.rb
primer_view_components-0.2.0 previews/primer/beta/truncate_preview.rb
primer_view_components-0.1.9 previews/primer/beta/truncate_preview.rb
primer_view_components-0.1.8 previews/primer/beta/truncate_preview.rb
primer_view_components-0.1.7 previews/primer/beta/truncate_preview.rb
primer_view_components-0.1.6 previews/primer/beta/truncate_preview.rb
primer_view_components-0.1.5 previews/primer/beta/truncate_preview.rb
primer_view_components-0.1.4 previews/primer/beta/truncate_preview.rb
primer_view_components-0.1.3 previews/primer/beta/truncate_preview.rb
primer_view_components-0.1.2 previews/primer/beta/truncate_preview.rb
primer_view_components-0.1.1 previews/primer/beta/truncate_preview.rb
primer_view_components-0.1.0 previews/primer/beta/truncate_preview.rb
primer_view_components-0.0.123 previews/primer/beta/truncate_preview.rb
primer_view_components-0.0.122 previews/primer/beta/truncate_preview.rb
primer_view_components-0.0.121 previews/primer/beta/truncate_preview.rb
primer_view_components-0.0.120 previews/primer/beta/truncate_preview.rb
primer_view_components-0.0.119 previews/primer/beta/truncate_preview.rb
primer_view_components-0.0.118 previews/primer/beta/truncate_preview.rb
primer_view_components-0.0.117 previews/primer/beta/truncate_preview.rb