Class: Typography::List

Inherits:
Base
  • Object
show all
Defined in:
lib/phlex_ui/typography/list.rb

Instance Method Summary collapse

Constructor Details

#initialize(items: [], numbered: false, **attrs) ⇒ List

Returns a new instance of List.



5
6
7
8
9
# File 'lib/phlex_ui/typography/list.rb', line 5

def initialize(items: [], numbered: false, **attrs)
  @items = items
  @numbered = numbered
  super(**attrs)
end

Instance Method Details

#view_templateObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/phlex_ui/typography/list.rb', line 11

def view_template(&)
  if @items.empty?
    list(**attrs, &)
  else
    list(**attrs) do
      @items.each do |item|
        render PhlexUI::Typography::ListItem.new { item }
      end
    end
  end
end