aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/frontend/src/editor/EditorTheme.ts
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2022-10-31 19:15:21 -0400
committerLibravatar Kristóf Marussy <kristof@marussy.com>2022-11-05 19:41:17 +0100
commit216dea1a36d1c05108ac5cfcec84a7808ecf1d6e (patch)
tree338e11bc8f90f270899f40f8217a70a040375d7c /subprojects/frontend/src/editor/EditorTheme.ts
parentrefactor(frontend): editor theme improvements (diff)
downloadrefinery-216dea1a36d1c05108ac5cfcec84a7808ecf1d6e.tar.gz
refinery-216dea1a36d1c05108ac5cfcec84a7808ecf1d6e.tar.zst
refinery-216dea1a36d1c05108ac5cfcec84a7808ecf1d6e.zip
feat(frontend): overlay scrollbars for editor
Diffstat (limited to 'subprojects/frontend/src/editor/EditorTheme.ts')
-rw-r--r--subprojects/frontend/src/editor/EditorTheme.ts99
1 files changed, 90 insertions, 9 deletions
diff --git a/subprojects/frontend/src/editor/EditorTheme.ts b/subprojects/frontend/src/editor/EditorTheme.ts
index 325f8d18..829b709f 100644
--- a/subprojects/frontend/src/editor/EditorTheme.ts
+++ b/subprojects/frontend/src/editor/EditorTheme.ts
@@ -4,15 +4,36 @@ import infoSVG from '@material-icons/svg/svg/info/baseline.svg?raw';
4import warningSVG from '@material-icons/svg/svg/warning/baseline.svg?raw'; 4import warningSVG from '@material-icons/svg/svg/warning/baseline.svg?raw';
5import { alpha, styled, type CSSObject } from '@mui/material/styles'; 5import { alpha, styled, type CSSObject } from '@mui/material/styles';
6 6
7import {
8 INDENTATION_MARKER_ACTIVE_CLASS,
9 INDENTATION_MARKER_CLASS,
10} from './indentationMarkerViewPlugin';
11
12function svgURL(svg: string): string { 7function svgURL(svg: string): string {
13 return `url('data:image/svg+xml;utf8,${svg}')`; 8 return `url('data:image/svg+xml;utf8,${svg}')`;
14} 9}
15 10
11function radialShadowTheme(
12 origin: string,
13 scaleX: boolean,
14 scaleY: boolean,
15): CSSObject {
16 function radialGradient(opacity: number, scale: string): string {
17 return `radial-gradient(
18 farthest-side at ${origin},
19 rgba(0, 0, 0, ${opacity}),
20 rgba(0, 0, 0, 0)
21 )
22 ${origin} /
23 ${scaleX ? scale : '100%'}
24 ${scaleY ? scale : '100%'}
25 no-repeat`;
26 }
27
28 return {
29 background: `
30 ${radialGradient(0.2, '40%')},
31 ${radialGradient(0.14, '50%')},
32 ${radialGradient(0.12, '100%')}
33 `,
34 };
35}
36
16export default styled('div', { 37export default styled('div', {
17 name: 'EditorTheme', 38 name: 'EditorTheme',
18 shouldForwardProp: (propName) => 39 shouldForwardProp: (propName) =>
@@ -36,8 +57,68 @@ export default styled('div', {
36 '&, .cm-editor': { 57 '&, .cm-editor': {
37 height: '100%', 58 height: '100%',
38 }, 59 },
60 '.cm-scroller-holder': {
61 display: 'flex',
62 position: 'relative',
63 flexDirection: 'column',
64 overflow: 'hidden',
65 flex: '1 1',
66 },
39 '.cm-scroller': { 67 '.cm-scroller': {
40 color: theme.palette.text.secondary, 68 color: theme.palette.text.secondary,
69 scrollbarWidth: 'none',
70 MsOverflowStyle: 'none',
71 '&::-webkit-scrollbar': {
72 width: 0,
73 height: 0,
74 background: 'transparent',
75 },
76 },
77 '.cm-scroller-thumb': {
78 position: 'absolute',
79 background: theme.palette.text.secondary,
80 opacity: theme.palette.mode === 'dark' ? 0.16 : 0.28,
81 transition: theme.transitions.create('opacity', {
82 duration: theme.transitions.duration.shortest,
83 }),
84 '&:hover': {
85 opacity: 0.75,
86 },
87 '&.active': {
88 opacity: 1,
89 pointerEvents: 'none',
90 userSelect: 'none',
91 },
92 },
93 '.cm-scroller-thumb-y': {
94 top: 0,
95 right: 0,
96 },
97 '.cm-scroller-thumb-x': {
98 left: 0,
99 bottom: 0,
100 },
101 '.cm-scroller-gutter-decoration': {
102 position: 'absolute',
103 top: 0,
104 bottom: 0,
105 left: 0,
106 width: 0,
107 transition: theme.transitions.create('width', {
108 duration: theme.transitions.duration.shortest,
109 }),
110 ...radialShadowTheme('0 50%', true, false),
111 },
112 '.cm-scroller-top-decoration': {
113 position: 'absolute',
114 top: 0,
115 left: 0,
116 right: 0,
117 height: 0,
118 transition: theme.transitions.create('height', {
119 duration: theme.transitions.duration.shortest,
120 }),
121 ...radialShadowTheme('50% 0', false, true),
41 }, 122 },
42 '.cm-gutters': { 123 '.cm-gutters': {
43 background: theme.palette.background.default, 124 background: theme.palette.background.default,
@@ -157,12 +238,12 @@ export default styled('div', {
157 '.cm-searchMatch-selected': { 238 '.cm-searchMatch-selected': {
158 background: theme.palette.highlight.search.selected, 239 background: theme.palette.highlight.search.selected,
159 }, 240 },
160 [`.${INDENTATION_MARKER_CLASS}`]: { 241 '.cm-indentation-marker': {
161 display: 'inline-block', 242 display: 'inline-block',
162 boxShadow: `1px 0 0 ${theme.palette.highlight.lineNumber} inset`, 243 boxShadow: `1px 0 0 ${theme.palette.highlight.lineNumber} inset`,
163 }, 244 '&.active': {
164 [`.${INDENTATION_MARKER_CLASS}.${INDENTATION_MARKER_ACTIVE_CLASS}`]: { 245 boxShadow: `1px 0 0 ${theme.palette.text.primary} inset`,
165 boxShadow: `1px 0 0 ${theme.palette.text.primary} inset`, 246 },
166 }, 247 },
167 }; 248 };
168 249