aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/frontend/src/editor
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2022-08-21 13:32:32 +0200
committerLibravatar Kristóf Marussy <kristof@marussy.com>2022-08-21 18:59:23 +0200
commitd1f85fda716aee15121e9064ee99c4390fac41bd (patch)
tree2a5fe884bb51ad7d2731c834c9c6da5f21d63484 /subprojects/frontend/src/editor
parentrefactor(frontend): improve code splitting (diff)
downloadrefinery-d1f85fda716aee15121e9064ee99c4390fac41bd.tar.gz
refinery-d1f85fda716aee15121e9064ee99c4390fac41bd.tar.zst
refinery-d1f85fda716aee15121e9064ee99c4390fac41bd.zip
refactor(frontend): theme improvements
Diffstat (limited to 'subprojects/frontend/src/editor')
-rw-r--r--subprojects/frontend/src/editor/EditorPane.tsx23
-rw-r--r--subprojects/frontend/src/editor/EditorTheme.ts13
-rw-r--r--subprojects/frontend/src/editor/SearchToolbar.tsx32
3 files changed, 52 insertions, 16 deletions
diff --git a/subprojects/frontend/src/editor/EditorPane.tsx b/subprojects/frontend/src/editor/EditorPane.tsx
index 935a84e8..df43d2c9 100644
--- a/subprojects/frontend/src/editor/EditorPane.tsx
+++ b/subprojects/frontend/src/editor/EditorPane.tsx
@@ -1,10 +1,10 @@
1import Box from '@mui/material/Box'; 1import Box from '@mui/material/Box';
2import Skeleton from '@mui/material/Skeleton';
2import Stack from '@mui/material/Stack'; 3import Stack from '@mui/material/Stack';
3import Toolbar from '@mui/material/Toolbar'; 4import Toolbar from '@mui/material/Toolbar';
4import { observer } from 'mobx-react-lite'; 5import { observer } from 'mobx-react-lite';
5import React from 'react'; 6import React, { useState } from 'react';
6 7
7import Loading from '../Loading';
8import { useRootStore } from '../RootStore'; 8import { useRootStore } from '../RootStore';
9 9
10import EditorArea from './EditorArea'; 10import EditorArea from './EditorArea';
@@ -12,6 +12,23 @@ import EditorButtons from './EditorButtons';
12import GenerateButton from './GenerateButton'; 12import GenerateButton from './GenerateButton';
13import SearchPanelPortal from './SearchPanelPortal'; 13import SearchPanelPortal from './SearchPanelPortal';
14 14
15function EditorLoading(): JSX.Element {
16 const [skeletonSizes] = useState(() =>
17 new Array(10).fill(0).map(() => Math.random() * 60 + 10),
18 );
19
20 return (
21 <Box mx={2}>
22 {skeletonSizes.map((length, i) => (
23 /* eslint-disable-next-line react/no-array-index-key --
24 Random placeholders have no identity.
25 */
26 <Skeleton key={i} width={`${length}%`} />
27 ))}
28 </Box>
29 );
30}
31
15function EditorPane(): JSX.Element { 32function EditorPane(): JSX.Element {
16 const { editorStore } = useRootStore(); 33 const { editorStore } = useRootStore();
17 34
@@ -23,7 +40,7 @@ function EditorPane(): JSX.Element {
23 </Toolbar> 40 </Toolbar>
24 <Box flexGrow={1} flexShrink={1} overflow="auto"> 41 <Box flexGrow={1} flexShrink={1} overflow="auto">
25 {editorStore === undefined ? ( 42 {editorStore === undefined ? (
26 <Loading /> 43 <EditorLoading />
27 ) : ( 44 ) : (
28 <> 45 <>
29 <SearchPanelPortal editorStore={editorStore} /> 46 <SearchPanelPortal editorStore={editorStore} />
diff --git a/subprojects/frontend/src/editor/EditorTheme.ts b/subprojects/frontend/src/editor/EditorTheme.ts
index ca07d602..dfeeb547 100644
--- a/subprojects/frontend/src/editor/EditorTheme.ts
+++ b/subprojects/frontend/src/editor/EditorTheme.ts
@@ -14,8 +14,10 @@ export default styled('div', {
14})<{ showLineNumbers: boolean }>(({ theme, showLineNumbers }) => { 14})<{ showLineNumbers: boolean }>(({ theme, showLineNumbers }) => {
15 const editorFontStyle = { 15 const editorFontStyle = {
16 ...theme.typography.editor, 16 ...theme.typography.editor,
17 fontWeight: theme.typography.fontWeightEditorNormal,
17 [theme.breakpoints.down('sm')]: { 18 [theme.breakpoints.down('sm')]: {
18 fontSize: '0.875rem', 19 // `rem` for JetBrains MonoVariable make the text too large in Safari.
20 fontSize: '14px',
19 lineHeight: 1.43, 21 lineHeight: 1.43,
20 }, 22 },
21 }; 23 };
@@ -29,7 +31,12 @@ export default styled('div', {
29 color: theme.palette.text.secondary, 31 color: theme.palette.text.secondary,
30 }, 32 },
31 '.cm-gutters': { 33 '.cm-gutters': {
32 background: theme.palette.background.default, 34 background: `linear-gradient(
35 to right,
36 ${theme.palette.background.default} 0%,
37 ${theme.palette.background.default} calc(100% - 12px),
38 transparent 100%
39 )`,
33 border: 'none', 40 border: 'none',
34 }, 41 },
35 '.cm-content': { 42 '.cm-content': {
@@ -93,7 +100,7 @@ export default styled('div', {
93 fontStyle: 'italic', 100 fontStyle: 'italic',
94 }, 101 },
95 '.tok-problem-containment': { 102 '.tok-problem-containment': {
96 fontWeight: theme.typography.fontWeightBold, 103 fontWeight: theme.typography.fontWeightEditorBold,
97 textDecorationSkipInk: 'none', 104 textDecorationSkipInk: 'none',
98 }, 105 },
99 '.tok-problem-error': { 106 '.tok-problem-error': {
diff --git a/subprojects/frontend/src/editor/SearchToolbar.tsx b/subprojects/frontend/src/editor/SearchToolbar.tsx
index 7e6ff4f7..895f1ca1 100644
--- a/subprojects/frontend/src/editor/SearchToolbar.tsx
+++ b/subprojects/frontend/src/editor/SearchToolbar.tsx
@@ -11,6 +11,7 @@ import Stack from '@mui/material/Stack';
11import TextField from '@mui/material/TextField'; 11import TextField from '@mui/material/TextField';
12import ToggleButton from '@mui/material/ToggleButton'; 12import ToggleButton from '@mui/material/ToggleButton';
13import Toolbar from '@mui/material/Toolbar'; 13import Toolbar from '@mui/material/Toolbar';
14import { styled } from '@mui/material/styles';
14import useMediaQuery from '@mui/material/useMediaQuery'; 15import useMediaQuery from '@mui/material/useMediaQuery';
15import { observer } from 'mobx-react-lite'; 16import { observer } from 'mobx-react-lite';
16import React, { useCallback, useState } from 'react'; 17import React, { useCallback, useState } from 'react';
@@ -18,7 +19,13 @@ import React, { useCallback, useState } from 'react';
18import type SearchPanelStore from './SearchPanelStore'; 19import type SearchPanelStore from './SearchPanelStore';
19 20
20const SPLIT_MEDIA_QUERY = '@media (max-width: 1200px)'; 21const SPLIT_MEDIA_QUERY = '@media (max-width: 1200px)';
21const ABBREVIATE_MEDIA_QUERY = '@media (max-width: 720px)'; 22
23const DimLabel = styled(FormControlLabel)(({ theme }) => ({
24 '.MuiFormControlLabel-label': {
25 ...theme.typography.body2,
26 color: theme.palette.text.secondary,
27 },
28}));
22 29
23function SearchToolbar({ 30function SearchToolbar({
24 searchPanelStore, 31 searchPanelStore,
@@ -31,7 +38,6 @@ function SearchToolbar({
31 invalidRegexp, 38 invalidRegexp,
32 } = searchPanelStore; 39 } = searchPanelStore;
33 const split = useMediaQuery(SPLIT_MEDIA_QUERY); 40 const split = useMediaQuery(SPLIT_MEDIA_QUERY);
34 const abbreviate = useMediaQuery(ABBREVIATE_MEDIA_QUERY);
35 const [showRepalceState, setShowReplaceState] = useState(false); 41 const [showRepalceState, setShowReplaceState] = useState(false);
36 42
37 const showReplace = !split || showRepalceState || replace !== ''; 43 const showReplace = !split || showRepalceState || replace !== '';
@@ -132,7 +138,7 @@ function SearchToolbar({
132 alignItems="center" 138 alignItems="center"
133 rowGap={0.5} 139 rowGap={0.5}
134 > 140 >
135 <FormControlLabel 141 <DimLabel
136 control={ 142 control={
137 <Checkbox 143 <Checkbox
138 checked={caseSensitive} 144 checked={caseSensitive}
@@ -144,10 +150,9 @@ function SearchToolbar({
144 size="small" 150 size="small"
145 /> 151 />
146 } 152 }
147 aria-label="Match case" 153 label="Match case"
148 label={abbreviate ? 'Case' : 'Match case'}
149 /> 154 />
150 <FormControlLabel 155 <DimLabel
151 control={ 156 control={
152 <Checkbox 157 <Checkbox
153 checked={literal} 158 checked={literal}
@@ -159,10 +164,9 @@ function SearchToolbar({
159 size="small" 164 size="small"
160 /> 165 />
161 } 166 }
162 aria-label="Literal" 167 label="Literal"
163 label={abbreviate ? 'Lit' : 'Literal'}
164 /> 168 />
165 <FormControlLabel 169 <DimLabel
166 control={ 170 control={
167 <Checkbox 171 <Checkbox
168 checked={regexp} 172 checked={regexp}
@@ -248,7 +252,15 @@ function SearchToolbar({
248 </Stack> 252 </Stack>
249 </Stack> 253 </Stack>
250 </Stack> 254 </Stack>
251 <Stack direction="row" alignSelf="stretch" alignItems="start" mt="1px"> 255 <Stack
256 direction="row"
257 alignSelf="stretch"
258 alignItems="start"
259 mt="1px"
260 sx={{
261 [SPLIT_MEDIA_QUERY]: { display: 'none' },
262 }}
263 >
252 <IconButton 264 <IconButton
253 aria-label="Close find/replace" 265 aria-label="Close find/replace"
254 onClick={() => searchPanelStore.close()} 266 onClick={() => searchPanelStore.close()}