Class: Railsboot::DividerComponent

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

Overview

ViewComponent: renders the divider block.

Constant Summary collapse

DEFAULT_COLOR =

Default color.

"secondary-subtle".freeze
SIZES =

Sizes.

[1, 2, 3, 4, 5, 6].freeze
DEFAULT_SIZE =

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.



12
13
14
15
16
17
18
19
20
21
22
# File 'app/components/railsboot/divider_component.rb', line 12

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



24
25
26
27
28
# File 'app/components/railsboot/divider_component.rb', line 24

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