-
Notifications
You must be signed in to change notification settings - Fork 0
Rename package category, create hero section with banner.svg, and implement accessible theme toggle #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Rename package category, create hero section with banner.svg, and implement accessible theme toggle #14
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c178439
Initial plan
Copilot 3c5995b
Implement website improvements: rename category, simplify banner, add…
Copilot 978d119
Add validation and SSR safety to theme provider
Copilot 9b29720
Remove icons from category definitions
AFeuerpfeil 0f9188e
Update people.ts
AFeuerpfeil 4df0ec9
Add files via upload
AFeuerpfeil e0cdf48
Use banner.svg and improve theme toggle accessibility
Copilot c3f7b5f
Transform banner into hero section with content overlay
Copilot 866d78c
Position hero content on left to avoid banner text overlap
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| "use client"; | ||
|
|
||
| import { createContext, useContext, useEffect, useState } from "react"; | ||
|
|
||
| type Theme = "light" | "dark"; | ||
|
|
||
| interface ThemeContextType { | ||
| theme: Theme; | ||
| toggleTheme: () => void; | ||
| } | ||
|
|
||
| const ThemeContext = createContext<ThemeContextType | undefined>(undefined); | ||
|
|
||
| export function ThemeProvider({ children }: { children: React.ReactNode }) { | ||
| const [theme, setTheme] = useState<Theme>(() => { | ||
| if (typeof window === "undefined") { | ||
| return "light"; | ||
| } | ||
|
|
||
| const savedTheme = window.localStorage.getItem("theme"); | ||
| if (savedTheme === "light" || savedTheme === "dark") { | ||
| return savedTheme; | ||
| } | ||
|
|
||
| const isDark = window.matchMedia("(prefers-color-scheme: dark)").matches; | ||
| return isDark ? "dark" : "light"; | ||
| }); | ||
|
|
||
| useEffect(() => { | ||
| if (typeof window === "undefined") return; | ||
| document.documentElement.classList.toggle("dark", theme === "dark"); | ||
| }, [theme]); | ||
|
|
||
| const toggleTheme = () => { | ||
| if (typeof window === "undefined") return; | ||
|
|
||
| const newTheme = theme === "light" ? "dark" : "light"; | ||
| setTheme(newTheme); | ||
| window.localStorage.setItem("theme", newTheme); | ||
| }; | ||
|
|
||
| return ( | ||
| <ThemeContext.Provider value={{ theme, toggleTheme }}> | ||
| {children} | ||
| </ThemeContext.Provider> | ||
| ); | ||
| } | ||
|
|
||
| export function useTheme() { | ||
| const context = useContext(ThemeContext); | ||
| if (context === undefined) { | ||
| throw new Error("useTheme must be used within a ThemeProvider"); | ||
| } | ||
| return context; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| "use client"; | ||
|
|
||
| import { useTheme } from "./theme-provider"; | ||
| import { useState, useEffect } from "react"; | ||
|
|
||
| export function ThemeToggle() { | ||
| const { theme, toggleTheme } = useTheme(); | ||
| const [mounted, setMounted] = useState(false); | ||
|
|
||
| useEffect(() => { | ||
| setMounted(true); | ||
| }, []); | ||
|
|
||
| // Prevent hydration mismatch by not rendering until mounted | ||
| if (!mounted) { | ||
| return ( | ||
| <div className="p-2 rounded-lg bg-gray-100 w-9 h-9" /> | ||
| ); | ||
| } | ||
|
|
||
| return ( | ||
| <button | ||
| onClick={toggleTheme} | ||
| className="p-2 rounded-lg bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors" | ||
| aria-pressed={theme === "dark"} | ||
| aria-label={`Switch to ${theme === "light" ? "dark" : "light"} mode`} | ||
| > | ||
| {theme === "light" ? ( | ||
| <svg | ||
| className="w-5 h-5 text-gray-800 dark:text-gray-200" | ||
| fill="none" | ||
| stroke="currentColor" | ||
| viewBox="0 0 24 24" | ||
| xmlns="http://www.w3.org/2000/svg" | ||
| > | ||
| <path | ||
| strokeLinecap="round" | ||
| strokeLinejoin="round" | ||
| strokeWidth={2} | ||
| d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z" | ||
| /> | ||
| </svg> | ||
| ) : ( | ||
| <svg | ||
| className="w-5 h-5 text-gray-800 dark:text-gray-200" | ||
| fill="none" | ||
| stroke="currentColor" | ||
| viewBox="0 0 24 24" | ||
| xmlns="http://www.w3.org/2000/svg" | ||
| > | ||
| <path | ||
| strokeLinecap="round" | ||
| strokeLinejoin="round" | ||
| strokeWidth={2} | ||
| d="M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z" | ||
| /> | ||
| </svg> | ||
| )} | ||
| </button> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The toggleTheme function should check if window is defined before accessing localStorage and document, similar to the useEffect. This prevents potential SSR errors if the function is somehow called during server-side rendering.