mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-14 18:46:17 +00:00
app: Move docs button component.
Everything is visually unchanged. This just moves the button logic to the app, since it doesn't conceptually belong to the editor component. It controls things such as docs which has nothing to do with the editor. This way we don't have to pass states as props around when we add more buttons later.
This commit is contained in:
+16
-2
@@ -3,7 +3,8 @@
|
||||
|
||||
import 'react-splitter-layout/lib/index.css';
|
||||
import './app.scss';
|
||||
import { Classes, Spinner } from '@blueprintjs/core';
|
||||
import { Button, Classes, Spinner } from '@blueprintjs/core';
|
||||
import { Manual } from '@blueprintjs/icons';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import SplitterLayout from 'react-splitter-layout';
|
||||
import { useLocalStorage, useTernaryDarkMode } from 'usehooks-ts';
|
||||
@@ -71,7 +72,8 @@ const Docs: React.FunctionComponent = () => {
|
||||
const App: React.FunctionComponent = () => {
|
||||
const i18n = useI18n();
|
||||
const { isDarkMode } = useTernaryDarkMode();
|
||||
const { isSettingShowDocsEnabled } = useSettingIsShowDocsEnabled();
|
||||
const { isSettingShowDocsEnabled, toggleIsSettingShowDocsEnabled } =
|
||||
useSettingIsShowDocsEnabled();
|
||||
const [isDragging, setIsDragging] = useState(false);
|
||||
|
||||
const [docsSplit, setDocsSplit] = useLocalStorage('app-docs-split', 30);
|
||||
@@ -140,6 +142,18 @@ const App: React.FunctionComponent = () => {
|
||||
>
|
||||
<Editor />
|
||||
</React.Suspense>
|
||||
<Button
|
||||
className="pb-app-doc-button"
|
||||
minimal
|
||||
large
|
||||
icon={<Manual />}
|
||||
title={
|
||||
isSettingShowDocsEnabled
|
||||
? i18n.translate('docs.hide')
|
||||
: i18n.translate('docs.show')
|
||||
}
|
||||
onClick={toggleIsSettingShowDocsEnabled}
|
||||
/>
|
||||
</main>
|
||||
<aside
|
||||
className="pb-app-terminal"
|
||||
|
||||
@@ -71,6 +71,7 @@
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
position: relative;
|
||||
|
||||
& .pb-editor {
|
||||
min-height: 0;
|
||||
@@ -78,6 +79,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
.pb-app-doc-button {
|
||||
position: absolute;
|
||||
bottom: bp.$pt-grid-size;
|
||||
right: bp.$pt-grid-size;
|
||||
z-index: bp.$pt-z-index-overlay;
|
||||
}
|
||||
|
||||
$splitter-background-color: bp.$light-gray2;
|
||||
$splitter-background-color-hover: bp.$gray4;
|
||||
$dark-splitter-background-color: bp.$dark-gray5;
|
||||
|
||||
@@ -4,5 +4,9 @@
|
||||
"editor": "Editor",
|
||||
"terminal": "Terminal",
|
||||
"documentation": "Documentation"
|
||||
},
|
||||
"docs": {
|
||||
"show": "Show documentation",
|
||||
"hide": "Hide documentation"
|
||||
}
|
||||
}
|
||||
|
||||
+1
-24
@@ -16,15 +16,7 @@ import {
|
||||
Tabs,
|
||||
Text,
|
||||
} from '@blueprintjs/core';
|
||||
import {
|
||||
Blank,
|
||||
Clipboard,
|
||||
Cross,
|
||||
Duplicate,
|
||||
Manual,
|
||||
Redo,
|
||||
Undo,
|
||||
} from '@blueprintjs/icons';
|
||||
import { Blank, Clipboard, Cross, Duplicate, Redo, Undo } from '@blueprintjs/icons';
|
||||
import classNames from 'classnames';
|
||||
import * as monaco from 'monaco-editor';
|
||||
import tomorrowNightEightiesTheme from 'monaco-themes/themes/Tomorrow-Night-Eighties.json';
|
||||
@@ -37,7 +29,6 @@ import { UUID } from '../fileStorage';
|
||||
import { useFileStoragePath } from '../fileStorage/hooks';
|
||||
import { compile } from '../mpy/actions';
|
||||
import { useSelector } from '../reducers';
|
||||
import { useSettingIsShowDocsEnabled } from '../settings/hooks';
|
||||
import { isMacOS } from '../utils/os';
|
||||
import Welcome from './Welcome';
|
||||
import { editorActivateFile, editorCloseFile } from './actions';
|
||||
@@ -387,8 +378,6 @@ const Editor: React.FunctionComponent = () => {
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const [editor, setEditor] = useState<monaco.editor.IStandaloneCodeEditor>();
|
||||
const { isSettingShowDocsEnabled, toggleIsSettingShowDocsEnabled } =
|
||||
useSettingIsShowDocsEnabled();
|
||||
const { isDarkMode } = useTernaryDarkMode();
|
||||
|
||||
const i18n = useI18n();
|
||||
@@ -510,18 +499,6 @@ const Editor: React.FunctionComponent = () => {
|
||||
<div className="pb-editor-monaco" ref={editorRef} />
|
||||
</ContextMenu>
|
||||
</ResizeSensor>
|
||||
<Button
|
||||
className="pb-editor-doc-button"
|
||||
minimal
|
||||
large
|
||||
icon={<Manual />}
|
||||
title={
|
||||
isSettingShowDocsEnabled
|
||||
? i18n.translate('docs.hide')
|
||||
: i18n.translate('docs.show')
|
||||
}
|
||||
onClick={toggleIsSettingShowDocsEnabled}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -93,13 +93,6 @@
|
||||
color: bp.$pt-dark-text-color-muted;
|
||||
}
|
||||
}
|
||||
|
||||
&-doc-button {
|
||||
position: absolute;
|
||||
bottom: bp.$pt-grid-size;
|
||||
right: bp.$pt-grid-size;
|
||||
z-index: bp.$pt-z-index-overlay;
|
||||
}
|
||||
}
|
||||
|
||||
.monaco-editor {
|
||||
|
||||
@@ -5,16 +5,11 @@
|
||||
"welcome": "Welcome",
|
||||
"placeholder": "Write your program here...",
|
||||
"check": "Check syntax",
|
||||
"toggleDocs": "Toggle documentation",
|
||||
"copy": "Copy",
|
||||
"paste": "Paste",
|
||||
"selectAll": "Select all",
|
||||
"undo": "Undo",
|
||||
"redo": "Redo",
|
||||
"closeFile": { "tooltip": "Close {fileName}" },
|
||||
"contextMenu": { "label": "Editor context menu" },
|
||||
"docs": {
|
||||
"show": "Show documentation",
|
||||
"hide": "Hide documentation"
|
||||
}
|
||||
"contextMenu": { "label": "Editor context menu" }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user