Skip to content

Commit 65deca5

Browse files
authored
New light mood toggle icon (#1328)
* feat: added sun icon for light mode theme toggle * extracting the theme icons into a seperate component * Removing hard coded color * Rename the file from ThemeToggleIcon.tsx to theme-toggle-icon.tsx * applying proper importing * Rearranging the import * Add accessibility attributes for screen readers. * Fixed the accessibility issue
1 parent 42b81e3 commit 65deca5

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

apps/web/app/(org)/dashboard/_components/Navbar/Mobile.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
"use client";
22

33
import { LogoBadge } from "@cap/ui";
4-
import { faMoon, faSun } from "@fortawesome/free-solid-svg-icons";
5-
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
64
import { useClickAway } from "@uidotdev/usehooks";
75
import { AnimatePresence, motion } from "framer-motion";
86
import { X } from "lucide-react";
97
import Link from "next/link";
108
import { type MutableRefObject, useState } from "react";
9+
10+
import { ThemeToggleIcon } from "@/components/theme-toggle-icon";
1111
import { useTheme } from "../../Contexts";
1212
import NavItems from "./Items";
1313

@@ -61,10 +61,7 @@ export const AdminMobileNav = () => {
6161
}}
6262
className="flex justify-center items-center rounded-full border transition-colors cursor-pointer lg:hidden bg-gray-4 hover:border-gray-6 hover:bg-gray-5 size-9 border-gray-5"
6363
>
64-
<FontAwesomeIcon
65-
className="text-gray-12 size-3.5"
66-
icon={theme === "dark" ? faSun : faMoon}
67-
/>
64+
<ThemeToggleIcon />
6865
</div>
6966
</div>
7067
</div>

apps/web/app/(org)/dashboard/_components/Navbar/Top.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
PopoverContent,
1010
PopoverTrigger,
1111
} from "@cap/ui";
12-
import { faBell, faMoon, faSun } from "@fortawesome/free-solid-svg-icons";
12+
import { faBell } from "@fortawesome/free-solid-svg-icons";
1313
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
1414
import { useMutation, useQueryClient } from "@tanstack/react-query";
1515
import { useClickAway } from "@uidotdev/usehooks";
@@ -31,6 +31,7 @@ import {
3131
import { markAsRead } from "@/actions/notifications/mark-as-read";
3232
import Notifications from "@/app/(org)/dashboard/_components/Notifications";
3333
import { SignedImageUrl } from "@/components/SignedImageUrl";
34+
import { ThemeToggleIcon } from "@/components/theme-toggle-icon";
3435
import { UpgradeModal } from "@/components/UpgradeModal";
3536
import { useDashboardContext, useTheme } from "../../Contexts";
3637
import {
@@ -170,10 +171,7 @@ const Top = () => {
170171
}}
171172
className="hidden justify-center items-center rounded-full transition-colors cursor-pointer bg-gray-3 lg:flex hover:bg-gray-5 size-9"
172173
>
173-
<FontAwesomeIcon
174-
className="text-gray-12 size-3.5 view-transition-theme-icon"
175-
icon={theme === "dark" ? faMoon : faSun}
176-
/>
174+
<ThemeToggleIcon />
177175
</div>
178176
<User />
179177
</div>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"use client";
2+
import { Moon, Sun } from "lucide-react";
3+
import { useTheme } from "@/app/(org)/dashboard/Contexts";
4+
5+
export const ThemeToggleIcon = () => {
6+
const { theme } = useTheme();
7+
8+
return (
9+
<span className="view-transition-theme-icon">
10+
{theme === "dark" ? (
11+
<Moon size={17} className="fill-white stroke-gray-3" />
12+
) : (
13+
<Sun size={17} className="stroke-gray-12" />
14+
)}
15+
</span>
16+
);
17+
};

0 commit comments

Comments
 (0)