From a1ce6f696ac65dce9252b33e2abba4f53120ffc4 Mon Sep 17 00:00:00 2001 From: captain-Akshay Date: Tue, 19 Sep 2023 13:38:37 +0530 Subject: [PATCH 1/3] feat: added a better theme change ability for user --- .../(dashboard)/layout/profile-dropdown.tsx | 51 ++++++++++--------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/apps/web/src/components/(dashboard)/layout/profile-dropdown.tsx b/apps/web/src/components/(dashboard)/layout/profile-dropdown.tsx index 9ae9b4297..4d30d30d4 100644 --- a/apps/web/src/components/(dashboard)/layout/profile-dropdown.tsx +++ b/apps/web/src/components/(dashboard)/layout/profile-dropdown.tsx @@ -1,5 +1,7 @@ 'use client'; +import { useState } from 'react'; + import Link from 'next/link'; import { @@ -8,7 +10,6 @@ import { Key, LogOut, User as LucideUser, - Monitor, Moon, Sun, UserCog, @@ -26,9 +27,17 @@ import { DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, + DropdownMenuPortal, + DropdownMenuRadioGroup, + DropdownMenuRadioItem, DropdownMenuSeparator, + DropdownMenuSub, + DropdownMenuSubContent, + DropdownMenuSubTrigger, DropdownMenuTrigger, } from '@documenso/ui/primitives/dropdown-menu'; +import { Label } from '@documenso/ui/primitives/label'; +import { Switch } from '@documenso/ui/primitives/switch'; import { useFeatureFlags } from '~/providers/feature-flag'; @@ -37,10 +46,15 @@ export type ProfileDropdownProps = { }; export const ProfileDropdown = ({ user }: ProfileDropdownProps) => { - const { theme, setTheme } = useTheme(); const { getFlag } = useFeatureFlags(); + const { theme, setTheme } = useTheme(); const isUserAdmin = isAdmin(user); + const [isDarkMode, setIsDarkMode] = useState(theme === 'dark'); + const toggleDarkMode = () => { + setIsDarkMode(!isDarkMode); + setTheme(isDarkMode ? 'light' : 'dark'); + }; const isBillingEnabled = getFlag('app_billing'); const avatarFallback = user.name @@ -98,28 +112,19 @@ export const ProfileDropdown = ({ user }: ProfileDropdownProps) => { - {theme === 'light' ? null : ( - setTheme('light')}> - - Light Mode - - )} - {theme === 'dark' ? null : ( - setTheme('dark')}> - - Dark Mode - - )} - - {theme === 'system' ? null : ( - setTheme('system')}> - - System Theme - - )} - + + Themes + + + + Light + Dark + System + + + + - From 4cd56fa98cfe6bf86c056e718396d16251995b6b Mon Sep 17 00:00:00 2001 From: captain-Akshay Date: Tue, 19 Sep 2023 19:45:21 +0530 Subject: [PATCH 2/3] feat: removed unecessary code to the file and made few UI changes --- .../(dashboard)/layout/profile-dropdown.tsx | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/apps/web/src/components/(dashboard)/layout/profile-dropdown.tsx b/apps/web/src/components/(dashboard)/layout/profile-dropdown.tsx index 4d30d30d4..962187c1b 100644 --- a/apps/web/src/components/(dashboard)/layout/profile-dropdown.tsx +++ b/apps/web/src/components/(dashboard)/layout/profile-dropdown.tsx @@ -1,7 +1,5 @@ 'use client'; -import { useState } from 'react'; - import Link from 'next/link'; import { @@ -10,6 +8,7 @@ import { Key, LogOut, User as LucideUser, + Monitor, Moon, Sun, UserCog, @@ -36,8 +35,6 @@ import { DropdownMenuSubTrigger, DropdownMenuTrigger, } from '@documenso/ui/primitives/dropdown-menu'; -import { Label } from '@documenso/ui/primitives/label'; -import { Switch } from '@documenso/ui/primitives/switch'; import { useFeatureFlags } from '~/providers/feature-flag'; @@ -49,12 +46,7 @@ export const ProfileDropdown = ({ user }: ProfileDropdownProps) => { const { getFlag } = useFeatureFlags(); const { theme, setTheme } = useTheme(); const isUserAdmin = isAdmin(user); - const [isDarkMode, setIsDarkMode] = useState(theme === 'dark'); - const toggleDarkMode = () => { - setIsDarkMode(!isDarkMode); - setTheme(isDarkMode ? 'light' : 'dark'); - }; const isBillingEnabled = getFlag('app_billing'); const avatarFallback = user.name @@ -117,9 +109,17 @@ export const ProfileDropdown = ({ user }: ProfileDropdownProps) => { - Light - Dark - System + + Light + + + + Dark + + + + System + From 7771d7acbe13cd2284d38df26a521befa958ac0d Mon Sep 17 00:00:00 2001 From: captain-Akshay Date: Wed, 20 Sep 2023 06:56:40 +0530 Subject: [PATCH 3/3] feat: added the icon for theme --- .../src/components/(dashboard)/layout/profile-dropdown.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/web/src/components/(dashboard)/layout/profile-dropdown.tsx b/apps/web/src/components/(dashboard)/layout/profile-dropdown.tsx index 962187c1b..91b045feb 100644 --- a/apps/web/src/components/(dashboard)/layout/profile-dropdown.tsx +++ b/apps/web/src/components/(dashboard)/layout/profile-dropdown.tsx @@ -10,6 +10,7 @@ import { User as LucideUser, Monitor, Moon, + Palette, Sun, UserCog, } from 'lucide-react'; @@ -105,7 +106,10 @@ export const ProfileDropdown = ({ user }: ProfileDropdownProps) => { - Themes + + + Themes +