Merge remote-tracking branch 'origin/master' into karelkryda_master

# Conflicts:
#	src/components/HeartbeatBar.vue
This commit is contained in:
Louis Lam
2022-05-18 19:49:54 +08:00
23 changed files with 307 additions and 88 deletions

View File

@@ -1,6 +1,6 @@
<template>
<div ref="wrap" class="wrap" :style="wrapStyle">
<div class="hp-bar-big" :style="barStyle">
<div class="hp-bar-big d-flex" :style="barStyle">
<div
v-for="(beat, index) in shortBeatList"
:key="index"
@@ -8,7 +8,11 @@
:class="{ 'empty' : (beat === 0), 'down' : (beat.status === 0), 'pending' : (beat.status === 2), 'maintenance' : (beat.status === 3) }"
:style="beatStyle"
:title="getBeatTitle(beat)"
/>
@mouseenter="toggleActivateSibling"
@mouseleave="toggleActivateSibling"
>
<div class="beat-inner" />
</div>
</div>
</div>
</template>
@@ -168,6 +172,29 @@ export default {
getBeatTitle(beat) {
return `${this.$root.datetime(beat.time)}` + ((beat.msg) ? ` - ${beat.msg}` : "");
},
// Toggling the activeSibling class on hover over the current hover item
toggleActivateSibling(e) {
// Variable definition
const element = e.target;
const previous = element.previousSibling;
const next = element.nextSibling;
// Return if the hovered element has empty class
if (element.classList.contains("empty")) {
return;
}
// Check if Previous Sibling is heartbar element and doesn't have the empty class
if (previous.children && !previous.classList.contains("empty")) {
previous.classList.toggle("active-sibling");
}
// Check if Next Sibling is heartbar element and doesn't have the empty class
if (next.children && !next.classList.contains("empty")) {
next.classList.toggle("active-sibling");
}
}
},
};
@@ -184,9 +211,10 @@ export default {
.hp-bar-big {
.beat {
display: inline-block;
background-color: $primary;
border-radius: $border-radius;
display: inline-block;
transition: all ease 0.6s;
&.empty {
background-color: aliceblue;
@@ -200,15 +228,27 @@ export default {
background-color: $warning;
}
.beat-inner {
border-radius: $border-radius;
display: inline-block;
height: 100%;
width: 5px;
}
&.maintenance {
background-color: $maintenance;
}
&:not(.empty):hover {
transition: all ease-in-out 0.15s;
transition: all ease 0.15s;
opacity: 0.8;
transform: scale(var(--hover-scale));
}
&.active-sibling {
transform: scale(1.15);
transition: all ease 0.15s;
}
}
}