From ba72217e21b787c1b09b92dc3255abc5027ede51 Mon Sep 17 00:00:00 2001 From: Robin Fernandes Date: Fri, 11 Aug 2023 09:09:01 +1000 Subject: [PATCH] #197, #198: darkmode and minor UX improvement to keyframe dialogs. --- src/components/KeyframeDialogs.tsx | 36 ++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/src/components/KeyframeDialogs.tsx b/src/components/KeyframeDialogs.tsx index 1f73ee7..cd9c706 100644 --- a/src/components/KeyframeDialogs.tsx +++ b/src/components/KeyframeDialogs.tsx @@ -25,6 +25,8 @@ import { frameToXAxisType, xAxisTypeToFrame } from '../utils/maths'; import * as _ from 'lodash'; import { parse } from '../parseq-lang/parseq-lang-parser'; import { InvocationContext } from '../parseq-lang/parseq-lang-ast'; +import { SupportedColorScheme, experimental_extendTheme as extendTheme, useColorScheme } from "@mui/material/styles"; +import { themeFactory } from '../theme'; interface AddKeyframesDialogProps { keyframes: ParseqKeyframe[]; @@ -53,6 +55,11 @@ export const AddKeyframesDialog: FC = ({ const [start, setStart] = useState("0"); const [end, setEnd] = useState(String(lastFrame)); + const theme = extendTheme(themeFactory()); + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const {colorScheme, setColorScheme } = useColorScheme(); + const palette = theme.colorSchemes[(colorScheme||'light') as SupportedColorScheme].palette; + function handleCloseAddKeyframesDialog(event: any): void { setOpenAddKeyframesDialog(false); if (event?.target?.id === "add") { @@ -181,17 +188,17 @@ export const AddKeyframesDialog: FC = ({ {framesToAdd.length > 0 && <> - + Will add {framesToAdd.length} keyframe(s): - + • Frames: {framesToAdd.sort((a, b) => a - b).join(', ')}
• Seconds: {framesToAdd.sort((a, b) => a - b).map(f => frameToXAxisType(f, "seconds", fps, bpm)).join(', ')}
• Beats: {framesToAdd.sort((a, b) => a - b).map(f => frameToXAxisType(f, "beats", fps, bpm)).join(', ')}
} {framesToAdd.length <= 0 && - + No frames to add. } @@ -240,6 +247,12 @@ export const DeleteKeyframesDialog: FC = ({ const [deleteMatchRegex, setDeleteMatchRegex] = useState(''); const [deleteMatchFieldType, setDeleteMatchFieldType] = useState<'value' | 'interpolation'>('value'); + const theme = extendTheme(themeFactory()); + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const {colorScheme, setColorScheme } = useColorScheme(); + const palette = theme.colorSchemes[(colorScheme||'light') as SupportedColorScheme].palette; + + useEffect(() => { setFramesToDeleteList(initialFramesToDelete.join(', ')); }, [initialFramesToDelete]); @@ -359,10 +372,10 @@ export const DeleteKeyframesDialog: FC = ({ {framesToDelete.length > 0 && <> - + Will delete {framesToDelete.length} keyframe(s): - + • Frames: {framesToDelete.sort((a, b) => a - b).join(', ')}
• Seconds: {framesToDelete.sort((a, b) => a - b).map(f => frameToXAxisType(f, "seconds", fps, bpm)).join(', ')}
• Beats: {framesToDelete.sort((a, b) => a - b).map(f => frameToXAxisType(f, "beats", fps, bpm)).join(', ')}
@@ -418,6 +431,11 @@ export const BulkEditDialog: FC = ({ const [fieldTypeToUpdate, setFieldTypeToUpdate] = useState<'value' | 'interpolation'>('value'); const [newValue, setNewValue] = useState(''); + const theme = extendTheme(themeFactory()); + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const {colorScheme, setColorScheme } = useColorScheme(); + const palette = theme.colorSchemes[(colorScheme||'light') as SupportedColorScheme].palette; + const framesToEdit = useMemo(() => { if (matchRegex) { return findMatchingKeyframes(keyframes, matchRegex, matchMethod, matchField, @@ -565,17 +583,17 @@ export const BulkEditDialog: FC = ({ {framesToEdit.length > 0 && <> - + Will edit {framesToEdit.length} keyframe(s): - + • Frames: {framesToEdit.sort((a, b) => a - b).join(', ')}
• Seconds: {framesToEdit.sort((a, b) => a - b).map(f => frameToXAxisType(f, "seconds", fps, bpm)).join(', ')}
• Beats: {framesToEdit.sort((a, b) => a - b).map(f => frameToXAxisType(f, "beats", fps, bpm)).join(', ')}
} {framesToEdit.length <= 0 && - + No frames to edit. } @@ -587,7 +605,7 @@ export const BulkEditDialog: FC = ({ Cancel