import React, { useState } from "react"; import { Modal } from "../../ui/React/Modal"; import Button from "@mui/material/Button"; import ButtonGroup from "@mui/material/ButtonGroup"; import Typography from "@mui/material/Typography"; import Tooltip from "@mui/material/Tooltip"; import Paper from "@mui/material/Paper"; import TextField from "@mui/material/TextField"; import IconButton from "@mui/material/IconButton"; import ReplyIcon from "@mui/icons-material/Reply"; import PaletteSharpIcon from "@mui/icons-material/PaletteSharp"; import HistoryIcon from "@mui/icons-material/History"; import { Color, ColorPicker } from "material-ui-color"; import { ThemeEvents } from "./Theme"; import { Settings, defaultSettings } from "../../Settings/Settings"; import { defaultTheme } from "../Themes"; import { UserInterfaceTheme } from "../../ScriptEditor/NetscriptDefinitions"; import { IRouter } from "../../ui/Router"; import { ThemeCollaborate } from "./ThemeCollaborate"; interface IProps { open: boolean; onClose: () => void; router: IRouter; } interface IColorEditorProps { name: string; color: string | undefined; onColorChange: (name: string, value: string) => void; defaultColor: string; } function ColorEditor({ name, onColorChange, color, defaultColor }: IColorEditorProps): React.ReactElement { if (color === undefined) { console.error(`color ${name} was undefined, reverting to default`); color = defaultColor; } return ( <> onColorChange(name, "#" + newColor.hex)} disableAlpha /> ), endAdornment: ( <> onColorChange(name, defaultColor)}> ), }} /> ); } export function ThemeEditorModal(props: IProps): React.ReactElement { const [customTheme, setCustomTheme] = useState<{ [key: string]: string | undefined }>({ ...Settings.theme, }); function setTheme(theme: UserInterfaceTheme): void { setCustomTheme(theme); Object.assign(Settings.theme, theme); ThemeEvents.emit(); } function onThemeChange(event: React.ChangeEvent): void { try { const importedTheme = JSON.parse(event.target.value); if (typeof importedTheme !== "object") return; setCustomTheme(importedTheme); for (const key of Object.keys(importedTheme)) { Settings.theme[key] = importedTheme[key]; } ThemeEvents.emit(); } catch (err) { // ignore } } function onColorChange(name: string, value: string): void { setCustomTheme((old: any) => { old[name] = value; return old; }); Settings.theme[name] = value; ThemeEvents.emit(); } function setTemplateTheme(theme: UserInterfaceTheme): void { setTheme(theme); } return ( Example tooltip}>
text with primary color   text with secondary color   text with error color







<> Backup your theme or share it with others by copying the string above.
); }