Class: Panda::Core::Admin::FormSectionComponent

Inherits:
Base
  • Object
show all
Defined in:
app/components/panda/core/admin/form_section_component.rb

Overview

Standardized form section component for grouping related form fields. Provides a consistent heading style for form sections without the heavy visual weight of PanelComponent.

Examples:

Basic usage

<%= render Panda::Core::Admin::FormSectionComponent.new(title: "SEO Settings") do %>
  <%= f.text_field :seo_title %>
  <%= f.text_area :seo_description %>
<% end %>

With description

<%= render Panda::Core::Admin::FormSectionComponent.new(
  title: "Notification Settings",
  description: "Configure how you receive notifications"
) do %>
  ...
<% end %>

With icon

<%= render Panda::Core::Admin::FormSectionComponent.new(
  title: "Menu Items",
  icon: "fa-bars"
) do %>
  ...
<% end %>

Constant Summary

Constants inherited from Base

Base::TAILWIND_MERGER

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title:, description: nil, icon: nil, border_top: true, **attrs) ⇒ FormSectionComponent

Returns a new instance of FormSectionComponent.



33
34
35
36
37
38
39
# File 'app/components/panda/core/admin/form_section_component.rb', line 33

def initialize(title:, description: nil, icon: nil, border_top: true, **attrs)
  @title = title
  @description = description
  @icon = icon
  @border_top = border_top
  super(**attrs)
end

Instance Attribute Details

#border_topObject (readonly)

Returns the value of attribute border_top.



41
42
43
# File 'app/components/panda/core/admin/form_section_component.rb', line 41

def border_top
  @border_top
end

#descriptionObject (readonly)

Returns the value of attribute description.



41
42
43
# File 'app/components/panda/core/admin/form_section_component.rb', line 41

def description
  @description
end

#iconObject (readonly)

Returns the value of attribute icon.



41
42
43
# File 'app/components/panda/core/admin/form_section_component.rb', line 41

def icon
  @icon
end

#titleObject (readonly)

Returns the value of attribute title.



41
42
43
# File 'app/components/panda/core/admin/form_section_component.rb', line 41

def title
  @title
end

Instance Method Details

#content_classesObject



58
59
60
# File 'app/components/panda/core/admin/form_section_component.rb', line 58

def content_classes
  "mt-4 space-y-4"
end

#default_attrsObject



43
44
45
46
47
48
# File 'app/components/panda/core/admin/form_section_component.rb', line 43

def default_attrs
  base_classes = "mt-6 pt-4"
  base_classes += " border-t border-gray-200" if border_top

  {class: base_classes}
end

#description_classesObject



54
55
56
# File 'app/components/panda/core/admin/form_section_component.rb', line 54

def description_classes
  "mt-1 text-xs text-gray-500"
end

#heading_classesObject



50
51
52
# File 'app/components/panda/core/admin/form_section_component.rb', line 50

def heading_classes
  "text-sm font-semibold text-gray-700 flex items-center gap-2"
end