WIP Позиционирование descriptionCard в 4 стороны

This commit is contained in:
Daria Golova
2022-11-18 16:08:34 +03:00
parent e7463b5296
commit c8fc1b944a
5 changed files with 33 additions and 34 deletions

View File

@@ -70,7 +70,7 @@ export default {
showModal: false, showModal: false,
timeInformation: { timeInformation: {
dayStartTime: "00:00", dayStartTime: "00:00",
dayEndTime: "24:00", dayEndTime: "20:00",
}, },
eventsData: [], eventsData: [],
employeesData: [], employeesData: [],

View File

@@ -29,7 +29,6 @@
@close-description-card="closeDescriptionCard" @close-description-card="closeDescriptionCard"
@delete-event="transmitDeleteEvent" @delete-event="transmitDeleteEvent"
:schedule-body-ref="scheduleBodyRef" :schedule-body-ref="scheduleBodyRef"
:event-card-size="cardSize"
) )
</template> </template>
@@ -223,12 +222,6 @@ export default {
this.hideDescriptionCard(); this.hideDescriptionCard();
this.setDefaultTheme(); this.setDefaultTheme();
}, },
writeCardSize() {
this.cardSize = {
width: this.$refs["eventCard"].getBoundingClientRect().width,
height: this.calculateCardHeight - 8,
};
},
}, },
watch: { watch: {
changeFormWasClosed: { changeFormWasClosed: {
@@ -241,21 +234,16 @@ export default {
}, },
}, },
}, },
mounted() {
this.writeCardSize();
},
}; };
</script> </script>
<style lang="sass" scoped> <style lang="sass" scoped>
.wrapper .wrapper
position: absolute position: absolute
z-index: 3
width: calc(100% - 8px) width: calc(100% - 8px)
height: 23px
.default-theme .default-theme
z-index: 0 z-index: 2
.card .card
background-color: var(--bg-color) background-color: var(--bg-color)
border: 2px solid var(--border-color) border: 2px solid var(--border-color)
@@ -271,6 +259,7 @@ export default {
background-color: var(--font-color) background-color: var(--font-color)
.active-theme .active-theme
z-index: 3
.card .card
background-color: var(--bg-active) background-color: var(--bg-active)
border: 2px solid var(--border-active-color) border: 2px solid var(--border-active-color)

View File

@@ -16,7 +16,10 @@
.icon-cancel.text-xxs.flex.items-center.cursor-pointer(@click="close") .icon-cancel.text-xxs.flex.items-center.cursor-pointer(@click="close")
.body.mr-6 .body.mr-6
span.text-base {{ eventMember }} span.text-base {{ eventMember }}
.flex.text-xxs.mt-4.justify-between(v-if="!disabled") .flex.text-xxs.justify-between(
v-if="!disabled",
:class="{'mt-4': description.length > 0}"
)
.column .column
ul ul
li(v-for="elem in description" :key="elem") {{ elem }} li(v-for="elem in description" :key="elem") {{ elem }}
@@ -38,7 +41,6 @@ export default {
default: false, default: false,
}, },
scheduleBodyRef: Node, scheduleBodyRef: Node,
eventCardSize: Object,
}, },
data() { data() {
return { return {
@@ -119,19 +121,27 @@ export default {
if (!this.$refs.descriptionCard || !this.scheduleBodyRef) return; if (!this.$refs.descriptionCard || !this.scheduleBodyRef) return;
const cardRect = this.$refs.descriptionCard.getBoundingClientRect(); const cardRect = this.$refs.descriptionCard.getBoundingClientRect();
const bodyRect = this.scheduleBodyRef.getBoundingClientRect(); const bodyRect = this.scheduleBodyRef.getBoundingClientRect();
//const bodyHeight = this.scheduleBodyRef.clientHeight + bodyRect.y - 20; const bodyHeight = this.scheduleBodyRef.clientHeight + bodyRect.y - 20;
const bodyWidth = this.scheduleBodyRef.clientWidth + bodyRect.x - 20; const bodyWidth = this.scheduleBodyRef.clientWidth;
if (cardRect.x + cardRect.width > bodyWidth) { console.log(cardRect.x, cardRect.width, bodyWidth);
if (cardRect.x + 2 * cardRect.width < bodyWidth) {
this.position = { this.position = {
top: `-${this.eventCardSize.height + 8}px`, top: 0,
right: `-${cardRect.width + 8}px`,
};
} else if (cardRect.x - 84 > bodyRect.x) {
this.position = {
top: 0,
left: `-${cardRect.width + 8}px`, left: `-${cardRect.width + 8}px`,
}; };
} else { } else if (cardRect.y + cardRect.height < bodyHeight) {
this.position = { this.position = {
top: `-${this.eventCardSize.height + 8}px`, "margin-top": "8px",
right: `-${this.eventCardSize.width + 8}px`, };
} else
this.position = {
top: `-${cardRect.height + 8}px`,
}; };
}
}, },
}; };
</script> </script>

View File

@@ -21,15 +21,15 @@
) Создать событие ) Создать событие
calendar-sidebar-event(:is-open="isOpen", :event-type="eventTypes") calendar-sidebar-event(:is-open="isOpen", :event-type="eventTypes")
calendar-sidebar-teammate(:team-data="teamData", :is-open="isOpen") calendar-sidebar-teammate(:team-data="teamData", :is-open="isOpen")
//- .button-wrapper.flex.justify-center.mb-23px .button-wrapper.flex.justify-center.mb-23px
//- base-button( base-button(
//- left-icon="icon-long-arrow", left-icon="icon-long-arrow",
//- rounded, :size="40", rounded, :size="40",
//- :icon-left-size="18", :icon-left-size="18",
//- secondary, secondary,
//- :style="{ transform: `rotate(${turnButton})`}", :style="{ transform: `rotate(${turnButton})`}",
//- @click="changeSize" @click="changeSize"
//- ) )
</template> </template>
<script> <script>

View File

@@ -1,5 +1,5 @@
<template lang="pug"> <template lang="pug">
.wrapper.flex.w-full.relative.mx-6 .wrapper.flex.w-full.relative.mx-2
clients-table(:open-form="openForm", :current-year="currentYear") clients-table(:open-form="openForm", :current-year="currentYear")
</template> </template>