minor fix

This commit is contained in:
aurinex
2025-12-14 22:22:05 +05:00
parent ae4a67dcdf
commit 645de4248e
2 changed files with 36 additions and 18 deletions

View File

@ -12,6 +12,19 @@
url('../../assets/fonts/benzin-bold.svg#benzin-bold') format('svg'); /* Chrome < 4, Legacy iOS */
}
:root {
--ui-scale: 1;
}
#root {
transform: scale(var(--ui-scale));
transform-origin: top left;
/* компенсация, чтобы после scale не появлялись пустые области/скроллы */
width: calc(100% / var(--ui-scale));
height: calc(100% / var(--ui-scale));
}
body {
position: relative;
color: white;

View File

@ -157,8 +157,18 @@ const NotificationPositionPicker = ({
);
};
const mapNotifPosition = (
p: SettingsState['notificationPosition'],
): NotificationPosition => {
const [vertical, horizontal] = p.split('-') as ['top' | 'bottom', 'left' | 'center' | 'right'];
return { vertical, horizontal };
};
const Settings = () => {
const [lastSavedSettings, setLastSavedSettings] = useState<SettingsState>(() => {
if (typeof window === 'undefined') return defaultSettings;
return safeParseSettings(localStorage.getItem(STORAGE_KEY)) ?? defaultSettings;
});
const [notifOpen, setNotifOpen] = useState(false);
const [notifMsg, setNotifMsg] = useState<React.ReactNode>('');
const [notifSeverity, setNotifSeverity] = useState<
@ -176,22 +186,22 @@ const Settings = () => {
});
const dirty = useMemo(() => {
if (typeof window === 'undefined') return false;
const saved = safeParseSettings(localStorage.getItem(STORAGE_KEY)) ?? defaultSettings;
return JSON.stringify(saved) !== JSON.stringify(settings);
}, [settings]);
return JSON.stringify(settings) !== JSON.stringify(lastSavedSettings);
}, [settings, lastSavedSettings]);
const save = () => {
try {
localStorage.setItem(STORAGE_KEY, JSON.stringify(settings));
setLastSavedSettings(settings);
window.dispatchEvent(new CustomEvent('settings-updated'));
// если уведомления выключены — НЕ показываем нотификацию
if (!isNotificationsEnabled()) return;
setNotifMsg('Настройки успешно сохранены!');
setNotifSeverity('info');
setNotifPos(getNotifPositionFromSettings());
setNotifPos(mapNotifPosition(settings.notificationPosition));
setNotifOpen(true);
} catch (e) {
console.error('Не удалось сохранить настройки', e);
@ -200,6 +210,8 @@ const Settings = () => {
const reset = () => {
setSettings(defaultSettings);
setLastSavedSettings(defaultSettings);
try {
localStorage.setItem(STORAGE_KEY, JSON.stringify(defaultSettings));
} catch (e) {
@ -208,28 +220,21 @@ const Settings = () => {
};
const checkNotif = () => {
if (!settings.notifications) return; // если выключены — не показываем
setNotifMsg('Проверка уведомления!');
setNotifSeverity('info');
setNotifPos(getNotifPositionFromSettings());
setNotifPos(mapNotifPosition(settings.notificationPosition)); // 👈 важно
setNotifOpen(true);
}
};
// Apply a few settings instantly
useEffect(() => {
if (typeof document === 'undefined') return;
// UI scale (простая версия)
document.documentElement.style.zoom = `${settings.uiScale}%`;
// Reduce motion
const scale = settings.uiScale / 100;
document.documentElement.style.setProperty('--ui-scale', String(scale));
document.body.classList.toggle('reduce-motion', settings.reduceMotion);
// Blur effects (можно использовать этот класс в sx, если захочешь)
document.body.classList.toggle('no-blur', !settings.blurEffects);
// Persist
save();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [settings.uiScale, settings.reduceMotion, settings.blurEffects]);
const SectionTitle = ({ children }: { children: string }) => (