Client - display more workouts in calendar popup (wip)

todo: display on mobile
This commit is contained in:
Sam 2021-09-05 22:57:16 +02:00
parent 2ae2cf04d5
commit 43b5c4009e
3 changed files with 73 additions and 7 deletions

View File

@ -120,9 +120,10 @@
border-right: solid 1px var(--calendar-border-color); border-right: solid 1px var(--calendar-border-color);
height: 3em; height: 3em;
flex-grow: 1; flex-grow: 1;
flex-basis: 10%; flex-basis: 8%;
padding: $default-padding * 0.5; padding: $default-padding * 0.5 $default-padding $default-padding * 0.5
width: 10%; $default-padding * 0.5;
width: 8%;
position: relative; position: relative;
.calendar-cell-day { .calendar-cell-day {

View File

@ -25,10 +25,20 @@
</script> </script>
<style lang="scss"> <style lang="scss">
@import '~@/scss/base';
.calendar-workout { .calendar-workout {
padding: 2px;
img { img {
max-width: 18px; max-width: 18px;
max-height: 18px; max-height: 18px;
} }
@media screen and (max-width: $small-limit) {
img {
max-width: 14px;
max-height: 14px;
}
}
} }
</style> </style>

View File

@ -1,16 +1,36 @@
<template> <template>
<div class="calendar-workouts"> <div class="calendar-workouts">
<div v-for="(workout, index) in workouts" :key="index"> <div v-for="(workout, index) in workouts.slice(0, 6)" :key="index">
<CalendarWorkout
:workout="workout"
:sportImg="getSportImg(workout, sports)"
/>
</div>
<div v-if="workouts.length > 6">
<i
class="fa calendar-more"
:class="`fa-${isHidden ? 'plus' : 'times'}`"
aria-hidden="true"
title="show more workouts"
@click="displayMore"
/>
<div v-if="!isHidden" class="more-workouts">
<div
v-for="(workout, index) in workouts.slice(6 - workouts.length)"
:key="index"
>
<CalendarWorkout <CalendarWorkout
:workout="workout" :workout="workout"
:sportImg="getSportImg(workout, sports)" :sportImg="getSportImg(workout, sports)"
/> />
</div> </div>
</div> </div>
</div>
</div>
</template> </template>
<script lang="ts"> <script lang="ts">
import { defineComponent, PropType } from 'vue' import { PropType, defineComponent, ref } from 'vue'
import CalendarWorkout from '@/components/Dashboard/UserCalendar/CalendarWorkout.vue' import CalendarWorkout from '@/components/Dashboard/UserCalendar/CalendarWorkout.vue'
import { ISport } from '@/types/sports' import { ISport } from '@/types/sports'
@ -32,14 +52,49 @@
}, },
}, },
setup() { setup() {
const isHidden = ref(true)
function getSportImg(workout: IWorkout, sports: ISport[]): string { function getSportImg(workout: IWorkout, sports: ISport[]): string {
return sports return sports
.filter((sport) => sport.id === workout.sport_id) .filter((sport) => sport.id === workout.sport_id)
.map((sport) => sport.img)[0] .map((sport) => sport.img)[0]
} }
return { getSportImg } function displayMore() {
isHidden.value = !isHidden.value
}
return { isHidden, getSportImg, displayMore }
}, },
}) })
</script> </script>
<style lang="scss"></style> <style lang="scss">
@import '~@/scss/base';
.calendar-workouts {
display: flex;
flex-wrap: wrap;
position: relative;
.calendar-more {
position: absolute;
top: 30px;
right: -3px;
}
.more-workouts {
background: whitesmoke;
border-radius: 4px;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2),
0 6px 20px 0 rgba(0, 0, 0, 0.19);
position: absolute;
top: 52px;
left: 0;
min-width: 53px;
margin-bottom: 20px;
padding: 10px 15px;
display: flex;
flex-wrap: wrap;
z-index: 1000;
}
}
</style>