mirror of
https://github.com/gabehf/Koito.git
synced 2026-03-20 20:56:30 -07: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";
|
import type { Theme } from "~/styles/themes.css";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
theme: Theme
|
theme: Theme;
|
||||||
themeName: string
|
themeName: string;
|
||||||
setTheme: Function
|
setTheme: Function;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function ThemeOption({ theme, themeName, setTheme }: Props) {
|
export default function ThemeOption({ theme, themeName, setTheme }: Props) {
|
||||||
|
|
||||||
const capitalizeFirstLetter = (s: string) => {
|
const capitalizeFirstLetter = (s: string) => {
|
||||||
return s.charAt(0).toUpperCase() + s.slice(1);
|
return s.charAt(0).toUpperCase() + s.slice(1);
|
||||||
}
|
};
|
||||||
|
|
||||||
return (
|
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
|
||||||
<div className="text-xs sm:text-sm">{capitalizeFirstLetter(themeName)}</div>
|
onClick={() => setTheme(themeName)}
|
||||||
<div className="w-[50px] h-[30px] rounded-md" style={{background: theme.bgSecondary}}></div>
|
className="rounded-md p-3 sm:p-5 hover:cursor-pointer flex gap-3 items-center border-2 justify-between"
|
||||||
<div className="w-[50px] h-[30px] rounded-md" style={{background: theme.fgSecondary}}></div>
|
style={{
|
||||||
<div className="w-[50px] h-[30px] rounded-md" style={{background: theme.primary}}></div>
|
background: theme.bg,
|
||||||
|
color: theme.fg,
|
||||||
|
borderColor: theme.bgSecondary,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div className="text-xs sm:text-sm">
|
||||||
|
{capitalizeFirstLetter(themeName)}
|
||||||
</div>
|
</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>
|
<AsyncButton onClick={resetTheme}>Reset</AsyncButton>
|
||||||
</div>
|
</div>
|
||||||
</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]) => (
|
{Object.entries(themes).map(([name, themeData]) => (
|
||||||
<ThemeOption
|
<ThemeOption
|
||||||
setTheme={setTheme}
|
setTheme={setTheme}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue