Skip to content

Commit

Permalink
style(ContentScripts、Popup、Option): 实现主题同步
Browse files Browse the repository at this point in the history
  • Loading branch information
couriourc committed Apr 20, 2024
1 parent b9a542c commit bb3bd86
Show file tree
Hide file tree
Showing 9 changed files with 170 additions and 38 deletions.
37 changes: 37 additions & 0 deletions assets/title.header-bg.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 40 additions & 18 deletions entrypoints/options/App.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React, {Suspense} from "react";
import {Select, SelectItem, Skeleton} from "@nextui-org/react";
import {Card, CardBody, CardHeader, Radio, RadioGroup, Skeleton} from "@nextui-org/react";
import {LangCode, supportedLanguages} from "@/shared/lang";
import {appStore, getPanelStore} from "@/shared/store";

setTimeout(() => {
console.log(getPanelStore());
});
import {useTheme} from "@/shared/hooks/useTheme.ts";
import {useSettingStore} from "@/shared/store";
import {LogoWithName} from "@/shared/components/Logo.tsx";
import {saveSettings} from "@/shared/config.ts";
import {UseThemeProps} from "next-themes/dist/types";
import {$t} from "@/shared/utils.ts";

interface ILanguageSelectorProps {
value?: string;
Expand All @@ -31,19 +32,40 @@ const langOptions: LangOption = supportedLanguages.reduce((acc, [id, label]) =>
})[]);

function LanguageSelector({value, onChange, onBlur}: ILanguageSelectorProps) {
const {themes,theme, setTheme} = useTheme();
console.log(useSettingStore());
return (
<Select
onChange={(event) => onChange(event.target.value)}
onBlur={onBlur}
value={value}
size={"sm"}
>
{
(langOptions as LangOption).map(({id, label}) => {
return <SelectItem value={id} key={id} variant={"flat"}>{label}</SelectItem>;
})
}
</Select>
<Card className={"w-full h-100vh"}>
<CardHeader className="flex z-0 top-1 flex-col !items-start">
<LogoWithName></LogoWithName>
</CardHeader>
<CardBody className={"z-10 "}>
<RadioGroup
label={$t("SelectYourFavoriteTheme")}
orientation="horizontal"
value={theme}
onChange={async (event) => {
const value = event.target.value! as UseThemeProps['systemTheme'];
await saveSettings({
theme: value,
});
//@ts-ignore
setTheme(value);
}}
>
{
themes.map(theme => {
return <Radio
value={theme}
key={theme}
className={"cursor-pointer"}>{theme}</Radio>;
})
}
</RadioGroup>
<div className={"flex gap-1"}>
</div>
</CardBody>
</Card>
);
}

Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,12 @@
"@nextui-org/badge": "^2.0.25",
"@nextui-org/button": "^2.0.28",
"@nextui-org/card": "^2.0.25",
"@nextui-org/chip": "^2.0.28",
"@nextui-org/divider": "^2.0.26",
"@nextui-org/dropdown": "^2.1.18",
"@nextui-org/image": "^2.0.27",
"@nextui-org/input": "^2.1.18",
"@nextui-org/radio": "^2.0.28",
"@nextui-org/react": "^2.3.0",
"@nextui-org/scroll-shadow": "^2.1.15",
"@nextui-org/select": "^2.1.22",
Expand Down
Loading

0 comments on commit bb3bd86

Please sign in to comment.