disable undo button
This commit is contained in:
+9
-1
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
:root {
|
:root {
|
||||||
--clr-primary: #1976d2;
|
--clr-primary: #1976d2;
|
||||||
|
--clr-light-gray: #ddd;
|
||||||
|
--clr-dark-gray: #aaa;
|
||||||
--clr-code: rgba(0, 32, 90, 0.87);
|
--clr-code: rgba(0, 32, 90, 0.87);
|
||||||
--ff-primary: Roboto;
|
--ff-primary: Roboto;
|
||||||
--ff-code: "Roboto Mono";
|
--ff-code: "Roboto Mono";
|
||||||
@@ -54,7 +56,13 @@ code {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.btn-disabled, .btn[disabled] {
|
.btn-disabled, .btn[disabled] {
|
||||||
color: #aaa;
|
color: var(--clr-dark-gray);
|
||||||
|
background: var(--clr-light-gray);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-inverted.btn-disabled, .btn-inverted.btn[disabled] {
|
||||||
|
color: var(--clr-dark-gray);
|
||||||
|
background: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* App Bar */
|
/* App Bar */
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ function Level() {
|
|||||||
|
|
||||||
const [commandLineMode, setCommandLineMode] = useState(true)
|
const [commandLineMode, setCommandLineMode] = useState(true)
|
||||||
const [showSidePanel, setShowSidePanel] = useState(true)
|
const [showSidePanel, setShowSidePanel] = useState(true)
|
||||||
|
const [canUndo, setCanUndo] = useState(true)
|
||||||
|
|
||||||
const toggleSidePanel = () => {
|
const toggleSidePanel = () => {
|
||||||
setShowSidePanel(!showSidePanel)
|
setShowSidePanel(!showSidePanel)
|
||||||
@@ -114,6 +115,8 @@ function Level() {
|
|||||||
|
|
||||||
const onDidChangeContent = (code) => {
|
const onDidChangeContent = (code) => {
|
||||||
dispatch(codeEdited({world: worldId, level: levelId, code}))
|
dispatch(codeEdited({world: worldId, level: levelId, code}))
|
||||||
|
|
||||||
|
setCanUndo(code.trim() !== "")
|
||||||
}
|
}
|
||||||
|
|
||||||
const initialCode = useSelector(selectCode(worldId, levelId))
|
const initialCode = useSelector(selectCode(worldId, levelId))
|
||||||
@@ -157,7 +160,7 @@ function Level() {
|
|||||||
</div>
|
</div>
|
||||||
<div className="info-panel">
|
<div className="info-panel">
|
||||||
<div className="input-mode-switch">
|
<div className="input-mode-switch">
|
||||||
{commandLineMode && <button className="btn" onClick={handleUndo}><FontAwesomeIcon icon={faRotateLeft} /> Undo</button>}
|
{commandLineMode && <button className="btn" onClick={handleUndo} disabled={!canUndo}><FontAwesomeIcon icon={faRotateLeft} /> Undo</button>}
|
||||||
<FormGroup>
|
<FormGroup>
|
||||||
<FormControlLabel control={<Switch onChange={(ev) => { setCommandLineMode(!commandLineMode) }} />} label="Editor mode" />
|
<FormControlLabel control={<Switch onChange={(ev) => { setCommandLineMode(!commandLineMode) }} />} label="Editor mode" />
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
|
|||||||
Reference in New Issue
Block a user