mirror of
https://github.com/kevin-DL/build-gmail-clone-with-vue-3.git
synced 2026-01-14 20:04:43 +00:00
Lesson 9 - Email Navigation Buttons and Keyboard Shortcuts
This commit is contained in:
@@ -55,6 +55,7 @@
|
||||
openEmail(email) {
|
||||
email.read = true
|
||||
this.updateEmail(email)
|
||||
|
||||
this.openedEmail = email
|
||||
},
|
||||
archiveEmail(email) {
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
<template>
|
||||
<div class="email-display">
|
||||
<div>
|
||||
<button @click="toggleArchive">{{email.archived ? 'Move to Inbox (e)' : 'Archive (e)'}}</button>
|
||||
<button @click="toggleRead">{{email.read ? 'Mark Unread (r)' : 'Mark Read (r)'}}</button>
|
||||
<button @click="goNewer">Newer (k)</button>
|
||||
<button @click="goOlder">Older (j)</button>
|
||||
</div>
|
||||
<h2 class="mb-0">Subject: <strong>{{email.subject}}</strong></h2>
|
||||
<div><em>From {{email.from}} on {{format(new Date(email.sentAt), 'MMM do yyyy')}}</em></div>
|
||||
<div v-html="marked(email.body)" />
|
||||
@@ -9,11 +15,32 @@
|
||||
<script>
|
||||
import { format } from 'date-fns'
|
||||
import marked from 'marked'
|
||||
import axios from 'axios'
|
||||
import useKeydown from '../composables/use-keydown'
|
||||
|
||||
export default {
|
||||
setup(){
|
||||
setup(props, {emit}){
|
||||
let email = props.email;
|
||||
let toggleRead = () => {
|
||||
email.read = !email.read
|
||||
axios.put(`http://localhost:3000/emails/${email.id}`, email)
|
||||
}
|
||||
let toggleArchive = () => {
|
||||
email.archived = !email.archived
|
||||
axios.put(`http://localhost:3000/emails/${email.id}`, email)
|
||||
// How to close the modal?
|
||||
}
|
||||
|
||||
useKeydown([
|
||||
{key: 'r', fn: toggleRead},
|
||||
{key: 'e', fn: toggleArchive}
|
||||
])
|
||||
|
||||
return {
|
||||
format,
|
||||
marked
|
||||
marked,
|
||||
toggleRead,
|
||||
toggleArchive
|
||||
}
|
||||
},
|
||||
props: {
|
||||
|
||||
Reference in New Issue
Block a user