From eca8bec0d896f065b093b7f61938d702e4e618a7 Mon Sep 17 00:00:00 2001 From: Yogesh Choudhary Paliyal Date: Fri, 9 May 2025 20:47:25 +0530 Subject: [PATCH 1/2] feat: added tool of the day --- src/App.tsx | 56 ++++++++++++++ src/components/ui/floating-action-button.tsx | 59 +++++++++++++++ src/components/ui/modal.tsx | 77 ++++++++++++++++++++ src/components/ui/tool-of-the-day.tsx | 67 +++++++++++++++++ src/lib/utils.ts | 34 +++++++++ 5 files changed, 293 insertions(+) create mode 100644 src/components/ui/floating-action-button.tsx create mode 100644 src/components/ui/modal.tsx create mode 100644 src/components/ui/tool-of-the-day.tsx diff --git a/src/App.tsx b/src/App.tsx index 85f9d3c..d3c0c3e 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -7,6 +7,9 @@ import { Pagination } from './components/ui/pagination' import { MasonryGrid } from './components/ui/masonry-grid' import { Header } from './components/ui/header' import { GitHubStats } from './components/ui/github-stats' +import { FloatingActionButton } from './components/ui/floating-action-button' +import { ToolOfTheDay } from './components/ui/tool-of-the-day' +import { getToolOfTheDay } from './lib/utils' // Define type for the tools interface Tool { @@ -73,10 +76,32 @@ function App() { const [currentPage, setCurrentPage] = useState(1); const [itemsPerPage] = useState(15); // Show 9 tools per page (3x3 grid) const [heroVisible, setHeroVisible] = useState(true); + const [toolOfTheDayOpen, setToolOfTheDayOpen] = useState(false); + const [toolOfTheDay, setToolOfTheDay] = useState(null); const heroRef = useRef(null); // Store random colors for each tool to ensure consistent colors between renders const [cardColors, setCardColors] = useState<{[key: string]: string}>({}); + + // Function to select the Tool of the Day using the date-based algorithm + const selectToolOfTheDay = () => { + const todaysTool = getToolOfTheDay(tools); + if (todaysTool) { + setToolOfTheDay(todaysTool); + setToolOfTheDayOpen(true); + } + }; + + // Use useEffect to initialize the Tool of the Day when the app loads + useEffect(() => { + if (tools.length > 0) { + const todaysTool = getToolOfTheDay(tools); + if (todaysTool) { + setToolOfTheDay(todaysTool); + // Don't automatically open the modal, just set the tool + } + } + }, [tools]); // Load data from data.json useEffect(() => { @@ -420,6 +445,37 @@ function App() {