Skip to content

Commit 7204cf6

Browse files
authored
add edit and enhanced styling
1 parent 615ba58 commit 7204cf6

File tree

2 files changed

+43
-10
lines changed

2 files changed

+43
-10
lines changed

components.html

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
<head>
22
<title></title>
33
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.3.2/css/bulma.css">
4+
<link rel="stylesheet" href="./font-awesome-4.7.0/css/font-awesome.min.css">
45
<style type="text/css">body { padding-top: 40px; }</style>
56
</head>
67

78
<body>
89
<style type="text/css">
910
.add { margin-top: 20px; margin-bottom: 20px; }
11+
.footer { height: 10% }
1012
input { padding-bottom: 12px; }
1113
</style>
1214

@@ -26,34 +28,51 @@ <h1 class="title">
2628
</div>
2729

2830
<tabs>
29-
<tab name="Notes" :selected="true">
31+
<tab name="Notes" icon="fa fa-sticky-note" :selected="true">
3032
<ul>
3133
<li v-for="note in nonArchivedNotes">
3234
<article class="message is-warning">
3335
<div class="message-body">
34-
<p> {{ note.text }} </p> <br />
35-
<a @click="note.archived = true">Add to Archives</a> | <a>Edit</a> | <a @click="note.isVisible = false">Delete</a>
36+
<p v-show="note != activeEdit"> {{ note.text }} </p>
37+
<input type="text" v-model="note.text" v-on:keyup.enter="doneEdit(note)" v-show="note == activeEdit"><br />
38+
<p class="control"><a class="button is-small" title="Add to Archives" @click="note.archived = true"><span class="icon is-small"><i class="fa fa-archive"></i></span></a> <a class="button is-small" title="Edit" @click="editNote(note)"><span class="icon is-small"><i class="fa fa-pencil"></i></span></a> <a class="button is-small" title="Delete" @click="note.isVisible = false"><span class="icon is-small"><i class="fa fa-trash"></i></span></a></p>
3639
</div>
3740
</article>
38-
<br />
41+
<br>
3942
</li>
4043
</ul>
4144
</tab>
42-
<tab name="Archived">
45+
<tab name="Archived" icon="fa fa-archive">
4346
<ul>
4447
<li v-for="note in archivedNotes">
4548
<article class="message is-warning">
4649
<div class="message-body">
47-
<p> {{ note.text }} </p> <br />
48-
<a @click="note.archived = false">Remove from Archives</a> | <a>Edit</a> | <a @click="note.isVisible = false">Delete</a>
50+
<p v-show="note != activeEdit"> {{ note.text }} </p>
51+
<input type="text" v-model="note.text" v-on:keyup.enter="doneEdit(note)" v-show="note == activeEdit"><br>
52+
<p class="control"><a class="button is-small" title="Remove from Archives" @click="note.archived = false"><span class="icon is-small"><i class="fa fa-sticky-note"></i></span></a> <a class="button is-small" title="Edit" @click="editNote(note)"><span class="icon is-small"><i class="fa fa-pencil"></i></span></a> <a class="button is-small" title="Delete" @click="note.isVisible = false"><span class="icon is-small"><i class="fa fa-trash"></i></span></a></p>
4953
</div>
5054
</article>
51-
<br />
55+
<br>
5256
</li>
5357
</ul>
5458
</tab>
5559
</tabs>
5660
</div>
61+
62+
<footer class="footer">
63+
<div class="container">
64+
<div class="content has-text-centered">
65+
<p>
66+
<strong>NotesApp</strong> by <a href="https://github.com/yashkarle">Yash Karle</a>
67+
</p>
68+
<p>
69+
<a class="icon" href="https://github.com/yashkarle/vuejs-notes">
70+
<i class="fa fa-github"></i>
71+
</a>
72+
</p>
73+
</div>
74+
</div>
75+
</footer>
5776
</body>
5877

5978
<script src="https://unpkg.com/vue@2.2.1"></script>

main.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Vue.component('tabs', {
66
<ul>
77
<li :class="{ 'is-active': tab.isActive }" v-for="tab in tabs">
88
<a :href="tab.href" @click="selectTab(tab)">
9+
<span class="icon is-small"><i v-bind:class="tab.icon"></i></span>
910
<span>{{ tab.name }}</span>
1011
</a>
1112
</li>
@@ -39,6 +40,7 @@ Vue.component('tab', {
3940
`,
4041
props: {
4142
name: { required: true },
43+
icon: { required: true },
4244
selected: { default: false }
4345
},
4446
data() {
@@ -51,14 +53,16 @@ Vue.component('tab', {
5153
},
5254
mounted() {
5355
this.isActive = this.selected;
56+
this.icon = this.icon;
5457
}
5558
});
5659

5760
var app = new Vue({
5861
el: '#root',
5962
data: {
6063
newNote: '',
61-
notes: []
64+
notes: [],
65+
activeEdit: null
6266
},
6367
methods: {
6468
addNote() {
@@ -69,7 +73,17 @@ var app = new Vue({
6973
this.newNote = '';
7074
}
7175
//alert('Adding a Note!');
72-
}
76+
},
77+
editNote(note) {
78+
this.activeEdit = note;
79+
},
80+
doneEdit(note) {
81+
if (!this.activeEdit) {
82+
return;
83+
}
84+
this.activeEdit = null;
85+
note.text = note.text.trim();
86+
}
7387
},
7488
computed: {
7589
nonArchivedNotes() {

0 commit comments

Comments
 (0)