Merge pull request #24 from dderbentsov/UC-10

Сделала CalendarHeader, подключила moment js
This commit is contained in:
Daria Golova
2022-10-12 18:47:39 +03:00
committed by GitHub
9 changed files with 195 additions and 9 deletions

14
package-lock.json generated
View File

@@ -8,6 +8,7 @@
"name": "urban-couscous",
"version": "0.1.0",
"dependencies": {
"moment": "^2.29.4",
"vue": "^3.2.13",
"vue-router": "^4.1.5",
"vuex": "^4.0.2"
@@ -9154,6 +9155,14 @@
"integrity": "sha512-A/78XjoX2EmNvppVWEhM2oGk3x4lLxnkEA4jTbaK97QKSDjkIoOsKQlfylt/d3kKKi596Qy3NP5XrXJ6fZIC9Q==",
"dev": true
},
"node_modules/moment": {
"version": "2.29.4",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz",
"integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==",
"engines": {
"node": "*"
}
},
"node_modules/mrmime": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/mrmime/-/mrmime-1.0.1.tgz",
@@ -20965,6 +20974,11 @@
"integrity": "sha512-A/78XjoX2EmNvppVWEhM2oGk3x4lLxnkEA4jTbaK97QKSDjkIoOsKQlfylt/d3kKKi596Qy3NP5XrXJ6fZIC9Q==",
"dev": true
},
"moment": {
"version": "2.29.4",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz",
"integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w=="
},
"mrmime": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/mrmime/-/mrmime-1.0.1.tgz",

View File

@@ -8,6 +8,7 @@
"lint": "vue-cli-service lint"
},
"dependencies": {
"moment": "^2.29.4",
"vue": "^3.2.13",
"vue-router": "^4.1.5",
"vuex": "^4.0.2"

View File

@@ -13,7 +13,6 @@
[class^="icon-"]::before, [class*=" icon-"]::before {
/* use !important to prevent issues with browser extensions that change fonts */
font-family: 'icomoon' !important;
speak: never;
font-style: normal;
font-weight: normal;
font-variant: normal;

View File

@@ -1,10 +1,11 @@
\:root
--bg-lavender-color: #E9E9F6
--bg-white-color: #F8F8FF
--bg-ligth-blue-color: #E6EAFC
--bg-lavender-color: #e9e9f6
--bg-white-color: #f8f8ff
--bg-ligth-blue-color: #e6eafc
--font-dark-blue-color: #252850
--font-black-color: #090A15
--btn-blue-color: #4772F2
--font-grey-color: #9294A7
--border-light-grey-color: #9294A7
--font-black-color: #090a15
--btn-blue-color: #4772f2
--btn-light-blue-color: #c6d2f6
--font-grey-color: #9294a7
--border-light-grey-color: #d3d4dc
--default-shadow: 4px 4px 8px rgba(9, 10, 21, 0.1), -4px -4px 8px rgba(9, 10, 21, 0.1)

View File

@@ -0,0 +1,24 @@
<template lang="pug">
button.arrow-button.flex.items-center.icon-down-arrow.px-2.pt-px
</template>
<script>
export default {
name: "ArrowButton",
data() {
return {};
},
};
</script>
<style lang="sass">
.arrow-button
width: 32px
height: 32px
background: var(--btn-light-blue-color)
color: var(--btn-blue-color)
border-radius: 50%
font-size: 16px
&:hover
background: #a0b4f0
</style>

View File

@@ -1,9 +1,10 @@
import { createApp } from "vue";
import App from "./App.vue";
import router from "./router";
import moment from "moment";
import "./assets/sass/fonts.sass";
import "./assets/sass/tailwind.sass";
import "./assets/sass/variables.sass";
import "./assets/css/iconfonts.css";
createApp(App).use(router).mount("#app");
createApp(App).use(router, moment).mount("#app");

View File

@@ -1,8 +1,29 @@
<template lang="pug">
calendar-header(
:currentDay="currentDate"
@previous-date="switchPreviousDate"
@next-date="switchNextDate")
</template>
<script>
import * as moment from "moment/moment";
import CalendarHeader from "./components/CalendarHeader.vue";
moment.locale("ru");
export default {
name: "TheCalendar",
components: { CalendarHeader },
data() {
return {
currentDate: moment(),
};
},
methods: {
switchPreviousDate() {
this.currentDate = this.currentDate.clone().subtract(1, "day");
},
switchNextDate() {
this.currentDate = this.currentDate.clone().add(1, "day");
},
},
};
</script>

View File

@@ -0,0 +1,78 @@
<template lang="pug">
.calendar-header-wrapper.flex.items-center.justify-between.ml-2.py-3.pl-5.pr-6
.flex
base-arrow-button.left-arrow.mr-4(@click="previousHandler")
base-arrow-button.right-arrow.mr-6(@click="nextHandler")
.text.flex.items-center
span.font-medium.text-base {{ dateString }}
span.today.font-bold.text-xxs(v-if="isToday") Сегодня
calendar-layout-switch(@selected="changeSelectedLayout")
</template>
<script>
import * as moment from "moment/moment";
import BaseArrowButton from "@/components/base/buttons/BaseArrowButton.vue";
import CalendarLayoutSwitch from "./CalendarLayoutSwitch.vue";
export default {
name: "CalendarHeader",
components: { BaseArrowButton, CalendarLayoutSwitch },
props: {
currentDay: Object,
},
data() {
return {
isToday: true,
selectedLayout: "",
};
},
computed: {
dateString() {
let newStr = this.currentDay.format("D MMMM YYYY");
return newStr
.split(" ")
.map((elem, index) => {
if (index === 1) return elem[0].toUpperCase() + elem.slice(1);
return elem;
})
.join(" ");
},
},
methods: {
changeSelectedLayout(option) {
this.selectedLayout = option;
},
previousHandler() {
this.$emit("previous-date");
},
nextHandler() {
this.$emit("next-date");
},
},
watch: {
currentDay: function () {
this.isToday =
this.currentDay.format("DD.MM.YYYY") === moment().format("DD.MM.YYYY");
},
},
};
</script>
<style lang="sass" scoped>
.calendar-header-wrapper
width: 100%
background-color: var(--bg-white-color)
height: 56px
border-radius: 4px
.left-arrow
transform: rotate(90deg)
.right-arrow
transform: rotate(270deg)
.text
color: var(--font-dark-blue-color)
.today
opacity: 0.5
</style>

View File

@@ -0,0 +1,47 @@
<template lang="pug">
.layout-switch-wrapper.inline-block
button#day.py-2.px-3(:class="dayLayoutState" @click="changeSelectedLayout") День
button#week.py-2.px-3(:class="weekLayoutState" @click="changeSelectedLayout") Неделя
</template>
<script>
export default {
name: "CalendarLayoutSwitch",
props: {},
data() {
return {
selectedLayout: "day",
};
},
computed: {
dayLayoutState() {
return {
active: this.selectedLayout === "day",
};
},
weekLayoutState() {
return {
active: this.selectedLayout === "week",
};
},
},
methods: {
changeSelectedLayout(event) {
this.selectedLayout = event.target.id;
this.$emit("selected", event.target.id);
},
},
};
</script>
<style lang="sass" scoped>
.active
background-color: #6787e7
color: var(--bg-white-color)
border-radius: 4px
.layout-switch-wrapper
background-color: var(--bg-lavender-color)
color: var(--font-dark-blue-color)
border-radius: 4px
</style>