Class: UI::SeparatorComponent

Inherits:
ViewComponent::Base
  • Object
show all
Includes:
SeparatorBehavior
Defined in:
app/view_components/ui/separator_component.rb

Overview

Separator - ViewComponent implementation

Visually or semantically separates content. Uses SeparatorBehavior module for shared styling logic.

Based on shadcn/ui Separator: ui.shadcn.com/docs/components/separator Based on Radix UI Separator: www.radix-ui.com/primitives/docs/components/separator

Instance Method Summary collapse

Methods included from SeparatorBehavior

#separator_classes, #separator_html_attributes

Constructor Details

#initialize(orientation: :horizontal, decorative: true, classes: "", **attributes) ⇒ SeparatorComponent

Returns a new instance of SeparatorComponent.

Parameters:

  • orientation (Symbol, String) (defaults to: :horizontal)

    Direction of the separator (:horizontal, :vertical)

  • decorative (Boolean) (defaults to: true)

    Whether the separator is purely decorative (true) or has semantic meaning (false)

  • classes (String) (defaults to: "")

    Additional CSS classes to merge

  • attributes (Hash)

    Additional HTML attributes



17
18
19
20
21
22
# File 'app/view_components/ui/separator_component.rb', line 17

def initialize(orientation: :horizontal, decorative: true, classes: "", **attributes)
  @orientation = orientation
  @decorative = decorative
  @classes = classes
  @attributes = attributes
end

Instance Method Details

#callObject



24
25
26
# File 'app/view_components/ui/separator_component.rb', line 24

def call
  tag.div(**separator_html_attributes.deep_merge(@attributes))
end