Class: Primer::Alpha::TreeView::SubTreeNode
- Inherits:
-
Component
- Object
- ViewComponent::Base
- Component
- Primer::Alpha::TreeView::SubTreeNode
- Defined in:
- app/components/primer/alpha/tree_view/sub_tree_node.rb
Overview
A ‘TreeView` sub-tree node.
This component is part of the <%= link_to_component(Primer::Alpha::TreeView) %> component and should not be used directly.
Direct Known Subclasses
Constant Summary collapse
- DEFAULT_SELECT_STRATEGY =
:mixed_descendants- SELECT_STRATEGIES =
[ :self, DEFAULT_SELECT_STRATEGY, :descendants ]
Constants inherited from Component
Component::INVALID_ARIA_LABEL_TAGS
Constants included from Status::Dsl
Constants included from ViewHelper
Constants included from TestSelectorHelper
TestSelectorHelper::TEST_SELECTOR_TAG
Constants included from FetchOrFallbackHelper
FetchOrFallbackHelper::InvalidValueError
Constants included from Primer::AttributesHelper
Primer::AttributesHelper::PLURAL_ARIA_ATTRIBUTES, Primer::AttributesHelper::PLURAL_DATA_ATTRIBUTES
Instance Method Summary collapse
-
#initialize(label:, path:, node_variant:, sub_tree_component_klass: SubTree, expanded: false, select_strategy: DEFAULT_SELECT_STRATEGY, **system_arguments) ⇒ SubTreeNode
constructor
A new instance of SubTreeNode.
- #render_in(*args, &block) ⇒ Object
-
#with_leading_action_button(**system_arguments, &block) ⇒ Object
Adds a leading action rendered to the left of the node’s label and any leading visuals or checkboxes.
-
#with_leading_visual_icon(label: nil, **system_arguments, &block) ⇒ Object
Adds a leading visual icon rendered to the left of the node’s label.
-
#with_leading_visual_icons(label: nil, **system_arguments, &block) ⇒ Object
Adds a pair of leading visual icon rendered to the left of the node’s label.
-
#with_trailing_visual_icon(label: nil, **system_arguments, &block) ⇒ Object
Adds a trailing visual icon rendered to the right of the node’s label.
Methods inherited from Component
Methods included from JoinStyleArgumentsHelper
Methods included from TestSelectorHelper
Methods included from FetchOrFallbackHelper
#fetch_or_fallback, #fetch_or_fallback_boolean, #silence_deprecations?
Methods included from ClassNameHelper
Methods included from Primer::AttributesHelper
#aria, #data, #extract_data, #merge_aria, #merge_data, #merge_prefixed_attribute_hashes
Methods included from ExperimentalSlotHelpers
Methods included from ExperimentalRenderHelpers
Constructor Details
#initialize(label:, path:, node_variant:, sub_tree_component_klass: SubTree, expanded: false, select_strategy: DEFAULT_SELECT_STRATEGY, **system_arguments) ⇒ SubTreeNode
Returns a new instance of SubTreeNode.
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'app/components/primer/alpha/tree_view/sub_tree_node.rb', line 116 def initialize( label:, path:, node_variant:, sub_tree_component_klass: SubTree, expanded: false, select_strategy: DEFAULT_SELECT_STRATEGY, **system_arguments ) @label = label @system_arguments = system_arguments @select_strategy = fetch_or_fallback(SELECT_STRATEGIES, select_strategy, DEFAULT_SELECT_STRATEGY) @system_arguments[:aria] = merge_aria( @system_arguments, { aria: { expanded: } } ) @system_arguments[:data] = merge_data( @system_arguments, { data: { target: "tree-view-sub-tree-node.node", "node-type": "sub-tree" } } ) sub_tree_arguments = @system_arguments.delete(:sub_tree_arguments) || {} @sub_tree = sub_tree_component_klass.new( expanded: , path: path, node_variant: node_variant, **sub_tree_arguments ) @node = Primer::Alpha::TreeView::Node.new( **@system_arguments, path: @sub_tree.path, node_variant: node_variant ) return if @node.select_variant == :none @node.merge_system_arguments!( data: { "select-strategy": @select_strategy } ) end |
Instance Method Details
#render_in(*args, &block) ⇒ Object
167 168 169 170 171 172 173 174 |
# File 'app/components/primer/alpha/tree_view/sub_tree_node.rb', line 167 def render_in(*args, &block) super.tap do # check this _after_ rendering so @sub_tree's slots are defined if @node.select_variant != :none && @sub_tree.defer? raise ArgumentError, "TreeView does not currently support select variants for sub-trees loaded asynchronously." end end end |
#with_leading_action_button(**system_arguments, &block) ⇒ Object
Adds a leading action rendered to the left of the node’s label and any leading visuals or checkboxes.
4 5 |
# File 'app/components/primer/alpha/tree_view/sub_tree_node.rb', line 4 def (**system_arguments, &block) end |
#with_leading_visual_icon(label: nil, **system_arguments, &block) ⇒ Object
Adds a leading visual icon rendered to the left of the node’s label.
5 6 |
# File 'app/components/primer/alpha/tree_view/sub_tree_node.rb', line 5 def with_leading_visual_icon(label: nil, **system_arguments, &block) end |
#with_leading_visual_icons(label: nil, **system_arguments, &block) ⇒ Object
Adds a pair of leading visual icon rendered to the left of the node’s label.
5 6 |
# File 'app/components/primer/alpha/tree_view/sub_tree_node.rb', line 5 def with_leading_visual_icons(label: nil, **system_arguments, &block) end |
#with_trailing_visual_icon(label: nil, **system_arguments, &block) ⇒ Object
Adds a trailing visual icon rendered to the right of the node’s label.
5 6 |
# File 'app/components/primer/alpha/tree_view/sub_tree_node.rb', line 5 def with_trailing_visual_icon(label: nil, **system_arguments, &block) end |