File tree Expand file tree Collapse file tree 4 files changed +49
-48
lines changed Expand file tree Collapse file tree 4 files changed +49
-48
lines changed Original file line number Diff line number Diff line change @@ -176,9 +176,10 @@ export default Vue.extend({
176
176
mounted() {
177
177
if (darkMode === null ) {
178
178
this .darkMode = darkMode = this .$cookies .isDarkMode
179
- if (this . $cookies . isDarkMode ) {
179
+ if (darkMode ) {
180
180
document .documentElement .classList .add (' dark' )
181
181
document .cookie = ` darkMode=${darkMode }; Secure; max-age=31536000; path=/; `
182
+ this .$store .commit (' theme/set' , darkMode )
182
183
}
183
184
}
184
185
document .documentElement .classList .remove (' hidden' )
@@ -190,6 +191,7 @@ export default Vue.extend({
190
191
' dark'
191
192
)
192
193
document .cookie = ` darkMode=${! currentDarkMode }; Secure; max-age=31536000; path=/; `
194
+ this .$store .commit (' theme/set' , ! currentDarkMode )
193
195
this .darkMode = ! currentDarkMode
194
196
},
195
197
},
Original file line number Diff line number Diff line change 1
1
<template >
2
2
<div class =" page-contents" >
3
+ <!-- Following hidden input is hacky way to update monaco editor theme when user changes theme manually -->
4
+ <input type =" hidden" inert :value =" onThemeChange" />
3
5
<Navbar :show-back-button =" true" />
4
6
<main class =" outline-none" tabindex =" 0" >
5
7
<DiffActionBar :diff-navigator =" diffNavigator" />
6
8
<section
7
- class ="
8
- flex
9
- items-stretch
10
- flex-wrap
11
- w-full
12
- gap-4
13
- font-mono
14
- text-gray-800
15
- dark:text-gray-50
16
- "
9
+ class =" flex flex-wrap items-stretch w-full gap-4 font-mono text-gray-800 dark:text-gray-50"
17
10
>
18
- <div class =" flex space-around w-full gap-4" >
11
+ <div class =" flex w-full gap-4 space-around " >
19
12
<p
20
- class ="
21
- flex-grow-0 flex-shrink-0
22
- w-1/2
23
- text-lg
24
- font-bold
25
- text-center
26
- capitalize
27
- break-all
28
- "
13
+ class =" flex-grow-0 flex-shrink-0 w-1/2 text-lg font-bold text-center capitalize break-all "
29
14
>
30
15
<span class =" inline-block w-4/5" >{{ lhsLabel }}</span >
31
16
</p >
32
17
<p
33
- class ="
34
- flex-grow-0 flex-shrink-0
35
- w-1/2
36
- text-lg
37
- font-bold
38
- text-center
39
- capitalize
40
- break-all
41
- "
18
+ class =" flex-grow-0 flex-shrink-0 w-1/2 text-lg font-bold text-center capitalize break-all "
42
19
>
43
20
<span class =" inline-block w-4/5" >{{ rhsLabel }}</span >
44
21
</p >
@@ -76,6 +53,13 @@ export default Vue.extend({
76
53
diffNavigator: {},
77
54
}
78
55
},
56
+ computed: {
57
+ onThemeChange() {
58
+ const theme = this .$store .state .theme .darkMode ? ' vs-dark' : ' light'
59
+ this .monacoDiffEditor ?.updateOptions ?.({ theme })
60
+ return this .$store .state .theme .darkMode
61
+ },
62
+ },
79
63
beforeMount() {
80
64
const _diff = this .$route .hash
81
65
if (_diff ) {
Original file line number Diff line number Diff line change
1
+ n
1
2
<template >
2
3
<div class =" page-contents" >
3
4
<Navbar />
5
+ <!-- Following hidden input is hacky way to update monaco editor theme when user changes theme manually -->
6
+ <input type =" hidden" inert :value =" onThemeChange" />
4
7
<main class =" text-gray-800 outline-none dark:text-gray-50" tabindex =" 0" >
5
8
<section >
6
9
<header >
54
57
<div class =" self-end flex-grow-0 w-full mt-4 text-center" >
55
58
<button
56
59
id =" submitButton"
57
- class ="
58
- inline-flex
59
- items-center
60
- justify-center
61
- w-48
62
- px-4
63
- py-2
64
- transition-transform
65
- transform
66
- bg-blue-600
67
- rounded-md
68
- shadow-lg
69
- outline-none
70
- text-gray-50
71
- focus:ring-4
72
- active:scale-y-75
73
- "
60
+ class =" inline-flex items-center justify-center w-48 px-4 py-2 transition-transform transform bg-blue-600 rounded-md shadow-lg outline-none text-gray-50 focus:ring-4 active:scale-y-75"
74
61
aria-label =" Click here to compare the inputted text blocks"
75
62
>
76
63
Compare
@@ -101,6 +88,14 @@ export default Vue.extend({
101
88
rhsEditor: null ,
102
89
}
103
90
},
91
+ computed: {
92
+ onThemeChange() {
93
+ const theme = this .$store .state .theme .darkMode ? ' vs-dark' : ' light'
94
+ this .lhsEditor ?.updateOptions ({ theme })
95
+ this .rhsEditor ?.updateOptions ({ theme })
96
+ return this .$store .state .theme .darkMode
97
+ },
98
+ },
104
99
mounted() {
105
100
showTutorials (this .$cookies , this .$route .path , this .$cookies .isDarkMode )
106
101
document .addEventListener (' keydown' , this .handleCtrlEnter )
@@ -121,7 +116,7 @@ export default Vue.extend({
121
116
this .rhsEditor = monaco .editor .create (rhs , {
122
117
... monacoEditorOptions ,
123
118
value: this .rhs || ' ' ,
124
- wordWrap: ' on'
119
+ wordWrap: ' on' ,
125
120
})
126
121
}
127
122
})
Original file line number Diff line number Diff line change
1
+ import { GetterTree , MutationTree } from 'vuex/types'
2
+
3
+ export const state = ( ) => ( {
4
+ darkMode : false
5
+ } )
6
+
7
+ export type themeStore = ReturnType < typeof state >
8
+
9
+ export const getters : GetterTree < themeStore , themeStore > = {
10
+ isEnabled : ( state ) => state . darkMode ,
11
+ }
12
+
13
+ export const mutations : MutationTree < themeStore > = {
14
+ toggle ( state ) {
15
+ state . darkMode = ! state . darkMode
16
+ } ,
17
+ set ( state , value ) {
18
+ state . darkMode = value
19
+ }
20
+ }
You can’t perform that action at this time.
0 commit comments