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
This commit is contained in:
43
app/imports/ui/components/CardHighlight.vue
Normal file
43
app/imports/ui/components/CardHighlight.vue
Normal file
@@ -0,0 +1,43 @@
|
||||
<template lang="html">
|
||||
<div
|
||||
v-if="dark || theme.isDark"
|
||||
class="overlay"
|
||||
:class="{active, 'extra-bright': dark && !theme.isDark}"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script lang="js">
|
||||
export default {
|
||||
inject: {
|
||||
theme: {
|
||||
default: {
|
||||
isDark: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
props: {
|
||||
active: Boolean,
|
||||
dark: Boolean,
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="css" scoped>
|
||||
.overlay {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
pointer-events: none;
|
||||
background-color: #fff;
|
||||
opacity: 0;
|
||||
transition: opacity 0.1s linear;
|
||||
}
|
||||
.overlay.active {
|
||||
opacity: 0.08;
|
||||
}
|
||||
.overlay.active.extra-bright {
|
||||
opacity: 0.3;
|
||||
}
|
||||
</style>
|
||||
@@ -2,15 +2,17 @@
|
||||
<v-card
|
||||
:hover="hasClickListener"
|
||||
class="toolbar-card"
|
||||
:class="hovering ? 'elevation-8': ''"
|
||||
:class="{'transparent-toolbar': transparentToolbar, hovering}"
|
||||
:elevation="hovering ? 8 : undefined"
|
||||
@click.native="$emit('click')"
|
||||
>
|
||||
<v-toolbar
|
||||
flat
|
||||
:style="`transform: none; ${hasToolbarClickListener ? 'cursor: pointer;' : ''}`"
|
||||
:color="color"
|
||||
:dark="isDark"
|
||||
:light="!isDark"
|
||||
:class="{}"
|
||||
:color="transparentToolbar ? undefined : color"
|
||||
:dark="transparentToolbar ? undefined : isDark"
|
||||
:light="transparentToolbar ? undefined : !isDark"
|
||||
@click="$emit('toolbarclick')"
|
||||
@mouseover="hoverToolbar(true)"
|
||||
@mouseleave="hoverToolbar(false)"
|
||||
@@ -20,14 +22,19 @@
|
||||
<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,
|
||||
@@ -35,6 +42,7 @@
|
||||
return getThemeColor('secondary');
|
||||
},
|
||||
},
|
||||
transparentToolbar: Boolean,
|
||||
},
|
||||
data(){ return {
|
||||
hovering: false,
|
||||
@@ -62,9 +70,12 @@
|
||||
|
||||
<style lang="css">
|
||||
.toolbar-card .v-toolbar__title {
|
||||
font-size: 14px;
|
||||
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>
|
||||
|
||||
Reference in New Issue
Block a user