mirror of
https://github.com/gabehf/Koito.git
synced 2026-03-07 13:38:15 -08:00
improve theme selector for mobile
This commit is contained in:
parent
c1c376eb2a
commit
b16b160f20
2 changed files with 37 additions and 17 deletions
|
|
@ -1,23 +1,43 @@
|
|||
import type { Theme } from "~/styles/themes.css";
|
||||
|
||||
interface Props {
|
||||
theme: Theme
|
||||
themeName: string
|
||||
setTheme: Function
|
||||
theme: Theme;
|
||||
themeName: string;
|
||||
setTheme: Function;
|
||||
}
|
||||
|
||||
export default function ThemeOption({ theme, themeName, setTheme }: Props) {
|
||||
const capitalizeFirstLetter = (s: string) => {
|
||||
return s.charAt(0).toUpperCase() + s.slice(1);
|
||||
};
|
||||
|
||||
const capitalizeFirstLetter = (s: string) => {
|
||||
return s.charAt(0).toUpperCase() + s.slice(1);
|
||||
}
|
||||
|
||||
return (
|
||||
<div onClick={() => setTheme(themeName)} className="rounded-md p-3 sm:p-5 hover:cursor-pointer flex gap-4 items-center border-2" style={{background: theme.bg, color: theme.fg, borderColor: theme.bgSecondary}}>
|
||||
<div className="text-xs sm:text-sm">{capitalizeFirstLetter(themeName)}</div>
|
||||
<div className="w-[50px] h-[30px] rounded-md" style={{background: theme.bgSecondary}}></div>
|
||||
<div className="w-[50px] h-[30px] rounded-md" style={{background: theme.fgSecondary}}></div>
|
||||
<div className="w-[50px] h-[30px] rounded-md" style={{background: theme.primary}}></div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<div
|
||||
onClick={() => setTheme(themeName)}
|
||||
className="rounded-md p-3 sm:p-5 hover:cursor-pointer flex gap-3 items-center border-2 justify-between"
|
||||
style={{
|
||||
background: theme.bg,
|
||||
color: theme.fg,
|
||||
borderColor: theme.bgSecondary,
|
||||
}}
|
||||
>
|
||||
<div className="text-xs sm:text-sm">
|
||||
{capitalizeFirstLetter(themeName)}
|
||||
</div>
|
||||
<div className="flex gap-2 w-full">
|
||||
<div
|
||||
className="w-2/7 max-w-[50px] h-[30px] rounded-md"
|
||||
style={{ background: theme.bgSecondary }}
|
||||
></div>
|
||||
<div
|
||||
className="w-2/7 max-w-[50px] h-[30px] rounded-md"
|
||||
style={{ background: theme.fgSecondary }}
|
||||
></div>
|
||||
<div
|
||||
className="w-2/7 max-w-[50px] h-[30px] rounded-md"
|
||||
style={{ background: theme.primary }}
|
||||
></div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ export function ThemeSwitcher() {
|
|||
<AsyncButton onClick={resetTheme}>Reset</AsyncButton>
|
||||
</div>
|
||||
</div>
|
||||
<div className="grid grid-cols-2 items-center gap-2">
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 items-center gap-2">
|
||||
{Object.entries(themes).map(([name, themeData]) => (
|
||||
<ThemeOption
|
||||
setTheme={setTheme}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue