Skip to content

Commit 9a7f8dc

Browse files
committed
Remade the edit notes popup into a fullscreen editor; added CheckIcon and DeleteIcon for saving and deleting notes; added a route in /notes/+page.svelte to the edit route
1 parent e7aa450 commit 9a7f8dc

30 files changed

+11500
-3
lines changed

src/lib/components/NoteDialog.svelte

+12-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
import { EditIcon } from '$lib/icons';
66
import { t, selectedVerses, bodyFontSize, currentFont } from '$lib/data/stores';
77
import { editNote, addNote } from '$lib/data/notes';
8+
import { goto } from '$app/navigation';
89
910
export let note = undefined;
1011
export let editing = false;
12+
export let show;
1113
1214
let id = 'note';
1315
let modal;
@@ -73,7 +75,15 @@
7375
</button>
7476
{/if}
7577
</div>
76-
<div style:word-wrap="break-word">
78+
<!-- TEST ----------------------------------------------------------------------- -->
79+
{#if editing}
80+
{ goto(`/notes/edit/${note.date}`) }
81+
82+
{/if}
83+
84+
<!-- TEST ----------------------------------------------------------------------- -->
85+
86+
<!-- <div style:word-wrap="break-word">
7787
{#if editing}
7888
<textarea bind:value={text} class="dy-textarea w-full" />
7989
{:else if text !== undefined}
@@ -95,7 +105,7 @@
95105
>{$t['Button_OK']}</button
96106
>
97107
</div>
98-
{/if}
108+
{/if} -->
99109
</div>
100110
</svelte:fragment>
101111
</Modal>

src/lib/icons/CheckIcon.svelte

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<script lang="ts">
2+
// Check from https://fonts.google.com/icons
3+
// 'FILL' 0,
4+
// 'wght' 400,
5+
// 'GRAD' 0,
6+
// 'opsz' 24
7+
export let color = 'black';
8+
export let size = '24';
9+
</script>
10+
11+
<svg fill={color} xmlns="http://www.w3.org/2000/svg" height={size} width={size} viewBox="0 -960 960 960">
12+
<path d="M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z" />
13+
</svg>

src/lib/icons/DeleteIcon.svelte

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<script lang="ts">
2+
// Delete SVG vector icon from https://www.svgrepo.com/svg/453328/delete
3+
export let color = 'black';
4+
export let size = '24';
5+
</script>
6+
7+
<svg fill={color} xmlns="http://www.w3.org/2000/svg" height={size} width={size} viewBox="0 0 24 24"
8+
><path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z" /></svg>

src/lib/icons/index.js

+4
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ import ArrowForwardIcon from './ArrowForwardIcon.svelte';
66
import BibleIcon from './BibleIcon.svelte';
77
import BookmarkIcon from './BookmarkIcon.svelte';
88
import BookmarkOutlineIcon from './BookmarkOutlineIcon.svelte';
9+
import CheckIcon from './CheckIcon.svelte';
910
import ChevronIcon from './ChevronIcon.svelte';
1011
import CopyContentIcon from './CopyContentIcon.svelte';
12+
import DeleteIcon from './DeleteIcon.svelte';
1113
import DeleteSweepIcon from './DeleteSweepIcon.svelte';
1214
import DropdownIcon from './DropdownIcon.svelte';
1315
import EditIcon from './EditIcon.svelte';
@@ -39,8 +41,10 @@ export {
3941
BibleIcon,
4042
BookmarkIcon,
4143
BookmarkOutlineIcon,
44+
CheckIcon,
4245
ChevronIcon,
4346
CopyContentIcon,
47+
DeleteIcon,
4448
DeleteSweepIcon,
4549
DropdownIcon,
4650
EditIcon,

src/routes/notes/+page.svelte

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
goto(`${base}/`);
2121
break;
2222
case $t['Annotation_Menu_Edit']:
23-
modal.open(MODAL_NOTE, note);
23+
// modal.open(MODAL_NOTE, note);
24+
goto(`/notes/edit/${note.date}`);
2425
break;
2526
case $t['Annotation_Menu_Share']:
2627
await shareAnnotation(note);
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { getNotes } from '$lib/data/notes';
2+
3+
export async function load({ params }) {
4+
const { noteid } = params;
5+
const date = parseInt(noteid, 10);
6+
const allNotes = await getNotes();
7+
const note = allNotes.find((item) => item.date === date);
8+
9+
console.log('note %o allNotes %o noteid %o date %o' , note, allNotes, noteid, date);
10+
11+
if (!note) {
12+
throw new Error('Note not found');
13+
}
14+
15+
return { note };
16+
}
17+
18+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<script>
2+
import Navbar from '$lib/components/Navbar.svelte';
3+
import { t } from '$lib/data/stores';
4+
import { ArrowBackIcon, DeleteIcon, CheckIcon } from '$lib/icons';
5+
import { removeNote } from '$lib/data/notes';
6+
import { selectedVerses } from '$lib/data/stores';
7+
import { editNote,addNote } from '$lib/data/notes';
8+
9+
export let data;
10+
let note = data.note;
11+
let text = note.text;
12+
13+
function closeEditor() {
14+
history.back();
15+
}
16+
async function deleteNote() {
17+
await removeNote(note.date);
18+
closeEditor();
19+
}
20+
async function modifyNote() {
21+
if (note !== undefined) {
22+
await editNote({
23+
note: note,
24+
newText:text
25+
});
26+
} else {
27+
await addNote({
28+
docSet: $selectedVerses[0].docSet,
29+
collection: $selectedVerses[0].collection,
30+
book: $selectedVerses[0].book,
31+
chapter: $selectedVerses[0].chapter,
32+
verse: $selectedVerses[0].verse,
33+
text,
34+
reference: $selectedVerses[0].reference
35+
});
36+
}
37+
closeEditor();
38+
}
39+
</script>
40+
41+
42+
<!--create a close button for this editor that closes on a button when clicked -->
43+
<div class="fullscreen-editor">
44+
<Navbar>
45+
<label for="sidebar" slot="center" >
46+
<div class="btn btn-ghost normal-case text-xl" >{$t['Annotation_Note_Edit']}</div>
47+
</label>
48+
49+
<div slot="right-buttons" style="">
50+
<button on:click={deleteNote} class="dy-btn dy-btn-ghost dy-btn-circle"><DeleteIcon color="white" /></button>
51+
<button on:click={modifyNote} class="dy-btn dy-btn-ghost p-1"><CheckIcon color="white" /></button>
52+
</div>
53+
54+
</Navbar>
55+
<!-- <button on:click={closeEditor} class="close-button"><ArrowBackIcon color="black" /></button> -->
56+
57+
<!-- <p>{note.text}</p> -->
58+
59+
<div class="flex justify-center mt-7 h-full max-w-screen-md mx-auto">
60+
<textarea bind:value={text} class="dy-textarea dy-textarea-bordered w-full h-5/6 shadow-md" />
61+
</div>
62+
63+
<!-- flex justify-center box-border mt-7 h-full -->
64+
<!-- dy-textarea dy-textarea-bordered w-11/12 h-5/6 shadow-md -->
65+
<!-- to save the data, save it to the store -->
66+
</div>
67+
68+
69+
<style>
70+
.fullscreen-editor{
71+
width: 100%;
72+
height: 100%;
73+
position: fixed;
74+
}
75+
</style>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?xml version="1.0" encoding="utf-8"?><book-details><f>73-JHNeng-web.usfm</f><features type="book"><e name="wj-marked" value="true"/></features></book-details>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?xml version="1.0" encoding="utf-8"?><book-details><f>72-LUKeng-web.usfm</f><features type="book"><e name="wj-marked" value="true"/></features></book-details>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?xml version="1.0" encoding="utf-8"?><book-details><f>70-MATeng-web.usfm</f><page num="1"><audio><f src="d1" len="224496" size="1825367">B01___01_Matthew_____ENGWEBN2DA.mp3</f><y>C01-41-MAT-01-timing.txt</y></audio></page><page num="2"><audio><f src="d1" len="225907" size="1836442">B01___02_Matthew_____ENGWEBN2DA.mp3</f><y>C01-41-MAT-02-timing.txt</y></audio></page><page num="3"><audio><f src="d1" len="157100" size="1285781">B01___03_Matthew_____ENGWEBN2DA.mp3</f><y>C01-41-MAT-03-timing.txt</y></audio></page><page num="4"><audio><f src="d1" len="228833" size="1860057">B01___04_Matthew_____ENGWEBN2DA.mp3</f><y>C01-41-MAT-04-timing.txt</y></audio></page><page num="5"><audio><f src="d1" len="398158" size="3214663">B01___05_Matthew_____ENGWEBN2DA.mp3</f><y>C01-41-MAT-05-timing.txt</y></audio></page><page num="6"><audio><f src="d1" len="298841" size="2420122">B01___06_Matthew_____ENGWEBN2DA.mp3</f><y>C01-41-MAT-06-timing.txt</y></audio></page><page num="7"><audio><f src="d1" len="230348" size="1871969">B01___07_Matthew_____ENGWEBN2DA.mp3</f><y>C01-41-MAT-07-timing.txt</y></audio></page><page num="8"><audio><f src="d1" len="304379" size="2464426">B01___08_Matthew_____ENGWEBN2DA.mp3</f><y>C01-41-MAT-08-timing.txt</y></audio></page><page num="9"><audio><f src="d1" len="341786" size="2763685">B01___09_Matthew_____ENGWEBN2DA.mp3</f><y>C01-41-MAT-09-timing.txt</y></audio></page><page num="10"><audio><f src="d1" len="328777" size="2659614">B01___10_Matthew_____ENGWEBN2DA.mp3</f><y>C01-41-MAT-10-timing.txt</y></audio></page><page num="11"><audio><f src="d1" len="252552" size="2049812">B01___11_Matthew_____ENGWEBN2DA.mp3</f><y>C01-41-MAT-11-timing.txt</y></audio></page><page num="12"><audio><f src="d1" len="441626" size="3562615">B01___12_Matthew_____ENGWEBN2DA.mp3</f><y>C01-41-MAT-12-timing.txt</y></audio></page><page num="13"><audio><f src="d1" len="503850" size="4060195">B01___13_Matthew_____ENGWEBN2DA.mp3</f><y>C01-41-MAT-13-timing.txt</y></audio></page><page num="14"><audio><f src="d1" len="284839" size="2308110">B01___14_Matthew_____ENGWEBN2DA.mp3</f><y>C01-41-MAT-14-timing.txt</y></audio></page><page num="15"><audio><f src="d1" len="318903" size="2580620">B01___15_Matthew_____ENGWEBN2DA.mp3</f><y>C01-41-MAT-15-timing.txt</y></audio></page><page num="16"><audio><f src="d1" len="260023" size="2109580">B01___16_Matthew_____ENGWEBN2DA.mp3</f><y>C01-41-MAT-16-timing.txt</y></audio></page><page num="17"><audio><f src="d1" len="256157" size="2078651">B01___17_Matthew_____ENGWEBN2DA.mp3</f><y>C01-41-MAT-17-timing.txt</y></audio></page><page num="18"><audio><f src="d1" len="298109" size="2414063">B01___18_Matthew_____ENGWEBN2DA.mp3</f><y>C01-41-MAT-18-timing.txt</y></audio></page><page num="19"><audio><f src="d1" len="277577" size="2250014">B01___19_Matthew_____ENGWEBN2DA.mp3</f><y>C01-41-MAT-19-timing.txt</y></audio></page><page num="20"><audio><f src="d1" len="282384" size="2288257">B01___20_Matthew_____ENGWEBN2DA.mp3</f><y>C01-41-MAT-20-timing.txt</y></audio></page><page num="21"><audio><f src="d1" len="428199" size="3454990">B01___21_Matthew_____ENGWEBN2DA.mp3</f><y>C01-41-MAT-21-timing.txt</y></audio></page><page num="22"><audio><f src="d1" len="318328" size="2576022">B01___22_Matthew_____ENGWEBN2DA.mp3</f><y>C01-41-MAT-22-timing.txt</y></audio></page><page num="23"><audio><f src="d1" len="332121" size="2686363">B01___23_Matthew_____ENGWEBN2DA.mp3</f><y>C01-41-MAT-23-timing.txt</y></audio></page><page num="24"><audio><f src="d1" len="372506" size="3009446">B01___24_Matthew_____ENGWEBN2DA.mp3</f><y>C01-41-MAT-24-timing.txt</y></audio></page><page num="25"><audio><f src="d1" len="331389" size="2680512">B01___25_Matthew_____ENGWEBN2DA.mp3</f><y>C01-41-MAT-25-timing.txt</y></audio></page><page num="26"><audio><f src="d1" len="642978" size="5173221">B01___26_Matthew_____ENGWEBN2DA.mp3</f><y>C01-41-MAT-26-timing.txt</y></audio></page><page num="27"><audio><f src="d1" len="551863" size="4444300">B01___27_Matthew_____ENGWEBN2DA.mp3</f><y>C01-41-MAT-27-timing.txt</y></audio></page><page num="28"><audio><f src="d1" len="174132" size="1422455">B01___28_Matthew_____ENGWEBN2DA.mp3</f><y>C01-41-MAT-28-timing.txt</y></audio></page><features type="book"><e name="wj-marked" value="true"/></features></book-details>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?xml version="1.0" encoding="utf-8"?><book-details><f>71-MRKeng-web.usfm</f><features type="book"><e name="wj-marked" value="true"/></features></book-details>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?xml version="1.0" encoding="utf-8"?><book-details><f>JHN.usfm</f></book-details>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?xml version="1.0" encoding="utf-8"?><book-details><f>LUK.usfm</f></book-details>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?xml version="1.0" encoding="utf-8"?><book-details><f>MAT.usfm</f></book-details>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?xml version="1.0" encoding="utf-8"?><book-details><f>MRK.usfm</f></book-details>

0 commit comments

Comments
 (0)