Merge pull request #38 from dderbentsov/UC-11

Добавила подсветку текущего времени
This commit is contained in:
Daria Golova
2022-10-17 17:17:46 +03:00
committed by GitHub
4 changed files with 87 additions and 59 deletions

View File

@@ -1,29 +1,17 @@
<template lang="pug"> <template lang="pug">
.calendar-column-wrapper.flex.flex-col .calendar-background-wrapper.flex.flex-col
.header.flex.items-center.justify-between.py-2.px-6 .header.flex.items-center.justify-between.py-2.px-6
.flex.items-center .body.flex.flex-col
img.avatar-wrapper.mr-2(:src="info.avatar" alt="Team member") .time-circle-indicator.-left-6px(v-if="isShownIndicator" :style="circleIndicatorLocation")
span.member-name.font-medium.text-base.mr-6 {{ info.name }} span.time-line-indicator.block(v-if="isShownIndicator" :style="lineIndicatorLocation")
img.icon-wrapper.cursor-pointer(src="@/assets/icons/lock.svg")
base-doc-ok-button
.flex.flex-col
span.block.time-indicator(v-if="isShownIndicator" :style="indicatorLocation")
.line.flex.items-center(v-for="hour in hoursArray" :key="hour") .line.flex.items-center(v-for="hour in hoursArray" :key="hour")
.middle-line .middle-line
</template> </template>
<script> <script>
import BaseDocOkButton from "@/components/base/buttons/BaseDocOkButton.vue";
export default { export default {
name: "CalendarColumn", name: "CalendarBackground",
components: { BaseDocOkButton },
props: { props: {
info: {
type: Object,
default() {
return {};
},
},
hoursArray: Array, hoursArray: Array,
currentTime: String, currentTime: String,
}, },
@@ -33,19 +21,24 @@ export default {
}; };
}, },
computed: { computed: {
indicatorLocation() { lineIndicatorLocation() {
return { return {
top: `${this.calculateIndicatorLocation()}px`, top: `${this.calculateIndicatorLocation()}px`,
}; };
}, },
circleIndicatorLocation() {
return {
top: `${this.calculateIndicatorLocation() - 6}px`,
};
},
}, },
methods: { methods: {
calculateIndicatorLocation() { calculateIndicatorLocation() {
let newTime = this.currentTime let newTime = this.currentTime
.split(":") .split(":")
.map((elem) => parseInt(elem, 10)); .map((elem) => parseInt(elem, 10));
let result = (newTime[0] - 7) * 60.5 + newTime[1]; let result = (newTime[0] - 8) * 62 + newTime[1] * 1.03;
if (result > 666) { if (result > 620) {
this.isShownIndicator = false; this.isShownIndicator = false;
return 0; return 0;
} }
@@ -56,28 +49,21 @@ export default {
</script> </script>
<style lang="sass" scoped> <style lang="sass" scoped>
.calendar-column-wrapper .calendar-background-wrapper
width: 100% width: 100%
position: relative
.header .header
height: 48px height: 48px
border-bottom: 1px solid var(--border-light-grey-color)
.avatar-wrapper .body
width: 32px position: relative
height: 32px
.icon-wrapper
width: 24px
height: 24px
.member-name
color: var(--font-dark-blue-color)
.line .line
border-bottom: 1px solid var(--border-light-grey-color) border-bottom: 1px solid var(--border-light-grey-color)
height: 62px height: 62px
&:nth-child(3)
height: 63px
border-top: 1px solid var(--border-light-grey-color)
&:last-child &:last-child
display: none display: none
@@ -85,8 +71,15 @@ export default {
border-top: 1px dashed var(--border-light-grey-color) border-top: 1px dashed var(--border-light-grey-color)
width: 100% width: 100%
.time-indicator .time-line-indicator
width: 100% width: 100%
border-top: 1px solid var(--time-indicator-color) border-top: 1px solid var(--time-indicator-color)
position: absolute position: absolute
.time-circle-indicator
width: 12px
height: 12px
background-color: var(--time-indicator-color)
border-radius: 50%
position: absolute
</style> </style>

View File

@@ -1,6 +1,6 @@
<template lang="pug"> <template lang="pug">
.calendar-clock-column.flex.flex-col.items-end.gap-y-43.pt-9.pb-12.px-3 .calendar-clock-column.flex.flex-col.items-end.gap-y-43.pt-9.pb-12.px-3
span.font-medium.text-base(v-for="hour in hoursArray") {{ hour }} span.font-medium.text-base(v-for="hour in hoursArray" :key="hour" :class="currentHourStyle(hour)") {{ hour }}
</template> </template>
<script> <script>
@@ -8,11 +8,33 @@ export default {
name: "CalendarClockColumn", name: "CalendarClockColumn",
props: { props: {
hoursArray: Array, hoursArray: Array,
currentTime: String,
},
computed: {
currentHour() {
return parseInt(this.currentTime.slice(0, -6), 10);
},
},
methods: {
currentHourStyle(elem) {
if (parseInt(elem.slice(0, 3), 10) === this.currentHour) {
return {
"current-time": true,
"font-bold": true,
};
}
return {
"current-time": false,
};
},
}, },
}; };
</script> </script>
<style lang="sass" scoped> <style lang="sass" scoped>
.current-time
color: var(--time-indicator-color)
.calendar-clock-column .calendar-clock-column
width: 80px width: 80px
height: 100% height: 100%

View File

@@ -6,19 +6,18 @@
@next-date="nextDate" @next-date="nextDate"
@selected-layout="selectedLayout") @selected-layout="selectedLayout")
.schedule-body.flex .schedule-body.flex
calendar-clock-column(:hoursArray="hoursArray") calendar-clock-column(:hoursArray="hoursArray" :currentTime="currentTime")
calendar-column(:info="columnInfo" :hoursArray="hoursArray" :currentTime="currentTime") calendar-background(:hoursArray="hoursArray" :currentTime="currentTime")
</template> </template>
<script> <script>
import * as moment from "moment/moment"; import * as moment from "moment/moment";
import CalendarHeader from "./CalendarHeader.vue"; import CalendarHeader from "./CalendarHeader.vue";
import CalendarColumn from "./CalendarColumn.vue"; import CalendarBackground from "./CalendarBackground.vue";
import CalendarClockColumn from "./CalendarClockColumn.vue"; import CalendarClockColumn from "./CalendarClockColumn.vue";
import teamMemberAvatar from "@/assets/images/team-member.svg";
export default { export default {
name: "CalendarSchedule", name: "CalendarSchedule",
components: { CalendarHeader, CalendarColumn, CalendarClockColumn }, components: { CalendarHeader, CalendarBackground, CalendarClockColumn },
props: { props: {
currentDate: { currentDate: {
type: Object, type: Object,
@@ -29,15 +28,19 @@ export default {
}, },
data() { data() {
return { return {
columnInfo: {
name: "Захарова А.О.",
avatar: teamMemberAvatar,
},
currentTime: "", currentTime: "",
hoursArray: [], hoursArray: [],
timer: null, timer: null,
}; };
}, },
computed: {
hours() {
return parseInt(this.currentTime.slice(0, -6), 10);
},
hoursMinutes() {
return this.currentTime.slice(0, -3);
},
},
methods: { methods: {
previousDate() { previousDate() {
this.$emit("previous-date"); this.$emit("previous-date");
@@ -48,49 +51,56 @@ export default {
selectedLayout(option) { selectedLayout(option) {
this.$emit("selected-layout", option); this.$emit("selected-layout", option);
}, },
updateTime() { startTimer() {
let currentHour = parseInt(this.currentTime.slice(0, -6), 10); if (this.hours >= 8 && this.hours < 18) {
if (currentHour < 20 && currentHour > 8) {
this.timer = setInterval(() => { this.timer = setInterval(() => {
this.changeCurrentTime(); this.changeCurrentTime();
this.changeHoursArray(); this.changeHoursArray();
}, 30000); }, 30000);
} }
}, },
stopTimer() {
clearInterval(this.timer);
this.timer = null;
},
changeCurrentTime() { changeCurrentTime() {
this.currentTime = moment().format("HH:mm:ss"); this.currentTime = moment().format("HH:mm:ss");
}, },
hoursArrayInitialization() { hoursArrayInitialization() {
for (let i = 8; i <= 18; i++) { for (let i = 8; i <= 18; i++) {
let startTime = this.currentTime.slice(0, -3); if (i === this.hours) {
let currentHour = parseInt(startTime.slice(0, -3), 10); this.hoursArray.push(this.hoursMinutes);
if (i === currentHour) {
this.hoursArray.push(startTime);
} else this.hoursArray.push(`${i}:00`); } else this.hoursArray.push(`${i}:00`);
} }
}, },
changeHoursArray() { changeHoursArray() {
let newCurrentTime = this.currentTime.slice(0, -3); this.hoursArray = this.hoursArray.map((elem) => {
let currentHour = parseInt(newCurrentTime.slice(0, -3), 10); if (parseInt(elem.slice(0, -3), 10) === this.hours) {
let newHoursArray = this.hoursArray.map((elem) => { return this.hoursMinutes;
if (parseInt(elem.slice(0, -3), 10) === currentHour) {
return this.currentTime.slice(0, -3);
} }
return elem; return elem;
}); });
this.hoursArray = newHoursArray; },
},
watch: {
currentTime() {
if (this.hours >= 18) {
this.stopTimer();
}
}, },
}, },
mounted() { mounted() {
this.changeCurrentTime(); this.changeCurrentTime();
this.hoursArrayInitialization(); this.hoursArrayInitialization();
this.updateTime(); this.startTimer();
},
beforeUnmount() {
this.stopTimer();
}, },
}; };
</script> </script>
<style lang="sass" scoped> <style lang="sass" scoped>
.schedule .schedule
width: 100%
background-color: var(--default-white) background-color: var(--default-white)
</style> </style>

View File

@@ -23,6 +23,9 @@ module.exports = {
gap: { gap: {
43: "43px", 43: "43px",
}, },
spacing: {
"6px": "6px",
},
}, },
}, },
plugins: [], plugins: [],