|
|
|
|
@ -1,12 +1,14 @@
|
|
|
|
|
import { observer } from "mobx-react-lite";
|
|
|
|
|
import { Moon, Palette, Sun, Wallpaper } from "lucide-react";
|
|
|
|
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
|
|
|
|
import { workspaceStore } from "@/store";
|
|
|
|
|
import { workspaceStore, userStore } from "@/store";
|
|
|
|
|
import { THEME_OPTIONS } from "@/utils/theme";
|
|
|
|
|
|
|
|
|
|
interface ThemeSelectProps {
|
|
|
|
|
value?: string;
|
|
|
|
|
onValueChange?: (theme: string) => void;
|
|
|
|
|
className?: string;
|
|
|
|
|
showEffectiveTheme?: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const THEME_ICONS: Record<string, JSX.Element> = {
|
|
|
|
|
@ -16,8 +18,13 @@ const THEME_ICONS: Record<string, JSX.Element> = {
|
|
|
|
|
whitewall: <Wallpaper className="w-4 h-4" />,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const ThemeSelect = ({ value, onValueChange, className }: ThemeSelectProps = {}) => {
|
|
|
|
|
const ThemeSelect = observer(({ value, onValueChange, className, showEffectiveTheme = false }: ThemeSelectProps = {}) => {
|
|
|
|
|
const currentTheme = value || workspaceStore.state.theme || "default";
|
|
|
|
|
|
|
|
|
|
// Calculate effective theme (user preference overrides workspace default)
|
|
|
|
|
const effectiveTheme = userStore.state.userGeneralSetting?.theme || workspaceStore.state.theme || "default";
|
|
|
|
|
|
|
|
|
|
const displayTheme = showEffectiveTheme ? effectiveTheme : currentTheme;
|
|
|
|
|
|
|
|
|
|
const handleThemeChange = (newTheme: Theme) => {
|
|
|
|
|
if (onValueChange) {
|
|
|
|
|
@ -32,6 +39,9 @@ const ThemeSelect = ({ value, onValueChange, className }: ThemeSelectProps = {})
|
|
|
|
|
<SelectTrigger className={className}>
|
|
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
|
<SelectValue placeholder="Select theme" />
|
|
|
|
|
{showEffectiveTheme && effectiveTheme !== currentTheme && (
|
|
|
|
|
<span className="text-xs text-muted-foreground">(effective: {effectiveTheme})</span>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</SelectTrigger>
|
|
|
|
|
<SelectContent>
|
|
|
|
|
@ -40,12 +50,15 @@ const ThemeSelect = ({ value, onValueChange, className }: ThemeSelectProps = {})
|
|
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
|
{THEME_ICONS[option.value]}
|
|
|
|
|
<span>{option.label}</span>
|
|
|
|
|
{showEffectiveTheme && option.value === effectiveTheme && (
|
|
|
|
|
<span className="text-xs text-green-600">✓</span>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</SelectItem>
|
|
|
|
|
))}
|
|
|
|
|
</SelectContent>
|
|
|
|
|
</Select>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export default ThemeSelect;
|
|
|
|
|
|