Class: Plutonium::UI::Form::Components::Section
- Inherits:
-
Component::Base
- Object
- Component::Base
- Plutonium::UI::Form::Components::Section
- Defined in:
- lib/plutonium/ui/form/components/section.rb
Overview
Renders a form section’s chrome (heading/description, optional native <details> collapsible, and a fields grid) and yields to a block that renders the section’s fields (the form supplies render_resource_field).
Constant Summary collapse
- SECTION_CLASS =
"space-y-5 pt-7 first:pt-0"- ACCENT_CLASS =
A short primary accent rule to the left of the heading — anchors the section and adds a touch of brand. Shared by the grouped <div> header and the collapsible <summary> so both read the same.
"border-l-[3px] border-primary-500 pl-3.5"- HEADING_CLASS =
"text-base font-semibold tracking-tight text-[var(--pu-text)]"- SUMMARY_CLASS =
"#{HEADING_CLASS} #{ACCENT_CLASS} cursor-pointer select-none"- DESCRIPTION_CLASS =
font-normal resets the semibold inherited from a <summary> parent.
"mt-1 text-sm font-normal text-[var(--pu-text-muted)]"
Instance Method Summary collapse
-
#initialize(resolved, grid_class:) ⇒ Section
constructor
A new instance of Section.
- #view_template(&fields_block) ⇒ Object
Methods included from Component::Behaviour
Methods included from Component::Tokens
Methods included from Component::Kit
#BuildActionButton, #BuildActionsDropdown, #BuildAvatar, #BuildBlock, #BuildBreadcrumbs, #BuildBulkActionsToolbar, #BuildColorModeSelector, #BuildDynaFrameContent, #BuildDynaFrameHost, #BuildEmptyCard, #BuildFrameNavigatorPanel, #BuildModalCentered, #BuildModalSlideover, #BuildPageHeader, #BuildPanel, #BuildRowActionsDropdown, #BuildSkeletonTable, #BuildTabList, #BuildTableFilterPills, #BuildTableInfo, #BuildTablePagination, #BuildTableScopesBar, #BuildTableScopesPills, #BuildTableSearchBar, #BuildTableToolbar, #BuildTableViewSwitcher, #method_missing, #respond_to_missing?
Constructor Details
#initialize(resolved, grid_class:) ⇒ Section
Returns a new instance of Section.
11 12 13 14 |
# File 'lib/plutonium/ui/form/components/section.rb', line 11 def initialize(resolved, grid_class:) @section = resolved.section @grid_class = grid_class end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Plutonium::UI::Component::Kit
Instance Method Details
#view_template(&fields_block) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/plutonium/ui/form/components/section.rb', line 26 def view_template(&fields_block) if @section.collapsible? details(open: !@section.collapsed?, class: SECTION_CLASS) do # <summary> must be the first child of <details> and can't be # wrapped, so the title text and its description both live inside # it — keeping the description hugging the title under one accent. summary(class: SUMMARY_CLASS) do plain heading_text describe end grid(&fields_block) end else div(class: SECTION_CLASS) do header_block grid(&fields_block) end end end |