File tree Expand file tree Collapse file tree 5 files changed +74
-65
lines changed Expand file tree Collapse file tree 5 files changed +74
-65
lines changed Original file line number Diff line number Diff line change 1
1
<template >
2
2
<nav
3
- class =" sticky top-0 left-0 right-0 z-10 text-gray-800 shadow-lg dark:shadow-dark bg-gray-50 dark:bg-gray-900 dark:text-gray-50"
3
+ class =" sticky top-0 left-0 right-0 z-10 text-gray-800 shadow-lg dark:shadow-dark bg-gray-50 dark:bg-gray-900 dark:text-gray-50"
4
4
>
5
5
<div class =" container flex items-center py-4 m-auto" >
6
6
<div
66
66
<slot name =" right" />
67
67
<button
68
68
type =" button"
69
- class =" inline-flex items-center justify-center ml-4 bg-transparent border-2 border-gray-700 rounded-full shadow-lg w-9 h-9 active:scale-y-75 hover:scale-105 hover:shadow-lg"
70
- aria-label =" Toggle Dark Mode"
69
+ class =" inline-flex items-center justify-center ml-4 bg-transparent border-2 border-gray-700 rounded-full shadow-lg w-9 h-9 active:scale-y-75 hover:scale-105 hover:shadow-lg"
70
+ :aria-label ="
71
+ darkMode ? 'Switch to light theme' : 'Switch to dark theme'
72
+ "
71
73
@click =" toggleDarkMode"
72
74
>
73
75
<svg
@@ -173,19 +175,24 @@ export default Vue.extend({
173
175
},
174
176
mounted() {
175
177
if (darkMode === null ) {
176
- darkMode = this .$cookies .isDarkMode
178
+ this . darkMode = darkMode = this .$cookies .isDarkMode
177
179
if (darkMode ) {
178
180
document .documentElement .classList .add (' dark' )
179
181
document .cookie = ` darkMode=${darkMode }; Secure; max-age=31536000; path=/; `
182
+ this .$store .commit (' theme/set' , darkMode )
180
183
}
181
184
}
182
185
document .documentElement .classList .remove (' hidden' )
183
186
},
184
187
methods: {
185
188
toggleDarkMode() {
186
- darkMode = ! darkMode
187
- document .documentElement .classList [darkMode ? ' add' : ' remove' ](' dark' )
188
- document .cookie = ` darkMode=${darkMode }; Secure; max-age=31536000; path=/; `
189
+ const currentDarkMode = this .darkMode
190
+ document .documentElement .classList [! currentDarkMode ? ' add' : ' remove' ](
191
+ ' dark'
192
+ )
193
+ document .cookie = ` darkMode=${! currentDarkMode }; Secure; max-age=31536000; path=/; `
194
+ this .$store .commit (' theme/set' , ! currentDarkMode )
195
+ this .darkMode = ! currentDarkMode
189
196
},
190
197
},
191
198
})
Original file line number Diff line number Diff line change @@ -90,19 +90,22 @@ const diffTutorials: TutorialMetadata[] = [
90
90
} ,
91
91
]
92
92
93
+ const comparePageTutorials : TutorialMetadata [ ] = [
94
+ {
95
+ tutorial : labelsTutorial ,
96
+ cookieName : 'isSkipTutorial' ,
97
+ } ,
98
+ {
99
+ tutorial : submitShortcutTutorial ,
100
+ cookieName : 'isSkipSubmitKbdShortcutTutorial' ,
101
+ } ,
102
+ ]
103
+
93
104
const tutorialsMetadata : TutorialsMetadata = {
94
105
'/v1/diff' : diffTutorials ,
95
- 'v2/diff' : diffTutorials ,
96
- '/' : [
97
- {
98
- tutorial : labelsTutorial ,
99
- cookieName : 'isSkipTutorial' ,
100
- } ,
101
- {
102
- tutorial : submitShortcutTutorial ,
103
- cookieName : 'isSkipSubmitKbdShortcutTutorial' ,
104
- } ,
105
- ] ,
106
+ '/v2/diff' : diffTutorials ,
107
+ '/' : comparePageTutorials ,
108
+ '/v2' : comparePageTutorials ,
106
109
}
107
110
108
111
export default async function showTutorials (
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