Skip to content

Commit 62eb3fd

Browse files
Fix: Layout and subcategory toggle regression (#49)
1 parent baa0f84 commit 62eb3fd

File tree

2 files changed

+54
-13
lines changed

2 files changed

+54
-13
lines changed

desktop/desktop.scss

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
grid-template-columns: 20% 80%;
55
grid-column-gap: 1em;
66
grid-row-gap: 3px;
7-
grid-template-areas: "sidebar navigation" "sidebar content";
8-
grid-template-rows: 65px 1fr;
97

108
@media screen and (max-width: 960px) {
119
grid-template-columns: 25% 75%;
@@ -18,6 +16,8 @@
1816
display: none;
1917
}
2018
}
19+
grid-template-areas: "sidebar navigation" "sidebar content";
20+
grid-template-rows: 65px 1fr;
2121

2222
.category-sidebar-outlet,
2323
.list-controls + .loading-container + span,
@@ -72,15 +72,19 @@
7272
}
7373
}
7474

75-
.category-sidebar-list {
76-
margin: 0;
77-
list-style: none;
75+
.category-sidebar {
76+
&-list {
77+
margin: 0;
78+
list-style: none;
79+
}
80+
}
7881

79-
&.show-children {
80-
.sidebar-category-toggle .d-icon {
81-
transform: rotate(90deg);
82-
}
82+
.category-sidebar-list-item {
83+
.sidebar-category-badge {
84+
background-color: var(--category-color);
85+
}
8386

87+
&.show-children {
8488
.subcategories {
8589
margin: 0.75em 0 0 0;
8690
height: auto;
@@ -92,6 +96,10 @@
9296
visibility: hidden !important;
9397
}
9498
}
99+
100+
.sidebar-category-toggle .d-icon {
101+
transform: rotate(90deg);
102+
}
95103
}
96104

97105
.subcategories {
@@ -145,10 +153,6 @@
145153
}
146154
}
147155

148-
.sidebar-category-badge {
149-
background-color: var(--category-color);
150-
}
151-
152156
&__parent-container {
153157
display: flex;
154158
align-items: baseline;
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# frozen_string_literal: true
2+
3+
describe "Sub Category Toggle", type: :system do
4+
let(:theme) do
5+
parent_theme = Fabricate(:theme, name: "Parent Theme")
6+
component = Fabricate(:theme, name: "Category Sidebar Navigation", component: true)
7+
parent_theme.set_default!
8+
end
9+
10+
before do
11+
theme
12+
upload_theme_component
13+
@category = Fabricate(:category, name: "Test Category")
14+
@subcategory = Fabricate(:category, name: "Test Subcategory", parent_category: @category)
15+
end
16+
17+
it "displays subcategories when toggle is clicked" do
18+
visit("/")
19+
20+
expect(page).to have_no_selector(".category-sidebar-list-item__parent.show-children")
21+
find(".sidebar-category-toggle").click
22+
expect(page).to have_selector(".category-sidebar-list-item__parent.show-children")
23+
expect(page).to have_selector(
24+
".category-sidebar-list-item-link.subcategory-item",
25+
text: @subcategory.name,
26+
)
27+
end
28+
29+
it "displays subcategories when on category page" do
30+
visit("/c/#{@category.id}")
31+
expect(page).to have_selector(".category-sidebar-list-item__parent.show-children")
32+
expect(page).to have_selector(
33+
".category-sidebar-list-item-link.subcategory-item",
34+
text: @subcategory.name,
35+
)
36+
end
37+
end

0 commit comments

Comments
 (0)