Skip to content

Commit

Permalink
Added Pinia and updated the ui
Browse files Browse the repository at this point in the history
  • Loading branch information
MoustafaShaaban committed Apr 19, 2024
1 parent ae254f9 commit ac9a235
Show file tree
Hide file tree
Showing 13 changed files with 442 additions and 391 deletions.
61 changes: 61 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
"@vueuse/core": "^10.9.0",
"lodash.uniqueid": "^4.0.1",
"nanoid": "^5.0.6",
"pinia": "^2.1.7",
"quasar": "^2.14.6",
"vue": "^3.4.19",
"vue-multiselect": "^3.0.0",
"vue-router": "^4.3.0"
},
"devDependencies": {
Expand Down
28 changes: 25 additions & 3 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script setup>
import { ref } from 'vue';
import { Dark } from 'quasar';
import { useNotesStore } from './stores/notes';
const drawerLeft = ref(false);
const darkQuery = '(prefers-color-scheme: dark)';
Expand All @@ -11,13 +12,16 @@ queryList.addEventListener('change', (event) => {
});
function toggleDarkMode() {
Dark.toggle();
Dark.toggle();
};
const notesStore = useNotesStore();
</script>

<template>
<div class="q-pa-md">
<q-layout view="hHh Lpr lff">
<q-layout view="hHh Lpr lff" :class="Dark.isActive ? 'text-white' : 'text-dark'">

<q-header reveal elevated class="bg-primary text-white">
<q-toolbar>
Expand All @@ -28,6 +32,14 @@ function toggleDarkMode() {
<q-breadcrumbs-el label="About" class="text-white" icon="info" to="/about" />
</q-breadcrumbs>
</q-toolbar-title>

<q-input dark dense standout v-model="notesStore.searchQuery" type="search" hint="Search by Title or Content" class="q-my-xs">
<template v-slot:append>
<q-icon v-if="notesStore.searchQuery === ''" name="search" />
<q-icon v-else name="clear" class="cursor-pointer" @click="notesStore.searchQuery = ''" />
</template>
</q-input>

</q-toolbar>
</q-header>

Expand All @@ -54,7 +66,7 @@ function toggleDarkMode() {
</q-item-section>
</q-item>

<q-item clickable v-ripple @click="toggleDarkMode">
<q-item v-if="!Dark.isActive" clickable v-ripple @click="toggleDarkMode">
<q-item-section avatar>
<q-icon name="dark_mode" />
</q-item-section>
Expand All @@ -63,6 +75,16 @@ function toggleDarkMode() {
Toggle Dark Mode
</q-item-section>
</q-item>

<q-item v-else clickable v-ripple @click="toggleDarkMode">
<q-item-section avatar>
<q-icon name="light_mode" />
</q-item-section>

<q-item-section>
Toggle Light Mode
</q-item-section>
</q-item>
</q-list>
</q-scroll-area>
</q-drawer>
Expand Down
40 changes: 0 additions & 40 deletions src/components/HelloWorld.vue

This file was deleted.

145 changes: 145 additions & 0 deletions src/components/NoteDetail.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
<script setup>
import { ref } from "vue";
import { useRoute, useRouter } from 'vue-router';
import { Dialog, date, Dark, Notify } from "quasar";
import Multiselect from "vue-multiselect";
import { useNotesStore } from "../stores/notes";
const notesStore = useNotesStore();
const route = useRoute();
const router = useRouter();
const isEditing = ref(false);
const note = ref({
id: '',
title: '',
content: '',
tags: [],
});
const noteTags = ref([]);
noteTags.value = notesStore.tags;
note.value = notesStore.getNoteById(route.params.id);
function handleSubmit() {
notesStore.updateNote(route.params.id, note.value);
isEditing.value = false;
Notify.create({
message: 'Note Updated Successfully',
type: "positive",
actions: [
{ icon: 'close', color: 'white', round: true, }
]
})
}
function confirm(id) {
Dialog.create({
dark: true,
title: 'Confirm',
color: 'primary',
message: 'Are you sure you want to delete this note?',
cancel: true,
persistent: true
}).onOk(() => {
notesStore.deleteNote(id)
router.push('/');
Notify.create({
message: 'Note Deleted Successfully',
type: "positive",
actions: [
{ icon: 'close', color: 'white', round: true, }
]
})
})
};
</script>

<template>
<q-page class="flex flex-center">
<q-card v-if="isEditing" flat bordered class="my-card">
<q-card-section class="row items-center q-pb-none q-mb-md" vertical>
<div class="text-h6">Edit: {{ note.title }}</div>
</q-card-section>

<q-separator />
<div class="text-overline">
<q-badge rounded color="primary" class="q-mx-xs q-my-xs" v-for="tag in note.tags">{{ tag.name }}</q-badge>
</div>

<q-card-section>
<q-form @submit.prevent="handleSubmit">
<q-input filled v-model="note.title" label="Note Title" required lazy-rules
:rules="[val => val && val.length > 0 || 'Note Title is required']" />

<q-input filled v-model="note.content" type="textarea" required label="Note Content" lazy-rules
:rules="[val => val && val.length > 0 || 'Note Content is required']" />
<div class="q-my-md"><label class="typo__label">Tagging</label>
<multiselect class="q-my-md" v-model="note.tags" placeholder="Search" label="name"
track-by="name" :options="noteTags" :multiple="true" :taggable="true">
</multiselect>
</div>

<q-separator />

<q-page-sticky position="bottom-right" :offset="[18, 18]">
<q-btn type="submit" fab icon="done" color="primary">
</q-btn>
</q-page-sticky>
</q-form>
</q-card-section>

<q-page-sticky position="bottom-left" :offset="[18, 18]">
<q-btn @click="isEditing = false" fab icon="undo" color="negative">
</q-btn>
</q-page-sticky>
</q-card>


<q-card v-else class="my-card q-mt-md" flat bordered>
<q-card-section>
<div class="row items-center no-wrap">
<div class="col">
<div class="text-h6">{{ note.title }}</div>
<div class="text-subtitle2">{{ date.formatDate(note.dateAdded, 'DD MMMM YYYY') }}</div>
</div>
</div>
</q-card-section>

<q-separator dark inset />

<q-card-section horizontal>
<q-card-section>
{{ note.content }}
</q-card-section>
</q-card-section>

<q-separator />

<q-card-actions>
<q-btn color="primary" type="button" size="sm" @click="isEditing = true">Edit</q-btn>
<q-btn color="negative" type="button" size="sm" @click="confirm">Delete</q-btn>
</q-card-actions>
</q-card>

<q-page-sticky position="bottom-left" :offset="[18, 18]">
<q-btn :to="{ 'name': 'home' }" fab icon="undo" color="negative">
</q-btn>
</q-page-sticky>
</q-page>
</template>

<style lang="sass" scoped>
.my-card
width: 100%
width: 350px
</style>
Loading

0 comments on commit ac9a235

Please sign in to comment.