mirror of
https://github.com/kevin-DL/build-gmail-clone-with-vue-3.git
synced 2026-01-23 15:41:33 +00:00
Lesson 13, pt 1 - Select Box Highlighting
This commit is contained in:
37
src/components/BulkActionBar.vue
Normal file
37
src/components/BulkActionBar.vue
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<input type="checkbox"
|
||||||
|
:checked="allEmailsSelected"
|
||||||
|
:class="[someEmailsSelected ? 'partial-check' : '']" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import useEmailSelection from '@/composables/use-email-selection';
|
||||||
|
import { computed } from 'vue'
|
||||||
|
export default {
|
||||||
|
setup(props){
|
||||||
|
let emailSelection = useEmailSelection();
|
||||||
|
let numberSelected = computed(() => emailSelection.emails.size)
|
||||||
|
let numberEmails = props.emails.length
|
||||||
|
let allEmailsSelected = computed(() => numberSelected.value === numberEmails)
|
||||||
|
let someEmailsSelected = computed(() => {
|
||||||
|
return numberSelected.value > 0 && numberSelected.value < numberEmails
|
||||||
|
})
|
||||||
|
return {
|
||||||
|
allEmailsSelected,
|
||||||
|
someEmailsSelected
|
||||||
|
}
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
emails: {
|
||||||
|
type: Array,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<BulkActionBar :emails="unarchivedEmails" />
|
||||||
<table class="mail-table">
|
<table class="mail-table">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr v-for="email in unarchivedEmails"
|
<tr v-for="email in unarchivedEmails"
|
||||||
@@ -30,6 +31,7 @@
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import MailView from '@/components/MailView.vue';
|
import MailView from '@/components/MailView.vue';
|
||||||
import ModalView from '@/components/ModalView.vue';
|
import ModalView from '@/components/ModalView.vue';
|
||||||
|
import BulkActionBar from '@/components/BulkActionBar.vue';
|
||||||
import { reactive } from 'vue';
|
import { reactive } from 'vue';
|
||||||
import useEmailSelection from '@/composables/use-email-selection'
|
import useEmailSelection from '@/composables/use-email-selection'
|
||||||
|
|
||||||
@@ -46,7 +48,8 @@
|
|||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
MailView,
|
MailView,
|
||||||
ModalView
|
ModalView,
|
||||||
|
BulkActionBar
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
sortedEmails() {
|
sortedEmails() {
|
||||||
|
|||||||
Reference in New Issue
Block a user