Files
actual/packages/desktop-client/src/components/ThemeSelector.tsx
Matiss Janis Aboltins 15358b6b54 [AI] Remove development theme (#7232)
* [AI] Remove development theme

Delete the development theme that was only available in non-production
environments. Removes the theme file, its registration in the theme
registry, type definitions, preference validation, ThemeSelector icon
mapping, and Storybook configuration.

https://claude.ai/code/session_01A1aEippeWppuwoRSCBPwby

* Add release notes for PR #7232

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-03-17 19:18:47 +00:00

77 lines
1.9 KiB
TypeScript

import React, { useRef, useState } from 'react';
import type { CSSProperties } from 'react';
import { useTranslation } from 'react-i18next';
import { Button } from '@actual-app/components/button';
import { useResponsive } from '@actual-app/components/hooks/useResponsive';
import {
SvgMoonStars,
SvgSun,
SvgSystem,
} from '@actual-app/components/icons/v2';
import { Menu } from '@actual-app/components/menu';
import { Popover } from '@actual-app/components/popover';
import type { Theme } from 'loot-core/types/prefs';
import { themeOptions, useTheme } from '@desktop-client/style';
type ThemeSelectorProps = {
style?: CSSProperties;
};
export function ThemeSelector({ style }: ThemeSelectorProps) {
const [theme, switchTheme] = useTheme();
const [menuOpen, setMenuOpen] = useState(false);
const triggerRef = useRef(null);
const { isNarrowWidth } = useResponsive();
const { t } = useTranslation();
const themeIcons = {
light: SvgSun,
dark: SvgMoonStars,
auto: SvgSystem,
midnight: SvgMoonStars,
} as const;
type ThemeIconKey = keyof typeof themeIcons;
function onMenuSelect(newTheme: Theme) {
setMenuOpen(false);
switchTheme(newTheme);
}
const Icon = themeIcons[theme as ThemeIconKey] || SvgSun;
if (isNarrowWidth) {
return null;
}
return (
<>
<Button
ref={triggerRef}
variant="bare"
aria-label={t('Switch theme')}
onPress={() => setMenuOpen(true)}
style={style}
>
<Icon style={{ width: 13, height: 13, color: 'inherit' }} />
</Button>
<Popover
offset={8}
triggerRef={triggerRef}
isOpen={menuOpen}
onOpenChange={() => setMenuOpen(false)}
>
<Menu
onMenuSelect={onMenuSelect}
items={themeOptions.map(([name, text]) => ({ name, text }))}
/>
</Popover>
</>
);
}