From 3fd7d09b3627027de264c1f183e91718255a51cb Mon Sep 17 00:00:00 2001 From: Mario Mohar Date: Sun, 15 Nov 2026 10:40:26 +0100 Subject: [PATCH] feat: show the most used tags as a cloud on the dashboard --- .../src/components/TagCloud/TagCloud.jsx | 79 +++++++++++++++++++ devboard/client/src/pages/Dashboard.jsx | 6 ++ 2 files changed, 85 insertions(+) create mode 100644 devboard/client/src/components/TagCloud/TagCloud.jsx diff --git a/devboard/client/src/components/TagCloud/TagCloud.jsx b/devboard/client/src/components/TagCloud/TagCloud.jsx new file mode 100644 index 0000000..869480a --- /dev/null +++ b/devboard/client/src/components/TagCloud/TagCloud.jsx @@ -0,0 +1,79 @@ +import React, { useMemo, useState } from "react"; +import { useBoard } from "../../context/BoardContext"; +import { TagIcon, ChevronDownIcon, ChevronUpIcon } from "../common/Icons"; + +const MAX_TAGS = 12; +const MIN_FONT_PX = 11; +const MAX_FONT_PX = 18; + +const TagCloud = () => { + // allTasks, not tasks: the filtered list would shrink the cloud down to the + // tags of the selected tag's tasks as soon as one is clicked. + const { allTasks, activeTag, setActiveTag } = useBoard(); + const [collapsed, setCollapsed] = useState(false); + + const topTags = useMemo(() => { + const counts = {}; + (allTasks || []).forEach((task) => { + // a tag listed twice on one task still counts once for that task + new Set(task.tags || []).forEach((tag) => { + if (tag) counts[tag] = (counts[tag] || 0) + 1; + }); + }); + return Object.entries(counts) + .sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0])) + .slice(0, MAX_TAGS); + }, [allTasks]); + + if (topTags.length === 0) return null; + + const highest = topTags[0][1]; + const lowest = topTags[topTags.length - 1][1]; + const fontSize = (count) => { + if (highest === lowest) return MIN_FONT_PX + 2; + const share = (count - lowest) / (highest - lowest); + return Math.round(MIN_FONT_PX + share * (MAX_FONT_PX - MIN_FONT_PX)); + }; + + return ( +
+ + + {!collapsed && ( +
+ {topTags.map(([tag, count]) => { + const active = activeTag === tag; + return ( + + ); + })} +
+ )} +
+ ); +}; + +export default TagCloud; diff --git a/devboard/client/src/pages/Dashboard.jsx b/devboard/client/src/pages/Dashboard.jsx index bf85a7d..387114d 100644 --- a/devboard/client/src/pages/Dashboard.jsx +++ b/devboard/client/src/pages/Dashboard.jsx @@ -7,6 +7,7 @@ import PomodoroTimer from "../components/Pomodoro/PomodoroTimer"; import TaskModal from "../components/Task/TaskModal"; import CommandPalette from "../components/common/CommandPalette"; import Heatmap from "../components/Heatmap/Heatmap"; +import TagCloud from "../components/TagCloud/TagCloud"; import {useBoard} from "../context/BoardContext"; import { useGithubStars } from "../hooks/useGithubStars"; import useXP from "../hooks/useXP"; @@ -2044,6 +2045,11 @@ ${stuck + {/* Most used tags */} +
+ +
+ {/* Pomodoro Timer Bar */}