Skip to content

Commit

Permalink
refactor(front): use variable
Browse files Browse the repository at this point in the history
  • Loading branch information
SARDONYX-sard committed Oct 20, 2024
1 parent 6f0774b commit 5cc9691
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import { Checkbox, FormControlLabel, Tooltip } from '@mui/material';

import { useStorageState } from '@/components/hooks/useStorageState/useStorageState';
import { useTranslation } from '@/components/hooks/useTranslation';
import { HIDDEN_CACHE_OBJ } from '@/lib/storage/cacheKeys';

import type { FormControlLabelProps } from '@mui/material';

type Props = Omit<FormControlLabelProps, 'control' | 'label'>;
const CACHE_KEY = 'run-script';

export const JsAutoRunButton = ({ ...props }: Props) => {
const { t } = useTranslation();
const [runScript, setRunScript] = useStorageState(CACHE_KEY, false);
const [runScript, setRunScript] = useStorageState(HIDDEN_CACHE_OBJ.runScript, false);

const title = (
<>
Expand All @@ -33,7 +33,7 @@ export const JsAutoRunButton = ({ ...props }: Props) => {
return (
<Tooltip title={title}>
<FormControlLabel
control={<Checkbox checked={runScript} name={`input-${CACHE_KEY}`} onClick={handleClick} />}
control={<Checkbox checked={runScript} name={`input-${HIDDEN_CACHE_OBJ.runScript}`} onClick={handleClick} />}
label={label}
{...props}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useTranslation } from '@/components/hooks/useTranslation';
import { useCssContext } from '@/components/providers/CssProvider';
import { useJsContext } from '@/components/providers/JsProvider';
import { CSS } from '@/lib/css';
import { PUB_CACHE_OBJ } from '@/lib/storage/cacheKeys';

import { type EditorInfo, EditorInitializer } from './EditorInitializer';

Expand All @@ -14,7 +15,7 @@ export const CodeEditor = () => {
const { css, setCss, setPreset } = useCssContext();
const { t } = useTranslation();

const [value, setValue] = useStorageState<'javascript' | 'css'>('editor-tab-select', 'javascript');
const [value, setValue] = useStorageState<'javascript' | 'css'>(PUB_CACHE_OBJ.editorTabSelect, 'javascript');
const handleTabChange: TabListProps['onChange'] = (_event, newValue) => {
setValue(newValue);
};
Expand Down

0 comments on commit 5cc9691

Please sign in to comment.