Class: Shadcn::Sidebar::MenuSkeleton::Component

Inherits:
ApplicationViewComponent show all
Defined in:
app/components/shadcn/sidebar/menu_skeleton/component.rb

Overview

SidebarMenuSkeleton — a placeholder row. Upstream randomises the text width between 50% and 90% so a column of them does not look like a barcode (vendor/shadcn/ui/sidebar.tsx:611-613); the same range is used here, drawn once per instance.

Constant Summary

Constants inherited from ApplicationViewComponent

ApplicationViewComponent::CONTENTS_STYLE, ApplicationViewComponent::VOID_TAGS

Instance Attribute Summary collapse

Attributes inherited from ApplicationViewComponent

#attributes

Instance Method Summary collapse

Methods inherited from ApplicationViewComponent

#css_classes, default_tag, #merged_style, #render_element, #shadcn_t, slot_name, #style_variants, #tag_name

Constructor Details

#initialize(show_icon: false, **attributes) ⇒ Component

Returns a new instance of Component.



19
20
21
22
23
# File 'app/components/shadcn/sidebar/menu_skeleton/component.rb', line 19

def initialize(show_icon: false, **attributes)
  @show_icon = show_icon
  @width = "#{rand(50..89)}%"
  super(**attributes)
end

Instance Attribute Details

#show_iconObject (readonly)

Returns the value of attribute show_icon.



17
18
19
# File 'app/components/shadcn/sidebar/menu_skeleton/component.rb', line 17

def show_icon
  @show_icon
end

Instance Method Details

#callObject



29
30
31
# File 'app/components/shadcn/sidebar/menu_skeleton/component.rb', line 29

def call
  render_element(body: safe_join([ icon, text ].compact))
end

#element_attributes(**defaults) ⇒ Object



25
26
27
# File 'app/components/shadcn/sidebar/menu_skeleton/component.rb', line 25

def element_attributes(**defaults)
  super(**{ "data-sidebar" => "menu-skeleton" }.merge(defaults))
end