Skip to content

Commit c3f76e5

Browse files
Fix test and refactor
1 parent 21bbc44 commit c3f76e5

4 files changed

Lines changed: 18 additions & 36 deletions

File tree

app/assets/stylesheets/css/components/ui/dropdown.css

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
@apply text-content-secondary gap-1.5;
5757

5858
&.dropdown-menu__item--disabled {
59-
@apply opacity-60 pointer-events-none;
59+
@apply opacity-60;
6060
}
6161
}
6262

@@ -75,11 +75,7 @@
7575

7676
.dropdown-menu__item:focus-visible,
7777
.dropdown-menu__list > :is(a, button):focus-visible {
78-
@apply ring-2 ring-inset ring-content bg-primary outline-none;
79-
80-
&.menu__item--action {
81-
@apply ring-info-foreground;
82-
}
78+
@apply ring-2 ring-inset ring-info-foreground bg-primary outline-none;
8379
}
8480

8581
.dropdown-menu__icon,
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
.dropdown-card {
2-
@apply flex w-full flex-col items-stretch overflow-hidden rounded-lg border border-tertiary bg-secondary p-0.5;
2+
@apply overflow-hidden rounded-lg border border-tertiary bg-secondary p-0.5;
33
box-shadow: var(--box-shadow-dropdown-card);
44
}
55

66
.dropdown-card__body {
7-
@apply w-full min-w-0 overflow-hidden rounded-lg border border-tertiary bg-primary;
7+
@apply overflow-hidden rounded-lg border border-tertiary bg-primary;
88
}
Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
1-
<%= content_tag :div, class: class_names(
2-
"dropdown-card",
3-
@classes
4-
) do %>
5-
<% if header? %>
6-
<%= header %>
7-
<% end %>
1+
<%= content_tag :div, class: class_names("dropdown-card", @classes) do %>
2+
<%= header %>
83

9-
<% if body? %>
10-
<div class="dropdown-card__body">
11-
<%= body %>
12-
</div>
13-
<% end %>
4+
<div class="dropdown-card__body">
5+
<%= body %>
6+
</div>
147

15-
<% if footer? %>
16-
<%= footer %>
17-
<% end %>
8+
<%= footer %>
189
<% end %>

spec/components/avo/u_i/dropdown_card_component_spec.rb

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@
1010
end
1111

1212
expect(page).to have_css(".dropdown-card")
13-
expect(page).to have_css(".dropdown-card__header", text: "Header content")
14-
expect(page).to have_css(".dropdown-card__body")
15-
expect(page).to have_css(".dropdown-card__content", text: "Body content")
16-
expect(page).to have_css(".dropdown-card__footer", text: "Footer content")
13+
expect(page).to have_css(".dropdown-card", text: /Header content/)
14+
expect(page).to have_css(".dropdown-card__body", text: "Body content")
15+
expect(page).to have_css(".dropdown-card", text: /Footer content/)
1716
end
1817

1918
it "renders without header and footer when those slots are not provided" do
@@ -22,9 +21,7 @@
2221
end
2322

2423
expect(page).to have_css(".dropdown-card")
25-
expect(page).not_to have_css(".dropdown-card__header")
26-
expect(page).not_to have_css(".dropdown-card__footer")
27-
expect(page).to have_css(".dropdown-card__content", text: "Only body")
24+
expect(page).to have_css(".dropdown-card__body", text: "Only body")
2825
end
2926

3027
it "renders with header and body only" do
@@ -33,9 +30,8 @@
3330
c.with_body { "Body content" }
3431
end
3532

36-
expect(page).to have_css(".dropdown-card__header", text: "Header only")
37-
expect(page).to have_css(".dropdown-card__content", text: "Body content")
38-
expect(page).not_to have_css(".dropdown-card__footer")
33+
expect(page).to have_css(".dropdown-card", text: /Header only/)
34+
expect(page).to have_css(".dropdown-card__body", text: "Body content")
3935
end
4036

4137
it "renders with footer and body only" do
@@ -44,9 +40,8 @@
4440
c.with_footer { "Footer only" }
4541
end
4642

47-
expect(page).not_to have_css(".dropdown-card__header")
48-
expect(page).to have_css(".dropdown-card__content", text: "Body content")
49-
expect(page).to have_css(".dropdown-card__footer", text: "Footer only")
43+
expect(page).to have_css(".dropdown-card__body", text: "Body content")
44+
expect(page).to have_css(".dropdown-card", text: /Footer only/)
5045
end
5146

5247
it "applies extra classes via the classes prop" do

0 commit comments

Comments
 (0)