diff --git a/src/actions/actionExport.tsx b/src/actions/actionExport.tsx index b24c5e3d..cf303f79 100644 --- a/src/actions/actionExport.tsx +++ b/src/actions/actionExport.tsx @@ -5,6 +5,7 @@ import { ProjectName } from "../components/ProjectName"; import { ToolButton } from "../components/ToolButton"; import "../components/ToolIcon.scss"; import { Tooltip } from "../components/Tooltip"; +import { DarkModeToggle, Appearence } from "../components/DarkModeToggle"; import { loadFromJSON, saveAsJSON } from "../data"; import { t } from "../i18n"; import useIsMobile from "../is-mobile"; @@ -204,3 +205,31 @@ export const actionLoadScene = register({ /> ), }); + +export const actionExportWithDarkMode = register({ + name: "exportWithDarkMode", + perform: (_elements, appState, value) => { + return { + appState: { ...appState, exportWithDarkMode: value }, + commitToHistory: false, + }; + }, + PanelComponent: ({ appState, updateData }) => ( +
+ { + updateData(appearance === "dark"); + }} + title={t("labels.toggleExportColorScheme")} + /> +
+ ), +}); diff --git a/src/actions/types.ts b/src/actions/types.ts index 9d90efd8..ae1baefe 100644 --- a/src/actions/types.ts +++ b/src/actions/types.ts @@ -85,7 +85,8 @@ export type ActionName = | "alignHorizontallyCentered" | "distributeHorizontally" | "distributeVertically" - | "viewMode"; + | "viewMode" + | "exportWithDarkMode"; export interface Action { name: ActionName; diff --git a/src/appState.ts b/src/appState.ts index f77e6cff..dc418fbc 100644 --- a/src/appState.ts +++ b/src/appState.ts @@ -40,6 +40,7 @@ export const getDefaultAppState = (): Omit< errorMessage: null, exportBackground: true, exportEmbedScene: false, + exportWithDarkMode: false, fileHandle: null, gridSize: null, height: window.innerHeight, @@ -118,6 +119,7 @@ const APP_STATE_STORAGE_CONF = (< errorMessage: { browser: false, export: false }, exportBackground: { browser: true, export: false }, exportEmbedScene: { browser: true, export: false }, + exportWithDarkMode: { browser: true, export: false }, fileHandle: { browser: false, export: false }, gridSize: { browser: true, export: true }, height: { browser: false, export: false }, diff --git a/src/components/DarkModeToggle.tsx b/src/components/DarkModeToggle.tsx index 2cf7df07..06d02a64 100644 --- a/src/components/DarkModeToggle.tsx +++ b/src/components/DarkModeToggle.tsx @@ -10,13 +10,18 @@ export type Appearence = "light" | "dark"; export const DarkModeToggle = (props: { value: Appearence; onChange: (value: Appearence) => void; + title?: string; }) => { + const title = props.title + ? props.title + : props.value === "dark" + ? t("buttons.lightMode") + : t("buttons.darkMode"); + return (