Skip to content

Commit d9880f5

Browse files
committed
Added default config, ignored testing notes directory, added delete and new note buttons, adjusted styling.
1 parent 26ac4b3 commit d9880f5

File tree

6 files changed

+55
-40
lines changed

6 files changed

+55
-40
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,6 @@ yarn-error.log*
2121
*.sw*
2222

2323
#Electron-builder output
24-
/dist_electron
24+
/dist_electron
25+
/notes
26+
/notes

config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"notePath":"notes","editorConfig":{"lineNumbers":false,"tabSize":4,"theme":"sticky hypermd-light","mode":{"name":"hypermd","hashtag":true}}}

notes/note.md

Lines changed: 0 additions & 13 deletions
This file was deleted.

notes/test.md

Lines changed: 0 additions & 13 deletions
This file was deleted.

public/style.css

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,17 @@ body {
3131
padding: 10px 10px 10px 5px;
3232
-webkit-app-region: drag;
3333
}
34-
35-
#NavBar a {
34+
#NavBar a{
3635
font-weight: bold;
3736
color: #fff;
38-
float: right;
3937
padding-left: 10px;
4038
text-decoration: none;
4139
-webkit-app-region: none;
4240
}
41+
42+
#NavBar #controls a {
43+
float: right;
44+
}
4345
#NavBar *{
4446
-webkit-app-region: none;
4547
}
@@ -54,6 +56,20 @@ body {
5456
width:20%;
5557
}
5658

59+
#NavBar select {
60+
border-top: none;
61+
border-left: none;
62+
border-right: none;
63+
border-bottom: 3px dashed lightblue;
64+
background: none;
65+
color: white;
66+
width:20%;
67+
}
68+
69+
#NavBar option{
70+
background:#2c3e50;
71+
}
72+
5773
textarea:focus,
5874
input:focus {
5975
outline: none;

src/components/NavBar.vue

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<template>
22
<div id="NavBar">
3-
<a v-on:click="close()"><i class="fas fa-window-close"></i></a>
4-
<!-- <a v-on:click="restore()"><i class="fas fa-window-restore"></i></a> -->
5-
<a v-on:click="minimize()"><i class="fas fa-minus-square"></i></a>
6-
<a v-on:click="pin()"><i class="fas fa-thumbtack"></i></a>
3+
<div id="controls">
4+
<a v-on:click="close()"><i class="fas fa-window-close"></i></a>
5+
<!-- <a v-on:click="restore()"><i class="fas fa-window-restore"></i></a> -->
6+
<a v-on:click="minimize()"><i class="fas fa-minus-square"></i></a>
7+
<a v-on:click="pin()"><i class="fas fa-thumbtack"></i></a>
8+
</div>
79
<input v-on:change="updateFileName" v-model="fileName" type="text" name="fileName">
810
<select
911
v-on:change="changeFile"
@@ -14,12 +16,18 @@
1416
>
1517
<option v-for="file in Files()" :value="file.value" :key="file.id" :id=file.id >{{ file.value }}</option>
1618
</select>
19+
<a v-on:click="newNote()"><i class="fas fa-file-medical"></i></a>
20+
<a v-on:click="deleteNote()"><i class="fas fa-trash"></i></a>
1721
</div>
1822
</template>
1923

2024
<script lang="ts">
2125
import { Component, Prop, Vue } from "vue-property-decorator";
2226
import * as fs from "fs";
27+
import * as path from "path";
28+
import Configuration from '@/utility/Configuration';
29+
const remote = require('electron').remote;
30+
2331
@Component
2432
export default class NavBar extends Vue {
2533
private fileName: string = "";
@@ -64,16 +72,30 @@ export default class NavBar extends Vue {
6472
w.setAlwaysOnTop(!w.isAlwaysOnTop())
6573
}
6674
restore(){
67-
const remote = require('electron').remote;
68-
let w = remote.getCurrentWindow();
69-
this.isMaximized ? w.unmaximize() : w.maximize();
75+
this.isMaximized ? remote.getCurrentWindow().unmaximize() : remote.getCurrentWindow().maximize();
7076
this.isMaximized = !this.isMaximized;
7177
}
7278
7379
minimize(){
74-
const remote = require('electron').remote;
75-
let w = remote.getCurrentWindow();
76-
w.minimize();
80+
remote.getCurrentWindow().minimize();
81+
}
82+
83+
84+
newNote(){
85+
let FileName = `${Date.now()}.md`
86+
fs.writeFile(path.join(new Configuration().notePath,FileName),"# Welcome to your new note!\n","",_=>{
87+
this.SelectedFile = FileName;
88+
this.$root.$emit("fileChange", this.SelectedFile);
89+
});
90+
}
91+
92+
deleteNote(){
93+
confirm(`This will permantly delete "${this.SelectedFile}". Continue?`);
94+
fs.unlink(path.join(new Configuration().notePath,this.SelectedFile), _ =>{
95+
this.SelectedFile = this.Files()[0].value;
96+
this.fileName = this.Files()[0].value;
97+
this.changeFile();
98+
});
7799
}
78100
}
79101
</script>

0 commit comments

Comments
 (0)