From 2cdc03db92739f8332f7347f161ad3e5aa73a85c Mon Sep 17 00:00:00 2001 From: Ivan <8611739+IRBorisov@users.noreply.github.com> Date: Thu, 19 Dec 2024 18:49:08 +0300 Subject: [PATCH] F: Improve theme switcher --- .../src/app/Navigation/ToggleNavigation.tsx | 52 +++++++++++++------ .../frontend/src/components/ui/Modal.tsx | 21 ++++---- .../src/context/ConceptOptionsContext.tsx | 11 +++- 3 files changed, 55 insertions(+), 29 deletions(-) diff --git a/rsconcept/frontend/src/app/Navigation/ToggleNavigation.tsx b/rsconcept/frontend/src/app/Navigation/ToggleNavigation.tsx index 3f22354d..5a696366 100644 --- a/rsconcept/frontend/src/app/Navigation/ToggleNavigation.tsx +++ b/rsconcept/frontend/src/app/Navigation/ToggleNavigation.tsx @@ -1,35 +1,53 @@ import clsx from 'clsx'; -import { IconPin, IconUnpin } from '@/components/Icons'; +import { IconDarkTheme, IconLightTheme, IconPin, IconUnpin } from '@/components/Icons'; import { useConceptOptions } from '@/context/ConceptOptionsContext'; import { globals, PARAMETER } from '@/utils/constants'; function ToggleNavigation() { - const { noNavigationAnimation, toggleNoNavigation } = useConceptOptions(); + const { noNavigationAnimation, noNavigation, toggleNoNavigation, toggleDarkMode, darkMode } = useConceptOptions(); + const iconSize = !noNavigationAnimation ? '0.75rem' : '1rem'; return ( - + {!noNavigationAnimation ? ( + + ) : null} + + ); } diff --git a/rsconcept/frontend/src/components/ui/Modal.tsx b/rsconcept/frontend/src/components/ui/Modal.tsx index 41b2a31b..76af1d17 100644 --- a/rsconcept/frontend/src/components/ui/Modal.tsx +++ b/rsconcept/frontend/src/components/ui/Modal.tsx @@ -12,7 +12,6 @@ import BadgeHelp from '../info/BadgeHelp'; import { CProps } from '../props'; import Button from './Button'; import MiniButton from './MiniButton'; -import Overlay from './Overlay'; export interface ModalProps extends CProps.Styling { /** Title of the modal window. */ @@ -105,20 +104,20 @@ function Modal({ 'border rounded-xl bg-prim-100' )} > - - } - onClick={handleCancel} - /> - {helpTopic && !hideHelpWhen?.() ? ( - +
- +
) : null} + } + className='float-right mt-2 mr-2' + onClick={handleCancel} + /> + {header ?

{header}

: null}
{ ); const toggleDarkMode = useCallback(() => { - setDarkMode(prev => !prev); + if (!document.startViewTransition || window.matchMedia('(prefers-reduced-motion: reduce)').matches) { + setDarkMode(prev => !prev); + } else { + document.startViewTransition(() => { + flushSync(() => { + setDarkMode(prev => !prev); + }); + }); + } }, [setDarkMode]); const mainHeight = useMemo(() => {