Class: PhlexKit::SidebarMenuSkeleton
- Inherits:
-
BaseComponent
- Object
- Phlex::HTML
- BaseComponent
- PhlexKit::SidebarMenuSkeleton
- Defined in:
- app/components/phlex_kit/sidebar/sidebar_menu_skeleton.rb
Overview
Loading placeholder for a menu item, ported from shadcn/ui's
SidebarMenuSkeleton: an optional icon shimmer plus a text shimmer whose
width randomises 50–90% per render (their --skeleton-width trick).
show_icon: mirrors shadcn's showIcon. See sidebar.rb.
Instance Method Summary collapse
-
#initialize(show_icon: false, **attrs) ⇒ SidebarMenuSkeleton
constructor
A new instance of SidebarMenuSkeleton.
- #view_template ⇒ Object
Methods inherited from BaseComponent
Constructor Details
#initialize(show_icon: false, **attrs) ⇒ SidebarMenuSkeleton
Returns a new instance of SidebarMenuSkeleton.
7 8 9 10 |
# File 'app/components/phlex_kit/sidebar/sidebar_menu_skeleton.rb', line 7 def initialize(show_icon: false, **attrs) @show_icon = show_icon @attrs = attrs end |
Instance Method Details
#view_template ⇒ Object
12 13 14 15 16 17 |
# File 'app/components/phlex_kit/sidebar/sidebar_menu_skeleton.rb', line 12 def view_template div(**mix({ class: "pk-sidebar-menu-skeleton" }, @attrs)) do render Skeleton.new(class: "icon") if @show_icon render Skeleton.new(class: "text", style: "--pk-skeleton-width: #{rand(50..90)}%;") end end |