Skip to content

Commit a717cc2

Browse files
authored
Add Skeleton component to the docs (#156)
1 parent 5232f11 commit a717cc2

File tree

5 files changed

+52
-0
lines changed

5 files changed

+52
-0
lines changed

app/components/ruby_ui/skeleton.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# frozen_string_literal: true
2+
3+
module RubyUI
4+
class Skeleton < Base
5+
def view_template(&)
6+
div(**attrs, &)
7+
end
8+
9+
private
10+
11+
def default_attrs
12+
{
13+
class: "animate-pulse rounded-md bg-primary/10"
14+
}
15+
end
16+
end
17+
end

app/controllers/docs_controller.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ def shortcut_key
166166
render Docs::ShortcutKeyView.new
167167
end
168168

169+
def skeleton
170+
render Docs::SkeletonView.new
171+
end
172+
169173
def switch
170174
render Docs::SwitchView.new
171175
end

app/views/components/shared/menu.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ def components
9494
{name: "Select", path: helpers.docs_select_path, badge: "New"},
9595
{name: "Sheet", path: helpers.docs_sheet_path},
9696
{name: "Shortcut Key", path: helpers.docs_shortcut_key_path},
97+
{name: "Skeleton", path: helpers.docs_skeleton_path, badge: "New"},
9798
{name: "Switch", path: helpers.docs_switch_path},
9899
{name: "Table", path: helpers.docs_table_path},
99100
{name: "Tabs", path: helpers.docs_tabs_path},

app/views/docs/skeleton_view.rb

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# frozen_string_literal: true
2+
3+
class Docs::SkeletonView < ApplicationView
4+
def view_template
5+
component = "Skeleton"
6+
7+
div(class: "max-w-2xl mx-auto w-full py-10 space-y-10") do
8+
render Docs::Header.new(title: "Skeleton", description: "Use to show a placeholder while content is loading.")
9+
10+
Heading(level: 2) { "Usage" }
11+
12+
render Docs::VisualCodeExample.new(title: "Example", context: self) do
13+
<<~RUBY
14+
div(class: "flex items-center space-x-4") do
15+
Skeleton(class: "h-12 w-12 rounded-full")
16+
div(class: "space-y-2") do
17+
Skeleton(class: "h-4 w-[250px]")
18+
Skeleton(class: "h-4 w-[200px]")
19+
end
20+
end
21+
RUBY
22+
end
23+
24+
render Components::ComponentSetup::Tabs.new(component_name: component)
25+
26+
render Docs::ComponentsTable.new(component_files(component))
27+
end
28+
end
29+
end

config/routes.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
get "select", to: "docs#select", as: :docs_select
4848
get "sheet", to: "docs#sheet", as: :docs_sheet
4949
get "shortcut_key", to: "docs#shortcut_key", as: :docs_shortcut_key
50+
get "skeleton", to: "docs#skeleton", as: :docs_skeleton
5051
get "switch", to: "docs#switch", as: :docs_switch
5152
get "table", to: "docs#table", as: :docs_table
5253
get "tabs", to: "docs#tabs", as: :docs_tabs

0 commit comments

Comments
 (0)