diff options
author | 2022-08-13 23:49:06 +0200 | |
---|---|---|
committer | 2022-08-15 18:03:58 +0200 | |
commit | c7abf6e90285857344d7e4f85553a89df971fc3c (patch) | |
tree | 1e86b700d7314a40c26612e2f6aa54de19f86108 /subprojects/frontend/src/theme/ThemeProvider.tsx | |
parent | feat(frontend): light/dark mode switch (diff) | |
download | refinery-c7abf6e90285857344d7e4f85553a89df971fc3c.tar.gz refinery-c7abf6e90285857344d7e4f85553a89df971fc3c.tar.zst refinery-c7abf6e90285857344d7e4f85553a89df971fc3c.zip |
refactor(frondend): dark theme tweaks
Diffstat (limited to 'subprojects/frontend/src/theme/ThemeProvider.tsx')
-rw-r--r-- | subprojects/frontend/src/theme/ThemeProvider.tsx | 66 |
1 files changed, 61 insertions, 5 deletions
diff --git a/subprojects/frontend/src/theme/ThemeProvider.tsx b/subprojects/frontend/src/theme/ThemeProvider.tsx index 1b8e49f0..9a8fdd44 100644 --- a/subprojects/frontend/src/theme/ThemeProvider.tsx +++ b/subprojects/frontend/src/theme/ThemeProvider.tsx | |||
@@ -1,41 +1,76 @@ | |||
1 | import { | 1 | import { |
2 | alpha, | ||
2 | createTheme, | 3 | createTheme, |
4 | type Components, | ||
3 | responsiveFontSizes, | 5 | responsiveFontSizes, |
4 | type ThemeOptions, | 6 | type ThemeOptions, |
5 | ThemeProvider as MaterialUiThemeProvider, | 7 | ThemeProvider as MaterialUiThemeProvider, |
6 | } from '@mui/material/styles'; | 8 | } from '@mui/material/styles'; |
7 | import { observer } from 'mobx-react-lite'; | 9 | import { observer } from 'mobx-react-lite'; |
8 | import React, { type CSSProperties, type ReactNode } from 'react'; | 10 | import React, { type ReactNode } from 'react'; |
9 | 11 | ||
10 | import { useRootStore } from '../RootStore'; | 12 | import { useRootStore } from '../RootStore'; |
11 | 13 | ||
12 | import EditorTheme from './EditorTheme'; | 14 | import EditorTheme from './EditorTheme'; |
13 | 15 | ||
14 | interface HighlightStyles { | 16 | interface HighlightStyles { |
15 | number: CSSProperties['color']; | 17 | number: string; |
16 | parameter: CSSProperties['color']; | 18 | parameter: string; |
19 | comment: string; | ||
20 | activeLine: string; | ||
17 | occurences: { | 21 | occurences: { |
18 | read: CSSProperties['color']; | 22 | read: string; |
19 | write: CSSProperties['color']; | 23 | write: string; |
20 | }; | 24 | }; |
21 | } | 25 | } |
22 | 26 | ||
23 | declare module '@mui/material/styles' { | 27 | declare module '@mui/material/styles' { |
24 | interface Palette { | 28 | interface Palette { |
29 | divider2: string; | ||
25 | selection: Palette['primary']; | 30 | selection: Palette['primary']; |
26 | highlight: HighlightStyles; | 31 | highlight: HighlightStyles; |
27 | } | 32 | } |
28 | 33 | ||
29 | interface PaletteOptions { | 34 | interface PaletteOptions { |
35 | divider2: string; | ||
30 | selection: PaletteOptions['primary']; | 36 | selection: PaletteOptions['primary']; |
31 | highlight: HighlightStyles; | 37 | highlight: HighlightStyles; |
32 | } | 38 | } |
33 | } | 39 | } |
34 | 40 | ||
35 | function getMUIThemeOptions(currentTheme: EditorTheme): ThemeOptions { | 41 | function getMUIThemeOptions(currentTheme: EditorTheme): ThemeOptions { |
42 | const components: Components = { | ||
43 | MuiButton: { | ||
44 | styleOverrides: { | ||
45 | root: { borderRadius: '50em' }, | ||
46 | text: { padding: '6px 16px' }, | ||
47 | textSizeSmall: { padding: '4px 10px' }, | ||
48 | textSizeLarge: { padding: '8px 22px' }, | ||
49 | }, | ||
50 | }, | ||
51 | MuiToggleButtonGroup: { | ||
52 | styleOverrides: { | ||
53 | groupedHorizontal: { | ||
54 | borderRadius: '50em', | ||
55 | ':first-of-type': { paddingLeft: 15 }, | ||
56 | ':last-of-type': { paddingRight: 15 }, | ||
57 | '&.MuiToggleButton-sizeSmall': { | ||
58 | ':first-of-type': { paddingLeft: 9 }, | ||
59 | ':last-of-type': { paddingRight: 9 }, | ||
60 | }, | ||
61 | '&.MuiToggleButton-sizeLarge': { | ||
62 | ':first-of-type': { paddingLeft: 21 }, | ||
63 | ':last-of-type': { paddingRight: 21 }, | ||
64 | }, | ||
65 | }, | ||
66 | }, | ||
67 | }, | ||
68 | }; | ||
69 | |||
36 | switch (currentTheme) { | 70 | switch (currentTheme) { |
37 | case EditorTheme.Light: | 71 | case EditorTheme.Light: |
38 | return { | 72 | return { |
73 | components, | ||
39 | palette: { | 74 | palette: { |
40 | mode: 'light', | 75 | mode: 'light', |
41 | primary: { main: '#0097a7' }, | 76 | primary: { main: '#0097a7' }, |
@@ -43,9 +78,12 @@ function getMUIThemeOptions(currentTheme: EditorTheme): ThemeOptions { | |||
43 | main: '#c8e4fb', | 78 | main: '#c8e4fb', |
44 | contrastText: '#000', | 79 | contrastText: '#000', |
45 | }, | 80 | }, |
81 | divider2: '#d7d7d7', | ||
46 | highlight: { | 82 | highlight: { |
47 | number: '#1976d2', | 83 | number: '#1976d2', |
48 | parameter: '#6a3e3e', | 84 | parameter: '#6a3e3e', |
85 | comment: alpha('#000', 0.38), | ||
86 | activeLine: '#f5f5f5', | ||
49 | occurences: { | 87 | occurences: { |
50 | read: '#ceccf7', | 88 | read: '#ceccf7', |
51 | write: '#f0d8a8', | 89 | write: '#f0d8a8', |
@@ -55,9 +93,25 @@ function getMUIThemeOptions(currentTheme: EditorTheme): ThemeOptions { | |||
55 | }; | 93 | }; |
56 | case EditorTheme.Dark: | 94 | case EditorTheme.Dark: |
57 | return { | 95 | return { |
96 | components, | ||
58 | palette: { | 97 | palette: { |
59 | mode: 'dark', | 98 | mode: 'dark', |
60 | primary: { main: '#56b6c2' }, | 99 | primary: { main: '#56b6c2' }, |
100 | error: { main: '#e06c75' }, | ||
101 | warning: { main: '#e5c07b' }, | ||
102 | success: { main: '#57a470' }, | ||
103 | info: { main: '#52b8ff' }, | ||
104 | background: { | ||
105 | default: '#282c34', | ||
106 | paper: '#21252b', | ||
107 | }, | ||
108 | text: { | ||
109 | primary: '#ebebff', | ||
110 | secondary: '#abb2bf', | ||
111 | disabled: '#4b5263', | ||
112 | }, | ||
113 | divider: alpha('#abb2bf', 0.16), | ||
114 | divider2: '#181a1f', | ||
61 | selection: { | 115 | selection: { |
62 | main: '#3e4453', | 116 | main: '#3e4453', |
63 | contrastText: '#fff', | 117 | contrastText: '#fff', |
@@ -65,6 +119,8 @@ function getMUIThemeOptions(currentTheme: EditorTheme): ThemeOptions { | |||
65 | highlight: { | 119 | highlight: { |
66 | number: '#6188a6', | 120 | number: '#6188a6', |
67 | parameter: '#c8ae9d', | 121 | parameter: '#c8ae9d', |
122 | comment: '#6b717d', | ||
123 | activeLine: '#21252b', | ||
68 | occurences: { | 124 | occurences: { |
69 | read: 'rgba(255, 255, 255, 0.15)', | 125 | read: 'rgba(255, 255, 255, 0.15)', |
70 | write: 'rgba(255, 255, 128, 0.4)', | 126 | write: 'rgba(255, 255, 128, 0.4)', |