Skip to content

Commit b72a2d6

Browse files
committed
support dark mode, closed #78
1 parent 4b3d835 commit b72a2d6

19 files changed

+566
-85
lines changed

.eslintrc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@
88
"curly": ["error", "multi-line"],
99
"no-warning-comments": 0,
1010
"max-lines": 0,
11-
"quote-props": ["error", "as-needed"]
11+
"quote-props": ["error", "as-needed"],
12+
"guard-for-in": 0
1213
},
1314
"env": {
1415
"browser": "true"
16+
},
17+
"globals": {
18+
"Mousetrap": true
1519
}
1620
}

app/eme/config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ const config = new Config({
1212
currentTabIndex: null
1313
},
1414
settings: {
15+
theme: 'white',
16+
colorSchema: 'base16-light',
17+
highlight: 'github',
18+
font: `-apple-system, BlinkMacSystemFont,
19+
'avenir next', avenir,
20+
helvetica, 'helvetica neue',
21+
Ubuntu,
22+
'segoe ui', arial,
23+
sans-serif`,
1524
writingMode: 'default',
1625
tabSize: 2,
1726
indentWithTabs: false,

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
"animate.css": "^3.5.1",
6969
"babel-runtime": "^6.11.6",
7070
"codemirror": "^5.17.0",
71+
"color-preset": "^0.1.1",
7172
"highlight.js": "^9.5.0",
7273
"hint.css": "2.3.2",
7374
"lodash.debounce": "^4.0.6",

scripts/webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ const appPkg = require('../app/package')
66

77
const postcss = [
88
require('postcss-nested'),
9-
require('postcss-simple-vars'),
109
require('postcss-import')(),
10+
require('postcss-simple-vars'),
1111
require('postcss-mixins'),
1212
require('autoprefixer')({
1313
browsers: ['last 2 Chrome versions']

src/app.vue

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
<style src="animate.css/animate.css"></style>
33
<style src="codemirror/lib/codemirror.css"></style>
44
<style src="./css/reset"></style>
5-
<style src="./css/editor-reset"></style>
5+
<style src="src/css/theme/white"></style>
6+
<style src="src/css/theme/dark"></style>
67
<style>
78
.overlay {
89
position: fixed;
@@ -16,10 +17,14 @@
1617

1718
<template>
1819
<div id="app"
19-
:class="{
20-
'distraction-free': isDistractionFreeMode,
21-
'full-screen': isFullScreen
22-
}">
20+
:class="[
21+
{
22+
'distraction-free': isDistractionFreeMode,
23+
'full-screen': isFullScreen
24+
},
25+
'theme-' + theme,
26+
highlight
27+
]">
2328
<div
2429
class="overlay"
2530
@click="togglePreferencePane"
@@ -53,7 +58,9 @@
5358
vuex: {
5459
getters: {
5560
tabsAmount: state => state.editor.tabs.length,
56-
showPreferencePane: state => state.app.showPreferencePane
61+
showPreferencePane: state => state.app.showPreferencePane,
62+
theme: state => state.app.settings.theme,
63+
highlight: state => state.app.settings.highlight
5764
},
5865
actions: {
5966
togglePreferencePane({dispatch}) {

src/components/footer.vue

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,12 @@
55
background-color: #f0f0f0;
66
padding: 0 10px;
77
font-size: 12px;
8-
color: #666;
9-
border-top: 1px solid #e2e2e2;
8+
border-top: 1px solid;
109
position: fixed;
1110
bottom: 0;
1211
left: 0;
1312
right: 0;
1413
-webkit-app-region: drag;
15-
box-shadow: inset 0 1px 0 #f5f4f5;
16-
background-image: linear-gradient(to bottom,#e8e6e8 0,#d1cfd1 100%);
17-
border-top: 1px solid #c2c0c2;
1814
> span {
1915
margin-right: 10px;
2016
}
@@ -24,8 +20,8 @@
2420
border: none;
2521
font-size: 12px;
2622
outline: none;
27-
color: #666;
2823
-webkit-appearance: none;
24+
text-rendering: geometricPrecision;
2925
}
3026
3127
.footer-right {
@@ -39,11 +35,7 @@
3935
.footer-icon-item {
4036
height: 16px;
4137
line-height: 16px;
42-
background-color: #fcfcfc;
43-
background-image: linear-gradient(to bottom,#fcfcfc 0,#f1f1f1 100%);
4438
border: 1px solid;
45-
border-color: #c2c0c2 #c2c0c2 #a19fa1;
46-
box-shadow: 0 1px 1px rgba(0,0,0,.06);
4739
margin-left: -1px;
4840
padding: 0 5px;
4941
text-align: center;
@@ -53,16 +45,7 @@
5345
position: relative;
5446
z-index: 1;
5547
&.active {
56-
background-color: #6d6c6d;
57-
background-image: none;
58-
color: white;
59-
border-color: transparent;
6048
z-index: 2;
61-
.footer-icon {
62-
path {
63-
fill: white;
64-
}
65-
}
6649
}
6750
&:first-child {
6851
border-radius: 4px 0 0 4px;
@@ -85,9 +68,6 @@
8568
svg {
8669
width: 12px;
8770
}
88-
path {
89-
fill: #666;
90-
}
9171
.disabled & path {
9272
fill: #ccc;
9373
}

src/components/header.vue

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
display: flex;
66
cursor: default;
77
height: $header-height;
8-
border-bottom: 1px solid #ddd;
8+
border-bottom: 1px solid;
99
-webkit-app-region: drag;
1010
&:hover {
1111
.settings-trigger {
@@ -38,17 +38,15 @@
3838
padding-right: 40px;
3939
position: relative;
4040
text-align: center;
41-
border-left: 1px solid #ddd;
42-
border-bottom: 1px solid #ddd;
41+
border-left: 1px solid;
42+
border-bottom: 1px solid;
4343
display: flex;
4444
flex: 1;
4545
width: 100%;
4646
white-space: nowrap;
47-
background-color: white;
4847
overflow: hidden;
4948
text-overflow: ellipsis;
5049
.tab-title {
51-
color: #999;
5250
-webkit-user-select: none;
5351
width: 100%;
5452
display: block;
@@ -60,17 +58,11 @@
6058
}
6159
}
6260
&.current-tab {
63-
border-left-color: #1976D2;
64-
background-color: white;
6561
border-left-width: 2px;
6662
border-bottom: none;
67-
.tab-title {
68-
color: #333;
69-
}
7063
}
7164
&.hover {
7265
.tab-indicator {
73-
background-color: rgba(255, 255, 255, 0.84);
7466
.dot {
7567
display: none;
7668
}
@@ -86,26 +78,18 @@
8678
8779
&:not(.single-tab) {
8880
.tab:last-child {
89-
border-right: 1px solid #ddd;
81+
border-right: 1px solid;
9082
}
9183
}
9284
9385
&.single-tab {
9486
.tab {
9587
&.current-tab {
96-
border-bottom: 1px solid #ddd;
88+
border-bottom: 1px solid;
9789
border-left-width: 1px;
98-
border-left-color: #ddd;
99-
border-right: 1px solid #ddd;
90+
border-right: 1px solid transparent;
10091
&:not(.unsaved) {
101-
border-right-width: 0;
102-
}
103-
}
104-
}
105-
&:hover {
106-
.tab {
107-
&.current-tab {
108-
border-right-width: 1px;
92+
border-right-color: transparent;
10993
}
11094
}
11195
}
@@ -127,7 +111,6 @@
127111
.dot {
128112
width: 5px;
129113
height: 5px;
130-
background-color: #4b89ff;
131114
border-radius: 50%;
132115
display: inline-block;
133116
}
@@ -146,27 +129,12 @@
146129
}
147130
148131
.settings-trigger {
149-
$color: #b1b1b1;
150-
$colorActive: #666;
151-
152132
opacity: 0;
153133
display: flex;
154134
justify-content: center;
155135
width: 50px;
156136
svg {
157137
width: 14px;
158-
color: $color;
159-
circle {
160-
color: $color;
161-
}
162-
}
163-
&:hover {
164-
svg {
165-
color: $colorActive;
166-
circle {
167-
color: $colorActive;
168-
}
169-
}
170138
}
171139
}
172140
}

src/components/main.vue

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
<style src="highlight.js/styles/github"></style>
2-
<style src="../css/base16-light"></style>
3-
<style src="../css/editor-dialog"></style>
4-
<style src="../css/editor-scrollbar"></style>
1+
<!-- codemirror theme -->
2+
<style src="src/css/codemirror/tomorrow-night-bright"></style>
3+
<style src="src/css/codemirror/base16-light"></style>
4+
<style src="src/css/codemirror/editor-dialog"></style>
5+
<style src="src/css/codemirror/editor-scrollbar"></style>
6+
<style src="src/css/codemirror/editor-reset"></style>
7+
<!-- highlight.js theme -->
8+
<style src="src/css/highlight/github"></style>
9+
<style src="src/css/highlight/tomorrow-night-bright"></style>
510

611
<style>
712
.main {
@@ -40,7 +45,7 @@
4045
cursor: text;
4146
overflow-x: hidden !important;
4247
position: relative;
43-
border-right: 1px solid #e3e3e3;
48+
border-right: 1px solid;
4449
.editor-input {
4550
display: none;
4651
}
@@ -86,7 +91,7 @@
8691
</style>
8792

8893
<template>
89-
<div class="main">
94+
<div class="main" :style="{'font-family': settings.font}">
9095
<tip v-if="tabs.length === 0"></tip>
9196
<div
9297
class="tab-body"
@@ -387,7 +392,7 @@
387392
const textarea = tabEl.querySelector(`#editor-${index}`)
388393
const editor = CodeMirror.fromTextArea(textarea, {
389394
mode: 'gfm',
390-
theme: 'base16-light',
395+
theme: this.settings.colorSchema,
391396
lineNumbers: false,
392397
matchBrackets: true,
393398
lineWrapping: true,
@@ -623,6 +628,12 @@
623628
this.editor.refresh()
624629
this.editor.focus()
625630
})
631+
632+
event.on('update-editor-options', options => {
633+
for (const option in options) {
634+
this.editor.setOption(option, options[option])
635+
}
636+
})
626637
},
627638
async closeTab(index) {
628639
const tab = this.tabs[index]

0 commit comments

Comments
 (0)