Skip to content

Commit 8be3d4f

Browse files
authored
Add Skeleton component (#217)
1 parent d29fac6 commit 8be3d4f

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

lib/ruby_ui/skeleton/skeleton.rb

+17
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

test/ruby_ui/skeleton_test.rb

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# frozen_string_literal: true
2+
3+
require "test_helper"
4+
5+
class RubyUI::SkeletonTest < ComponentTest
6+
def test_render
7+
output = phlex do
8+
RubyUI::Skeleton(class: "w-14 h-14")
9+
end
10+
11+
assert_match(/div/, output)
12+
assert_match(/w-14/, output)
13+
assert_match(/h-14/, output)
14+
end
15+
end

0 commit comments

Comments
 (0)