mirror of
https://github.com/kevin-DL/build-gmail-clone-with-vue-3.git
synced 2026-01-23 15:41:33 +00:00
Move up and down with j and k
This commit is contained in:
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
<portal target="#modal-portal">
|
<portal target="#modal-portal">
|
||||||
<ModalView v-if="!!openedEmail" :closeModal="() => {openedEmail = null;}">
|
<ModalView v-if="!!openedEmail" :closeModal="() => {openedEmail = null;}">
|
||||||
<MailView :email="openedEmail" />
|
<MailView :email="openedEmail" @changeEmail="changeEmail" />
|
||||||
</ModalView>
|
</ModalView>
|
||||||
</portal>
|
</portal>
|
||||||
</table>
|
</table>
|
||||||
@@ -41,10 +41,17 @@
|
|||||||
|
|
||||||
let openEmail = function(email) {
|
let openEmail = function(email) {
|
||||||
openedEmail.value = email;
|
openedEmail.value = email;
|
||||||
openedEmail.value.read = true;
|
if(email) {
|
||||||
|
openedEmail.value.read = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {format, emailSelection, openedEmail, openEmail}
|
let changeEmail = function({amount}){
|
||||||
|
let index = emails.findIndex(e => e == openedEmail.value);
|
||||||
|
openEmail(emails[index + amount])
|
||||||
|
}
|
||||||
|
|
||||||
|
return {format, emailSelection, openedEmail, openEmail, changeEmail}
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
emails: {
|
emails: {
|
||||||
|
|||||||
@@ -8,8 +8,15 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import marked from 'marked';
|
import marked from 'marked';
|
||||||
|
import { useKeydown } from '../composition/useKeydown';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setup({email}) {
|
setup({email}, {emit}) {
|
||||||
|
useKeydown([
|
||||||
|
{key: 'k', fn: () => emit('changeEmail', {amount: -1})},
|
||||||
|
{key: 'j', fn: () => emit('changeEmail', {amount: 1})}
|
||||||
|
])
|
||||||
|
|
||||||
let emailMarkdown = marked(email.body);
|
let emailMarkdown = marked(email.body);
|
||||||
return {
|
return {
|
||||||
emailMarkdown
|
emailMarkdown
|
||||||
|
|||||||
Reference in New Issue
Block a user