Class: Plutonium::UI::TabList
- Inherits:
-
Component::Base
- Object
- Component::Base
- Plutonium::UI::TabList
- Defined in:
- lib/plutonium/ui/tab_list.rb
Defined Under Namespace
Classes: TabDefinition
Instance Method Summary collapse
-
#initialize ⇒ TabList
constructor
A new instance of TabList.
- #render? ⇒ Boolean
- #view_template ⇒ Object
- #with_tab(identifier:, title:, &block) ⇒ Object
Methods included from Component::Behaviour
Methods included from Component::Tokens
Methods included from Component::Kit
#BuildActionButton, #BuildActionsDropdown, #BuildBlock, #BuildBreadcrumbs, #BuildBulkActionsToolbar, #BuildColorModeSelector, #BuildDynaFrameContent, #BuildDynaFrameHost, #BuildEmptyCard, #BuildFrameNavigatorPanel, #BuildPageHeader, #BuildPanel, #BuildRowActionsDropdown, #BuildSkeletonTable, #BuildTabList, #BuildTableInfo, #BuildTablePagination, #BuildTableScopesBar, #BuildTableSearchBar, #method_missing, #respond_to_missing?
Constructor Details
#initialize ⇒ TabList
Returns a new instance of TabList.
7 8 9 10 11 |
# File 'lib/plutonium/ui/tab_list.rb', line 7 def initialize(...) super @tabs = [] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Plutonium::UI::Component::Kit
Instance Method Details
#render? ⇒ Boolean
17 18 19 |
# File 'lib/plutonium/ui/tab_list.rb', line 17 def render? @tabs.present? end |
#view_template ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/plutonium/ui/tab_list.rb', line 21 def view_template div( data_controller: "resource-tab-list", data_resource_tab_list_active_classes_value: "focus:outline-none text-primary-600 border-primary-600 dark:text-primary-400 dark:border-primary-400", data_resource_tab_list_in_active_classes_value: "text-[var(--pu-text-muted)] hover:text-[var(--pu-text)] border-transparent hover:border-[var(--pu-border-strong)]" ) do div(class: "mb-6 border-b border-[var(--pu-border)]") do ul( class: "flex flex-wrap -mb-px text-base font-semibold text-center gap-1", role: "tablist" ) do @tabs.each do |tab| li(role: "presentation") do ( class: "inline-block px-5 py-3 border-b-2 rounded-t-lg transition-colors", id: "#{tab[:identifier]}-tab", type: "button", role: "tab", aria_controls: "#{tab[:identifier]}-tabpanel", aria_selected: "false", data_resource_tab_list_target: "btn", data_target: "#{tab[:identifier]}-tabpanel", data_action: "click->resource-tab-list#select" ) do phlexi_render tab[:title] do |val| plain val end end end end end end div do @tabs.each do |tab| div( hidden: true, id: "#{tab[:identifier]}-tabpanel", role: "tabpanel", aria_labelledby: "#{tab[:identifier]}-tab", data_resource_tab_list_target: "tab" ) do phlexi_render tab[:block] do |val| raise NotImplementedError, "this should NEVER be triggered" end end end end end end |
#with_tab(identifier:, title:, &block) ⇒ Object
13 14 15 |
# File 'lib/plutonium/ui/tab_list.rb', line 13 def with_tab(identifier:, title:, &block) @tabs << {identifier:, title:, block:} end |