Class: PhlexKit::List

Inherits:
BaseComponent show all
Defined in:
app/components/phlex_kit/typography/list.rb

Overview

Prose list, ported from shadcn/ui's typography "list" style (ruby_ui's TypographyList). Renders a ul (or ol via as:) with the .pk-list styling that previously shipped as an orphaned utility class. Children are plain

  • s.
  • Constant Summary collapse

    AS_TAGS =

    as: is dispatched dynamically (send) — whitelist like Separator.

    %i[ul ol].freeze

    Instance Method Summary collapse

    Methods inherited from BaseComponent

    #on

    Constructor Details

    #initialize(as: :ul, **attrs) ⇒ List

    Returns a new instance of List.

    
    
    10
    11
    12
    13
    14
    15
    16
    # File 'app/components/phlex_kit/typography/list.rb', line 10
    
    def initialize(as: :ul, **attrs)
      @as = as.to_sym
      unless AS_TAGS.include?(@as)
        raise ArgumentError, "unknown List as: #{@as.inspect} (use one of #{AS_TAGS.join(", ")})"
      end
      @attrs = attrs
    end

    Instance Method Details

    #view_templateObject

    
    
    18
    19
    20
    # File 'app/components/phlex_kit/typography/list.rb', line 18
    
    def view_template(&)
      send(@as, **mix({ class: "pk-list" }, @attrs), &)
    end