Sha256: ddb276f1ad566a11c0ba30a599822d4ae33af43d4da909fc6234db46675948fc

Contents?: true

Size: 1.92 KB

Versions: 125

Compression:

Stored size: 1.92 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
      # @snapshot
      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

125 entries across 125 versions & 2 rubygems

Version Path
primer_view_components-0.19.0 previews/primer/beta/truncate_preview.rb
openproject-primer_view_components-0.22.2 previews/primer/beta/truncate_preview.rb
primer_view_components-0.18.2 previews/primer/beta/truncate_preview.rb
openproject-primer_view_components-0.22.1 previews/primer/beta/truncate_preview.rb
primer_view_components-0.18.1 previews/primer/beta/truncate_preview.rb
openproject-primer_view_components-0.22.0 previews/primer/beta/truncate_preview.rb
primer_view_components-0.18.0 previews/primer/beta/truncate_preview.rb
openproject-primer_view_components-0.21.0 previews/primer/beta/truncate_preview.rb
primer_view_components-0.17.0 previews/primer/beta/truncate_preview.rb
openproject-primer_view_components-0.20.0 previews/primer/beta/truncate_preview.rb
primer_view_components-0.16.1 previews/primer/beta/truncate_preview.rb
primer_view_components-0.16.0 previews/primer/beta/truncate_preview.rb
openproject-primer_view_components-0.19.0 previews/primer/beta/truncate_preview.rb
primer_view_components-0.15.1 previews/primer/beta/truncate_preview.rb
primer_view_components-0.15.0 previews/primer/beta/truncate_preview.rb
openproject-primer_view_components-0.18.1 previews/primer/beta/truncate_preview.rb
openproject-primer_view_components-0.17.1 previews/primer/beta/truncate_preview.rb
openproject-primer_view_components-0.17.0 previews/primer/beta/truncate_preview.rb
primer_view_components-0.14.0 previews/primer/beta/truncate_preview.rb
openproject-primer_view_components-0.16.0 previews/primer/beta/truncate_preview.rb