-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #72 from trycompai/lewis/user-portal
Lewis/user portal
- Loading branch information
Showing
9 changed files
with
221 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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 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,49 @@ | ||
"use client"; | ||
|
||
import { | ||
useChangeLocale, | ||
useCurrentLocale, | ||
useI18n, | ||
} from "@/app/locales/client"; | ||
import { languages } from "@/app/locales/client"; | ||
import { | ||
Select, | ||
SelectContent, | ||
SelectGroup, | ||
SelectItem, | ||
SelectTrigger, | ||
SelectValue, | ||
} from "@bubba/ui/select"; | ||
import { Globe } from "lucide-react"; | ||
|
||
export const LocaleSwitch = () => { | ||
const t = useI18n(); | ||
const locale = useCurrentLocale(); | ||
const changeLocale = useChangeLocale(); | ||
|
||
return ( | ||
<div className="flex items-center relative"> | ||
<Select | ||
defaultValue={locale} | ||
onValueChange={(value: keyof typeof languages) => changeLocale(value)} | ||
> | ||
<SelectTrigger className="w-full pl-6 pr-3 py-1.5 bg-transparent outline-none capitalize h-[32px] text-xs"> | ||
<SelectValue placeholder={t("language.placeholder")} /> | ||
</SelectTrigger> | ||
<SelectContent> | ||
<SelectGroup> | ||
{Object.entries(languages).map(([code, name]) => ( | ||
<SelectItem key={code} value={code} className="capitalize"> | ||
{name} | ||
</SelectItem> | ||
))} | ||
</SelectGroup> | ||
</SelectContent> | ||
</Select> | ||
|
||
<div className="absolute left-2 pointer-events-none"> | ||
<Globe size={12} /> | ||
</div> | ||
</div> | ||
); | ||
}; |
This file contains 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,64 @@ | ||
"use client"; | ||
|
||
import { useI18n } from "@/app/locales/client"; | ||
import { Monitor, Moon, Sun } from "lucide-react"; | ||
import { useTheme } from "next-themes"; | ||
|
||
import { | ||
Select, | ||
SelectContent, | ||
SelectGroup, | ||
SelectItem, | ||
SelectTrigger, | ||
SelectValue, | ||
} from "@bubba/ui/select"; | ||
|
||
type Theme = "dark" | "system" | "light"; | ||
|
||
type Props = { | ||
currentTheme?: Theme; | ||
}; | ||
|
||
const ThemeIcon = ({ currentTheme }: Props) => { | ||
switch (currentTheme) { | ||
case "dark": | ||
return <Moon size={12} />; | ||
case "system": | ||
return <Monitor size={12} />; | ||
default: | ||
return <Sun size={12} />; | ||
} | ||
}; | ||
|
||
export const ThemeSwitch = () => { | ||
const t = useI18n(); | ||
const { theme, setTheme, themes } = useTheme(); | ||
|
||
return ( | ||
<div className="flex items-center relative"> | ||
<Select | ||
defaultValue={theme} | ||
onValueChange={(value: Theme) => setTheme(value)} | ||
> | ||
<SelectTrigger className="w-full pl-6 pr-3 py-1.5 bg-transparent outline-none capitalize h-[32px] text-xs"> | ||
<SelectValue placeholder={t("user_menu.theme")} /> | ||
</SelectTrigger> | ||
<SelectContent> | ||
<SelectGroup> | ||
{themes.map((theme) => ( | ||
<SelectItem key={theme} value={theme} className="capitalize"> | ||
{t( | ||
`theme.options.${theme.toLowerCase() as "dark" | "system" | "light"}`, | ||
)} | ||
</SelectItem> | ||
))} | ||
</SelectGroup> | ||
</SelectContent> | ||
</Select> | ||
|
||
<div className="absolute left-2 pointer-events-none"> | ||
<ThemeIcon currentTheme={theme as Theme} /> | ||
</div> | ||
</div> | ||
); | ||
}; |
This file contains 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 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 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 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 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 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