Class: Primer::Alpha::TreeView::SubTree

Inherits:
Component
  • Object
show all
Defined in:
app/components/primer/alpha/tree_view/sub_tree.rb

Overview

A ‘TreeView` sub-tree.

This component is part of the <%= link_to_component(Primer::Alpha::TreeView) %> component and should not be used directly.

Constant Summary

Constants inherited from Component

Component::INVALID_ARIA_LABEL_TAGS

Constants included from Status::Dsl

Status::Dsl::STATUSES

Constants included from ViewHelper

ViewHelper::HELPERS

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 Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Component

deprecated?, generate_id

Methods included from JoinStyleArgumentsHelper

#join_style_arguments

Methods included from TestSelectorHelper

#add_test_selector

Methods included from FetchOrFallbackHelper

#fetch_or_fallback, #fetch_or_fallback_boolean, #silence_deprecations?

Methods included from ClassNameHelper

#class_names

Methods included from Primer::AttributesHelper

#aria, #data, #extract_data, #merge_aria, #merge_data, #merge_prefixed_attribute_hashes

Methods included from ExperimentalSlotHelpers

included

Methods included from ExperimentalRenderHelpers

included

Constructor Details

#initialize(node_variant:, **system_arguments) ⇒ SubTree

Returns a new instance of SubTree.

Parameters:

  • node_variant (Symbol)

    The variant to use for this node. <%= one_of(Primer::Alpha::TreeView::NODE_VARIANT_OPTIONS) %>

  • system_arguments (Hash)

    The arguments accepted by <%= link_to_component(Primer::Alpha::TreeView::SubTreeContainer) %>.



96
97
98
99
100
101
102
103
104
105
# File 'app/components/primer/alpha/tree_view/sub_tree.rb', line 96

def initialize(node_variant:, **system_arguments)
  @node_variant = node_variant

  system_arguments[:data] = merge_data(
    system_arguments,
    { data: { target: "tree-view-sub-tree-node.subTree" } }
  )

  @container = SubTreeContainer.new(**system_arguments)
end

Instance Attribute Details

#node_variantObject (readonly)

Returns the value of attribute node_variant.



92
93
94
# File 'app/components/primer/alpha/tree_view/sub_tree.rb', line 92

def node_variant
  @node_variant
end

Instance Method Details

#defer?Boolean

Returns:

  • (Boolean)


107
108
109
# File 'app/components/primer/alpha/tree_view/sub_tree.rb', line 107

def defer?
  loader?
end

#with_leaf(**system_arguments, &block) ⇒ Object

Adds an leaf node to the tree. Leaf nodes are nodes that do not have children.

Parameters:

  • component_klass (Class)

    The class to use instead of the default <%= link_to_component(Primer::Alpha::TreeView::LeafNode) %>

  • system_arguments (Hash)

    These arguments are forwarded to <%= link_to_component(Primer::Alpha::TreeView::LeafNode) %>, or whatever class is passed as the ‘component_klass` argument.



5
6
# File 'app/components/primer/alpha/tree_view/sub_tree.rb', line 5

def with_leaf(**system_arguments, &block)
end

#with_loading_spinner(**system_arguments, &block) ⇒ Object

Adds a loader to this sub-tree that displays a skeleton animation while nodes are fetched from the server.

Parameters:

  • system_arguments (Hash)

    The arguments accepted by <%= link_to_component(Primer::Alpha::TreeView::SkeletonLoader) %>.



4
5
# File 'app/components/primer/alpha/tree_view/sub_tree.rb', line 4

def with_loading_spinner(**system_arguments, &block)
end

#with_sub_tree(**system_arguments, &block) ⇒ Object

Adds a sub-tree node to the tree. Sub-trees are nodes that have children, which can be both leaf nodes and other sub-trees.

Parameters:

  • component_klass (Class)

    The class to use instead of the default <%= link_to_component(Primer::Alpha::TreeView::SubTreeNode) %>

  • system_arguments (Hash)

    These arguments are forwarded to <%= link_to_component(Primer::Alpha::TreeView::SubTreeNode) %>, or whatever class is passed as the ‘component_klass` argument.



5
6
# File 'app/components/primer/alpha/tree_view/sub_tree.rb', line 5

def with_sub_tree(**system_arguments, &block)
end