mirror of
https://github.com/vkaelin/LeagueStats.git
synced 2026-03-25 12:57:28 +00:00
feat: add dropdown in RecentActivity component
This commit is contained in:
parent
e23932fcf6
commit
3b5ed35ea8
2 changed files with 85 additions and 7 deletions
63
client/src/components/Dropdown.vue
Normal file
63
client/src/components/Dropdown.vue
Normal file
|
|
@ -0,0 +1,63 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<!-- trigger -->
|
||||||
|
<div
|
||||||
|
@mouseenter="isOpen = true"
|
||||||
|
@mousemove="mousemove"
|
||||||
|
@mouseleave="isOpen = false"
|
||||||
|
:aria-expanded="isOpen"
|
||||||
|
aria-haspopup="true"
|
||||||
|
>
|
||||||
|
<slot name="trigger"></slot>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- dropdown content -->
|
||||||
|
<div
|
||||||
|
v-show="isOpen"
|
||||||
|
class="fixed z-40 bg-blue-1000 py-2 rounded-md shadow"
|
||||||
|
:style="{ width, ...position }"
|
||||||
|
>
|
||||||
|
<slot></slot>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
openMethod: {
|
||||||
|
type: String,
|
||||||
|
default: 'click'
|
||||||
|
},
|
||||||
|
width: {
|
||||||
|
type: String,
|
||||||
|
default: 'auto'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
isOpen: false,
|
||||||
|
left: 0,
|
||||||
|
offset: 12,
|
||||||
|
top: 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
computed: {
|
||||||
|
position() {
|
||||||
|
return {
|
||||||
|
left: `${this.left + this.offset}px`,
|
||||||
|
top: `${this.top + this.offset}px`,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
mousemove(event) {
|
||||||
|
this.left = event.clientX
|
||||||
|
this.top = event.clientY
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
@ -22,13 +22,22 @@
|
||||||
class="ml-2 flex flex-col flex-wrap"
|
class="ml-2 flex flex-col flex-wrap"
|
||||||
style="width: calc(20px * 15); height: calc(20px * 7)"
|
style="width: calc(20px * 15); height: calc(20px * 7)"
|
||||||
>
|
>
|
||||||
|
<Dropdown v-for="(day, index) in gridDays.slice(indexFirstMonday)" :key="day.timestamp">
|
||||||
|
<template v-slot:trigger>
|
||||||
<div
|
<div
|
||||||
v-for="(day, index) in gridDays.slice(indexFirstMonday)"
|
|
||||||
:key="day.timestamp"
|
|
||||||
:title="day.date + ' : ' + day.matches + ' game(s)'"
|
|
||||||
:class="[getCaseMargin(index), getCaseColor(day.matches)]"
|
:class="[getCaseMargin(index), getCaseColor(day.matches)]"
|
||||||
class="ml-1 w-4 h-4 cursor-pointer"
|
class="ml-1 w-4 h-4 cursor-pointer"
|
||||||
/>
|
/>
|
||||||
|
</template>
|
||||||
|
<template v-slot:default>
|
||||||
|
<div class="px-2 text-white text-center text-xs">
|
||||||
|
<div>{{ day.date }}</div>
|
||||||
|
<div>
|
||||||
|
<span class="font-bold text-teal-400">{{ day.matches }}</span> game(s)
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</Dropdown>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -36,7 +45,13 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import Dropdown from '@/components/Dropdown.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
components: {
|
||||||
|
Dropdown,
|
||||||
|
},
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
matches: {
|
matches: {
|
||||||
type: Array,
|
type: Array,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue