feat: Topics page loads with all categories collapsed; expand/collapse…
- "frontend/src/pages/TopicsBrowse.tsx" - "frontend/src/App.css" GSD-Task: S02/T01
This commit is contained in:
parent
df559bbca0
commit
a9b65fcea9
2 changed files with 16 additions and 4 deletions
|
|
@ -2315,7 +2315,19 @@ a.app-footer__repo:hover {
|
||||||
|
|
||||||
/* ── Sub-topics inside card ───────────────────────────────────────────────── */
|
/* ── Sub-topics inside card ───────────────────────────────────────────────── */
|
||||||
|
|
||||||
|
.topic-subtopics-wrapper {
|
||||||
|
display: grid;
|
||||||
|
grid-template-rows: 0fr;
|
||||||
|
transition: grid-template-rows 300ms ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.topic-subtopics-wrapper[data-expanded="true"] {
|
||||||
|
grid-template-rows: 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
.topic-subtopics {
|
.topic-subtopics {
|
||||||
|
overflow: hidden;
|
||||||
|
min-height: 0;
|
||||||
border-top: 1px solid var(--color-border);
|
border-top: 1px solid var(--color-border);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,8 @@ export default function TopicsBrowse() {
|
||||||
const data = await fetchTopics();
|
const data = await fetchTopics();
|
||||||
if (!cancelled) {
|
if (!cancelled) {
|
||||||
setCategories(data);
|
setCategories(data);
|
||||||
// All expanded by default
|
// Start collapsed
|
||||||
setExpanded(new Set(data.map((c) => c.name)));
|
setExpanded(new Set());
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (!cancelled) {
|
if (!cancelled) {
|
||||||
|
|
@ -151,7 +151,7 @@ export default function TopicsBrowse() {
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{isExpanded && (
|
<div className="topic-subtopics-wrapper" data-expanded={isExpanded}>
|
||||||
<div className="topic-subtopics">
|
<div className="topic-subtopics">
|
||||||
{cat.sub_topics.map((st) => {
|
{cat.sub_topics.map((st) => {
|
||||||
const stSlug = st.name.toLowerCase().replace(/\s+/g, "-");
|
const stSlug = st.name.toLowerCase().replace(/\s+/g, "-");
|
||||||
|
|
@ -175,7 +175,7 @@ export default function TopicsBrowse() {
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
)}
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue