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() {