Class: DesignSystem::Generic::ListComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/design_system/generic/list_component.rb

Overview

Plain, bullet, or numbered list rendered by ds_list.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers::CssHelper

#css_class_options_merge

Methods included from BrandDerivable

#brand

Constructor Details

#initialize(list:, type: :default, **options) ⇒ ListComponent

Returns a new instance of ListComponent.



5
6
7
8
9
10
# File 'app/components/design_system/generic/list_component.rb', line 5

def initialize(list:, type: :default, **options)
  super()
  @list = list
  @type = type.to_sym
  @options = options
end

Instance Attribute Details

#listObject (readonly)

Returns the value of attribute list.



12
13
14
# File 'app/components/design_system/generic/list_component.rb', line 12

def list
  @list
end

#optionsObject (readonly)

Returns the value of attribute options.



12
13
14
# File 'app/components/design_system/generic/list_component.rb', line 12

def options
  @options
end

#typeObject (readonly)

Returns the value of attribute type.



12
13
14
# File 'app/components/design_system/generic/list_component.rb', line 12

def type
  @type
end

Instance Method Details

#list_optionsObject



18
19
20
21
22
23
# File 'app/components/design_system/generic/list_component.rb', line 18

def list_options
  classes = ["#{brand}-list"]
  classes << "#{brand}-list--bullet" if type == :bullet
  classes << "#{brand}-list--number" if type == :number
  css_class_options_merge(options, classes)
end

#tag_nameObject



14
15
16
# File 'app/components/design_system/generic/list_component.rb', line 14

def tag_name
  type == :number ? :ol : :ul
end