Merge pull request #34 from dderbentsov/UC-11

WIP Сделала индикатор, таймер
This commit is contained in:
Daria Golova
2022-10-14 19:28:29 +03:00
committed by GitHub
7 changed files with 171 additions and 22 deletions

View File

@@ -17,4 +17,5 @@
--bg-hover-row-table: rgba(215, 217, 255, 0.25) --bg-hover-row-table: rgba(215, 217, 255, 0.25)
--default-white: #fff --default-white: #fff
--btn-red-color: #ff6f6f --btn-red-color: #ff6f6f
--time-indicator-color: #E93131
--br-grey-color: #D3D4DC --br-grey-color: #D3D4DC

View File

@@ -1,29 +1,23 @@
<template lang="pug"> <template lang="pug">
.calendar-container.ml-2 .calendar-container
calendar-header( calendar-schedule(
:currentDay="currentDate" :currentDate="currentDate"
@previous-date="switchPreviousDate" @previous-date="switchPreviousDate"
@next-date="switchNextDate" @next-date="switchNextDate"
@selectedLayout="changeCalendarLayout") @selected-layout="changeCalendarLayout"
calendar-column(:info="columnInfo") )
</template> </template>
<script> <script>
import * as moment from "moment/moment"; import * as moment from "moment/moment";
import CalendarHeader from "./components/CalendarHeader.vue"; import CalendarSchedule from "./components/CalendarSchedule.vue";
import CalendarColumn from "./components/CalendarColumn.vue";
import teamMemberAvatar from "@/assets/images/team-member.svg";
export default { export default {
name: "TheCalendar", name: "TheCalendar",
components: { CalendarHeader, CalendarColumn }, components: { CalendarSchedule },
data() { data() {
return { return {
currentDate: moment(),
calendarLayout: "", calendarLayout: "",
columnInfo: { currentDate: moment(),
name: "Захарова А.О.",
avatar: teamMemberAvatar,
},
}; };
}, },
methods: { methods: {

View File

@@ -0,0 +1,20 @@
<template lang="pug">
.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 }}
</template>
<script>
export default {
name: "CalendarClockColumn",
props: {
hoursArray: Array,
},
};
</script>
<style lang="sass" scoped>
.calendar-clock-column
width: 80px
height: 100%
color: var(--font-dark-blue-color)
</style>

View File

@@ -6,8 +6,9 @@
span.member-name.font-medium.text-base.mr-6 {{ info.name }} span.member-name.font-medium.text-base.mr-6 {{ info.name }}
img.icon-wrapper.cursor-pointer(src="@/assets/icons/lock.svg") img.icon-wrapper.cursor-pointer(src="@/assets/icons/lock.svg")
base-doc-ok-button base-doc-ok-button
.body.flex.flex-col .flex.flex-col
.line.flex.items-center(v-for="hour in 10" :key="hour") span.block.time-indicator(v-if="isShownIndicator" :style="indicatorLocation")
.line.flex.items-center(v-for="hour in hoursArray" :key="hour")
.middle-line .middle-line
</template> </template>
@@ -23,6 +24,33 @@ export default {
return {}; return {};
}, },
}, },
hoursArray: Array,
currentTime: String,
},
data() {
return {
isShownIndicator: true,
};
},
computed: {
indicatorLocation() {
return {
top: `${this.calculateIndicatorLocation()}px`,
};
},
},
methods: {
calculateIndicatorLocation() {
let newTime = this.currentTime
.split(":")
.map((elem) => parseInt(elem, 10));
let result = (newTime[0] - 7) * 60.5 + newTime[1];
if (result > 666) {
this.isShownIndicator = false;
return 0;
}
return result;
},
}, },
}; };
</script> </script>
@@ -30,7 +58,7 @@ export default {
<style lang="sass" scoped> <style lang="sass" scoped>
.calendar-column-wrapper .calendar-column-wrapper
width: 100% width: 100%
background-color: var(--default-white) position: relative
.header .header
height: 48px height: 48px
@@ -50,8 +78,15 @@ export default {
.line .line
border-bottom: 1px solid var(--border-light-grey-color) border-bottom: 1px solid var(--border-light-grey-color)
height: 62px height: 62px
&:last-child
display: none
.middle-line .middle-line
border-top: 1px dashed var(--border-light-grey-color) border-top: 1px dashed var(--border-light-grey-color)
width: 100% width: 100%
.time-indicator
width: 100%
border-top: 1px solid var(--time-indicator-color)
position: absolute
</style> </style>

View File

@@ -17,7 +17,7 @@ export default {
name: "CalendarHeader", name: "CalendarHeader",
components: { BaseArrowButton, CalendarLayoutSwitch }, components: { BaseArrowButton, CalendarLayoutSwitch },
props: { props: {
currentDay: Object, currentDate: Object,
}, },
data() { data() {
return { return {
@@ -26,7 +26,7 @@ export default {
}, },
computed: { computed: {
dateString() { dateString() {
let newStr = this.currentDay.format("D MMMM YYYY"); let newStr = this.currentDate.format("D MMMM YYYY");
return newStr return newStr
.split(" ") .split(" ")
.map((elem, index) => { .map((elem, index) => {
@@ -38,7 +38,7 @@ export default {
}, },
methods: { methods: {
changeSelectedLayout(option) { changeSelectedLayout(option) {
this.$emit("selectedLayout", option); this.$emit("selected-layout", option);
}, },
previousHandler() { previousHandler() {
this.$emit("previous-date"); this.$emit("previous-date");
@@ -48,9 +48,9 @@ export default {
}, },
}, },
watch: { watch: {
currentDay: function () { currentDate: function () {
this.isToday = this.isToday =
this.currentDay.format("DD.MM.YYYY") === moment().format("DD.MM.YYYY"); this.currentDate.format("DD.MM.YYYY") === moment().format("DD.MM.YYYY");
}, },
}, },
}; };

View File

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

View File

@@ -20,6 +20,9 @@ module.exports = {
"3xl": ["60px", { lineHeight: "70px" }], "3xl": ["60px", { lineHeight: "70px" }],
"4xl": ["44px", { lineHeight: "48px" }], "4xl": ["44px", { lineHeight: "48px" }],
}, },
gap: {
43: "43px",
},
}, },
}, },
plugins: [], plugins: [],