From bdfbe3ffd67f5d27d7390863337353f44d00c94f Mon Sep 17 00:00:00 2001 From: Micha Date: Fri, 26 Dec 2025 16:50:27 +0100 Subject: [PATCH] Restyle home forum list --- CHANGELOG.md | 1 + frontend/src/index.css | 19 ++++++++ frontend/src/pages/Home.jsx | 92 ++++++++++++++++++++++++++++--------- 3 files changed, 90 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42c6fe3..4652f92 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,3 +21,4 @@ - Added system font stack to remove external font requests. - Improved ACP drag-and-drop hover reordering and visual drop target feedback. - Hardened ACP access so admin tools require authentication. +- Updated the home page to render the forum tree with ACP-style rows and icons. diff --git a/frontend/src/index.css b/frontend/src/index.css index 33c57aa..2c94ff6 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -94,6 +94,21 @@ a { padding: 1.2rem; } +.bb-forum-row { + background: rgba(255, 255, 255, 0.04); + transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease; +} + +.bb-forum-row:hover { + border-color: var(--bb-accent, #f29b3f); + box-shadow: 0 10px 24px rgba(14, 18, 27, 0.2); + transform: translateY(-1px); +} + +.bb-forum-link { + color: inherit; +} + .bb-footer { margin-top: auto; padding: 2rem 0; @@ -124,6 +139,10 @@ a { box-shadow: 0 12px 24px rgba(0, 0, 0, 0.35); } +[data-bs-theme="light"] .bb-forum-row { + background: #fff; +} + [data-bs-theme="dark"] .bb-chip { background: #20252f; color: #c7cdd7; diff --git a/frontend/src/pages/Home.jsx b/frontend/src/pages/Home.jsx index 90ea2a1..529a8ed 100644 --- a/frontend/src/pages/Home.jsx +++ b/frontend/src/pages/Home.jsx @@ -1,7 +1,7 @@ -import { useEffect, useState } from 'react' -import { Card, Col, Container, Row } from 'react-bootstrap' +import { useEffect, useMemo, useState } from 'react' +import { Container } from 'react-bootstrap' import { Link } from 'react-router-dom' -import { listRootForums } from '../api/client' +import { listAllForums } from '../api/client' import { useTranslation } from 'react-i18next' export default function Home() { @@ -11,12 +11,76 @@ export default function Home() { const { t } = useTranslation() useEffect(() => { - listRootForums() + listAllForums() .then(setForums) .catch((err) => setError(err.message)) .finally(() => setLoading(false)) }, []) + const getParentId = (forum) => { + if (!forum.parent) return null + if (typeof forum.parent === 'string') { + return forum.parent.split('/').pop() + } + return forum.parent.id ?? null + } + + const forumTree = useMemo(() => { + const map = new Map() + const roots = [] + + forums.forEach((forum) => { + map.set(String(forum.id), { ...forum, children: [] }) + }) + + forums.forEach((forum) => { + const parentId = getParentId(forum) + const node = map.get(String(forum.id)) + if (parentId && map.has(String(parentId))) { + map.get(String(parentId)).children.push(node) + } else { + roots.push(node) + } + }) + + const sortNodes = (nodes) => { + nodes.sort((a, b) => { + if (a.position !== b.position) return a.position - b.position + return a.name.localeCompare(b.name) + }) + nodes.forEach((node) => sortNodes(node.children)) + } + + sortNodes(roots) + + return roots + }, [forums]) + + const renderTree = (nodes, depth = 0) => + nodes.map((node) => ( +
+
+
+ + + +
+ + {node.name} + +
{node.description || t('forum.no_description')}
+
+
+
+ {node.children?.length > 0 && ( +
{renderTree(node.children, depth + 1)}
+ )} +
+ )) + return (
@@ -30,26 +94,10 @@ export default function Home() {

{t('home.browse')}

{loading &&

{t('home.loading')}

} {error &&

{error}

} - {!loading && forums.length === 0 && ( + {!loading && forumTree.length === 0 && (

{t('home.empty')}

)} - - {forums.map((forum) => ( - - - - {forum.name} - - {forum.description || t('forum.no_description')} - - - {t('forum.open')} - - - - - ))} - + {forumTree.length > 0 &&
{renderTree(forumTree)}
} ) }