Class: Yattho::Alpha::ActionList::Item
- Defined in:
- app/components/yattho/alpha/action_list/item.rb
Overview
An individual ‘ActionList` item. Items can optionally include leading and/or trailing visuals, such as icons, avatars, and counters.
Direct Known Subclasses
Constant Summary collapse
- DEFAULT_SIZE =
:medium
- SIZE_MAPPINGS =
{ DEFAULT_SIZE => nil, :large => "ActionListContent--sizeLarge", :xlarge => "ActionListContent--sizeXLarge" }.freeze
- SIZE_OPTIONS =
SIZE_MAPPINGS.keys.freeze
- DEFAULT_DESCRIPTION_SCHEME =
:block
- DESCRIPTION_SCHEME_MAPPINGS =
{ :inline => "ActionListItem-descriptionWrap--inline", DEFAULT_DESCRIPTION_SCHEME => "ActionListItem-descriptionWrap" }.freeze
- DESCRIPTION_SCHEME_OPTIONS =
DESCRIPTION_SCHEME_MAPPINGS.keys.freeze
- DEFAULT_SCHEME =
:default
- SCHEME_MAPPINGS =
{ DEFAULT_SCHEME => nil, :danger => "ActionListItem--danger" }.freeze
- SCHEME_OPTIONS =
SCHEME_MAPPINGS.keys.freeze
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
Instance Attribute Summary collapse
-
#active ⇒ Object
(also: #active?)
readonly
Returns the value of attribute active.
-
#disabled ⇒ Object
(also: #disabled?)
readonly
Returns the value of attribute disabled.
-
#href ⇒ Object
readonly
Returns the value of attribute href.
-
#list ⇒ Object
readonly
Returns the value of attribute list.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Instance Method Summary collapse
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
Constructor Details
#initialize(list:, label:, label_classes: nil, content_arguments: {}, parent: nil, truncate_label: false, href: nil, role: :listitem, size: DEFAULT_SIZE, scheme: DEFAULT_SCHEME, disabled: false, description_scheme: DEFAULT_DESCRIPTION_SCHEME, active: false, on_click: nil, id: self.class.generate_id, **system_arguments) ⇒ Item
Returns a new instance of Item.
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
# File 'app/components/yattho/alpha/action_list/item.rb', line 143 def initialize( list:, label:, label_classes: nil, content_arguments: {}, parent: nil, truncate_label: false, href: nil, role: :listitem, size: DEFAULT_SIZE, scheme: DEFAULT_SCHEME, disabled: false, description_scheme: DEFAULT_DESCRIPTION_SCHEME, active: false, on_click: nil, id: self.class.generate_id, **system_arguments ) @list = list @parent = parent @label = label @href = href @truncate_label = truncate_label @disabled = disabled @active = active @trailing_action_on_hover = false @id = id @system_arguments = system_arguments @content_arguments = content_arguments @size = fetch_or_fallback(SIZE_OPTIONS, size, DEFAULT_SIZE) @scheme = fetch_or_fallback(SCHEME_OPTIONS, scheme, DEFAULT_SCHEME) @description_scheme = fetch_or_fallback( DESCRIPTION_SCHEME_OPTIONS, description_scheme, DEFAULT_DESCRIPTION_SCHEME ) @system_arguments[:classes] = class_names( @system_arguments[:classes], SCHEME_MAPPINGS[@scheme], "ActionListItem" ) @system_arguments[:role] = role @system_arguments[:aria] ||= {} @system_arguments[:aria][:disabled] = "true" if @disabled @label_arguments = { classes: class_names( label_classes, "ActionListItem-label", "ActionListItem-label--truncate" => @truncate_label ) } @content_arguments[:id] = @id @content_arguments[:classes] = class_names( @content_arguments[:classes], "ActionListContent", SIZE_MAPPINGS[@size] ) if @href && !@disabled @content_arguments[:tag] = :a @content_arguments[:href] = @href else @content_arguments[:tag] = :button @content_arguments[:onclick] = on_click if on_click end @description_wrapper_arguments = { classes: class_names( "ActionListItem-descriptionWrap", DESCRIPTION_SCHEME_MAPPINGS[@description_scheme] ) } end |
Instance Attribute Details
#active ⇒ Object (readonly) Also known as: active?
Returns the value of attribute active.
115 116 117 |
# File 'app/components/yattho/alpha/action_list/item.rb', line 115 def active @active end |
#disabled ⇒ Object (readonly) Also known as: disabled?
Returns the value of attribute disabled.
115 116 117 |
# File 'app/components/yattho/alpha/action_list/item.rb', line 115 def disabled @disabled end |
#href ⇒ Object (readonly)
Returns the value of attribute href.
115 116 117 |
# File 'app/components/yattho/alpha/action_list/item.rb', line 115 def href @href end |
#list ⇒ Object (readonly)
Returns the value of attribute list.
115 116 117 |
# File 'app/components/yattho/alpha/action_list/item.rb', line 115 def list @list end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
115 116 117 |
# File 'app/components/yattho/alpha/action_list/item.rb', line 115 def parent @parent end |