-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New light mood toggle icon #1328
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
Changes from 7 commits
6cc1399
87d31a0
086ac5f
ed3fe5e
c102b6c
c8a2216
2898073
96c004e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,23 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "use client"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { Moon, Sun } from "lucide-react"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { useTheme } from "@/app/(org)/dashboard/Contexts"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const ThemeToggleIcon = () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { theme } = useTheme(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <button | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type="button" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| className="view-transition-theme-icon" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| aria-label={ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| theme === "dark" ? "Switch to light theme" : "Switch to dark theme" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {theme === "dark" ? ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Moon size={17} className="fill-white stroke-gray-3" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) : ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Sun size={17} className="stroke-gray-12" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </button> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1
to
+17
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Filename should follow kebab-case convention. The filename As per coding guidelines. Apply this change:
-import { ThemeToggleIcon } from "@/components/ThemeToggleIcon";
+import { ThemeToggleIcon } from "@/components/theme-toggle-icon";
🤖 Prompt for AI Agents
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done renaming it, I hope you are happy now?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Enejivk, yes, thank you for renaming the file! 🎉 I really appreciate you following the kebab-case convention. This helps maintain consistency across the codebase, which makes it easier for everyone on the team to navigate and work with the files. Great work on this PR overall — the new theme toggle icon looks nice, and creating a reusable component was a smart move! 🧠 Learnings usedIf you found this review helpful, would you consider giving us a shout-out on X? Thank you for using CodeRabbit!
Comment on lines
+1
to
+17
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainFormat the file with Biome. As requested by @ameer2468 in the PR comments, please format this file with Biome to ensure consistency with the codebase standards. As per coding guidelines. Run the following command: 🏁 Script executed: pnpm formatLength of output: 273 🏁 Script executed: #!/bin/bash
# Check the actual indentation in the file
cat -A apps/web/components/theme-toggle-icon.tsxLength of output: 451 Format the file with Biome to convert tabs to 2-space indentation. The file currently uses tabs for indentation instead of the required 2-space indent. Run 🤖 Prompt for AI Agents
Comment on lines
+5
to
+17
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainButton lacks onClick handler to toggle the theme. The button has an aria-label indicating it should toggle the theme, but there's no Verify what the Once verified, apply a fix similar to this: export const ThemeToggleIcon = () => {
- const { theme } = useTheme();
+ const { theme, toggleTheme } = useTheme();
return (
<button
type="button"
className="view-transition-theme-icon"
+ onClick={toggleTheme}
aria-label={
theme === "dark" ? "Switch to light theme" : "Switch to dark theme"
}
>Note: Adjust the destructured property name (e.g., 🏁 Script executed: #!/bin/bash
# Check what properties/methods the ThemeContext provides
ast-grep --pattern $'export const ThemeContext = createContext<$_>($_)'
# Also check the ThemeProvider implementation to see available methods
rg -nP --type=tsx -A 10 'ThemeProvider|ThemeContext' apps/web/app/Length of output: 27 🏁 Script executed: #!/bin/bash
# Search for useTheme hook definition - check common locations
fd -e ts -e tsx | xargs grep -l "useTheme" | head -5
# Search for ThemeContext definition more broadly
rg -n "ThemeContext|useTheme" --type=ts -B 2 -A 5 | head -50
# Look for hook definition in lib or hooks directories
fd "use.*theme" -iLength of output: 3750 🏁 Script executed: #!/bin/bash
# Find the exact location and full content of theme-toggle-icon.tsx
fd "theme-toggle-icon" -e tsx
# Check how setThemeHandler is called in Top.tsx or other files
rg -n "setThemeHandler" --type=ts -B 2 -A 2Length of output: 3516 🏁 Script executed: #!/bin/bash
# Get the full content of theme-toggle-icon.tsx
cat apps/web/components/theme-toggle-icon.tsxLength of output: 530 Add onClick handler to enable theme toggling. The button is non-functional—it has no Fix at export const ThemeToggleIcon = () => {
- const { theme } = useTheme();
+ const { theme, setThemeHandler } = useTheme();
return (
<button
type="button"
className="view-transition-theme-icon"
+ onClick={() => {
+ if (document.startViewTransition) {
+ document.startViewTransition(() => {
+ setThemeHandler(theme === "light" ? "dark" : "light");
+ });
+ } else {
+ setThemeHandler(theme === "light" ? "dark" : "light");
+ }
+ }}
aria-label={
theme === "dark" ? "Switch to light theme" : "Switch to dark theme"
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.