Class: Railsboot::DividerComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/railsboot/divider_component.rb

Constant Summary collapse

DEFAULT_COLOR =
"secondary-subtle".freeze
SIZES =
[1, 2, 3, 4, 5, 6].freeze
DEFAULT_SIZE =
1

Instance Method Summary collapse

Constructor Details

#initialize(color: DEFAULT_COLOR, size: DEFAULT_SIZE, **html_attributes) ⇒ DividerComponent

Returns a new instance of DividerComponent.



7
8
9
10
11
12
13
14
15
16
17
# File 'app/components/railsboot/divider_component.rb', line 7

def initialize(color: DEFAULT_COLOR, size: DEFAULT_SIZE, **html_attributes)
  @color = color
  @size = size - 1
  @html_attributes = html_attributes

  @html_attributes[:class] = class_names(
    "w-100",
    "position-relative",
    html_attributes[:class]
  ).presence
end

Instance Method Details

#hr_classObject



19
20
21
22
23
# File 'app/components/railsboot/divider_component.rb', line 19

def hr_class
  classes = ["opacity-100", "text-#{@color}"]
  classes << "border border-#{@size} border-#{@color}" if @size > 0
  class_names(*classes)
end