Files
DiceCloud/app/imports/ui/components/ToolbarCard.vue
Stefan Zermatten 4b4e3a8928 Improve hover highlight UI effects for cards in dark mode
In light mode a change in elevation changes the drop shadow, but this is 
all but invisible in dark mode, so I added a highlight to the cards when 
hovering to show that the card can be expanded with a click
2022-03-03 17:21:59 +02:00

82 lines
1.9 KiB
Vue

<template lang="html">
<v-card
:hover="hasClickListener"
class="toolbar-card"
:class="{'transparent-toolbar': transparentToolbar, hovering}"
:elevation="hovering ? 8 : undefined"
@click.native="$emit('click')"
>
<v-toolbar
flat
:style="`transform: none; ${hasToolbarClickListener ? 'cursor: pointer;' : ''}`"
:class="{}"
:color="transparentToolbar ? undefined : color"
:dark="transparentToolbar ? undefined : isDark"
:light="transparentToolbar ? undefined : !isDark"
@click="$emit('toolbarclick')"
@mouseover="hoverToolbar(true)"
@mouseleave="hoverToolbar(false)"
>
<slot name="toolbar" />
</v-toolbar>
<div>
<slot />
</div>
<card-highlight :active="hovering" />
</v-card>
</template>
<script lang="js">
import isDarkColor from '/imports/ui/utility/isDarkColor.js';
import getThemeColor from '/imports/ui/utility/getThemeColor.js';
import CardHighlight from '/imports/ui/components/CardHighlight.vue';
export default {
components: {
CardHighlight,
},
props: {
color: {
type: String,
default(){
return getThemeColor('secondary');
},
},
transparentToolbar: Boolean,
},
data(){ return {
hovering: false,
}},
computed: {
isDark(){
return isDarkColor(this.color);
},
hasClickListener(){
return this.$listeners && !!this.$listeners.click;
},
hasToolbarClickListener(){
return this.$listeners && !!this.$listeners.toolbarclick;
},
},
methods: {
hoverToolbar(val){
this.hovering = this.$listeners &&
!!this.$listeners.toolbarclick &&
val;
}
}
};
</script>
<style lang="css">
.toolbar-card .v-toolbar__title {
font-size: 15px;
}
.toolbar-card {
transition: box-shadow .4s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.toolbar-card.transparent-toolbar .theme--dark.v-toolbar.v-sheet {
background-color: #303030;
}
</style>