Class: Shadcn::Field::Separator::Component

Inherits:
ApplicationViewComponent show all
Defined in:
app/components/shadcn/field/separator/component.rb

Overview

FieldSeparator — a rule with optional centred content.

Constant Summary collapse

CONTENT_CLASSES =
"relative mx-auto block w-fit bg-background px-2 text-muted-foreground"

Constants inherited from ApplicationViewComponent

ApplicationViewComponent::CONTENTS_STYLE, ApplicationViewComponent::VOID_TAGS

Instance Attribute Summary

Attributes inherited from ApplicationViewComponent

#attributes

Instance Method Summary collapse

Methods inherited from ApplicationViewComponent

#css_classes, default_tag, #initialize, #merged_style, #render_element, #shadcn_t, slot_name, #style_variants, #tag_name

Constructor Details

This class inherits a constructor from Shadcn::ApplicationViewComponent

Instance Method Details

#callObject



22
23
24
25
26
27
28
29
30
31
# File 'app/components/shadcn/field/separator/component.rb', line 22

def call
  body = [ render(Shadcn::Separator::Component.new(class: "absolute inset-0 top-1/2")) ]

  if content.present?
    body << tag.span(content, class: CONTENT_CLASSES,
                              "data-slot": "field-separator-content")
  end

  render_element(body: safe_join(body))
end

#element_attributes(**defaults) ⇒ Object



18
19
20
# File 'app/components/shadcn/field/separator/component.rb', line 18

def element_attributes(**defaults)
  super(**{ "data-content" => content.present? }.merge(defaults))
end