Class: NfgUi::Components::Patterns::Collapse
- Inherits:
-
Bootstrap::Components::Collapse
- Object
- Bootstrap::Components::Base
- Bootstrap::Components::Collapse
- NfgUi::Components::Patterns::Collapse
- Includes:
- Bootstrap::Utilities::Headable, Traits::Collapse, Utilities::Describable, Utilities::Renderable, Utilities::Traitable
- Defined in:
- lib/nfg_ui/components/patterns/collapse.rb
Overview
Button Group doesn’t have any customizations unique to the design system yet As such, the NFG UI button group is simply a bootstrap button group behind the scenes. Traits will eventually be connected here.
Constant Summary
Constants included from Traits::Collapse
Constants included from Traits
Traits::REGISTERED_TRAITS, Traits::TRAIT_MODULES
Instance Attribute Summary
Attributes inherited from Bootstrap::Components::Base
#body, #options, #view_context
Instance Method Summary collapse
-
#component_initialize ⇒ Object
Because it is common to forget to add the required :id to the component options when doing a “speed built” collapse, example: = ui.nfg :collapse, :collapsed, body: ‘Collapse body content’, heading: ‘My Link’.
- #render ⇒ Object
Methods included from Traits::Collapse
#collapsed_trait, #collapsible_trait, #navbar_trait
Methods included from Utilities::Renderable
Methods included from Utilities::Describable
Methods included from Utilities::Traitable
Methods included from Bootstrap::Utilities::Headable
Methods inherited from Bootstrap::Components::Collapse
Methods included from Bootstrap::Utilities::Collapsible
#collapse, #collapsed, #collapsible
Methods inherited from Bootstrap::Components::Base
#component_family, #data, #href, #html_options, #id, #initialize, #style
Constructor Details
This class inherits a constructor from NfgUi::Bootstrap::Components::Base
Instance Method Details
#component_initialize ⇒ Object
Because it is common to forget to add the required :id to the component options when doing a “speed built” collapse, example:
ui.nfg :collapse, :collapsed, body: ‘Collapse body content’, heading: ‘My Link’
Send in a random string that is carried through from the speed built heading / button AND to the collapse component.
26 27 28 29 30 31 |
# File 'lib/nfg_ui/components/patterns/collapse.rb', line 26 def component_initialize # Only create and supply a random ID this when a :heading is present return unless heading new_id = [:id].nil? ? random_id : [:id] [:id] = new_id end |
#render ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/nfg_ui/components/patterns/collapse.rb', line 33 def render capture do if heading icon = .fetch(:icon, 'caret-down') opts = { collapse: "##{[:id]}", body: heading, icon: icon, class: 'pl-0 text-left' } opts.merge!(traits: [:link, :block]) concat(NfgUi::Components::Elements::Button.new(opts, view_context).render) end concat(super) end end |