WIP Сделала CalendarHeader, подключила moment js
This commit is contained in:
14
package-lock.json
generated
14
package-lock.json
generated
@@ -8,6 +8,7 @@
|
|||||||
"name": "urban-couscous",
|
"name": "urban-couscous",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"moment": "^2.29.4",
|
||||||
"vue": "^3.2.13",
|
"vue": "^3.2.13",
|
||||||
"vue-router": "^4.1.5",
|
"vue-router": "^4.1.5",
|
||||||
"vuex": "^4.0.2"
|
"vuex": "^4.0.2"
|
||||||
@@ -9154,6 +9155,14 @@
|
|||||||
"integrity": "sha512-A/78XjoX2EmNvppVWEhM2oGk3x4lLxnkEA4jTbaK97QKSDjkIoOsKQlfylt/d3kKKi596Qy3NP5XrXJ6fZIC9Q==",
|
"integrity": "sha512-A/78XjoX2EmNvppVWEhM2oGk3x4lLxnkEA4jTbaK97QKSDjkIoOsKQlfylt/d3kKKi596Qy3NP5XrXJ6fZIC9Q==",
|
||||||
"dev": true
|
"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": {
|
"node_modules/mrmime": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/mrmime/-/mrmime-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/mrmime/-/mrmime-1.0.1.tgz",
|
||||||
@@ -20965,6 +20974,11 @@
|
|||||||
"integrity": "sha512-A/78XjoX2EmNvppVWEhM2oGk3x4lLxnkEA4jTbaK97QKSDjkIoOsKQlfylt/d3kKKi596Qy3NP5XrXJ6fZIC9Q==",
|
"integrity": "sha512-A/78XjoX2EmNvppVWEhM2oGk3x4lLxnkEA4jTbaK97QKSDjkIoOsKQlfylt/d3kKKi596Qy3NP5XrXJ6fZIC9Q==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"moment": {
|
||||||
|
"version": "2.29.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz",
|
||||||
|
"integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w=="
|
||||||
|
},
|
||||||
"mrmime": {
|
"mrmime": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/mrmime/-/mrmime-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/mrmime/-/mrmime-1.0.1.tgz",
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
"lint": "vue-cli-service lint"
|
"lint": "vue-cli-service lint"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"moment": "^2.29.4",
|
||||||
"vue": "^3.2.13",
|
"vue": "^3.2.13",
|
||||||
"vue-router": "^4.1.5",
|
"vue-router": "^4.1.5",
|
||||||
"vuex": "^4.0.2"
|
"vuex": "^4.0.2"
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
[class^="icon-"]::before, [class*=" icon-"]::before {
|
[class^="icon-"]::before, [class*=" icon-"]::before {
|
||||||
/* use !important to prevent issues with browser extensions that change fonts */
|
/* use !important to prevent issues with browser extensions that change fonts */
|
||||||
font-family: 'icomoon' !important;
|
font-family: 'icomoon' !important;
|
||||||
speak: never;
|
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
font-variant: normal;
|
font-variant: normal;
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
import { createApp } from "vue";
|
import { createApp } from "vue";
|
||||||
import App from "./App.vue";
|
import App from "./App.vue";
|
||||||
import router from "./router";
|
import router from "./router";
|
||||||
|
import moment from "moment";
|
||||||
import "./assets/sass/fonts.sass";
|
import "./assets/sass/fonts.sass";
|
||||||
import "./assets/sass/tailwind.sass";
|
import "./assets/sass/tailwind.sass";
|
||||||
import "./assets/sass/variables.sass";
|
import "./assets/sass/variables.sass";
|
||||||
import "./assets/css/iconfonts.css";
|
import "./assets/css/iconfonts.css";
|
||||||
|
|
||||||
createApp(App).use(router).mount("#app");
|
createApp(App).use(router, moment).mount("#app");
|
||||||
|
|||||||
@@ -1,10 +1,29 @@
|
|||||||
<template lang="pug">
|
<template lang="pug">
|
||||||
calendar-header
|
calendar-header(
|
||||||
|
:currentDay="currentDate"
|
||||||
|
@previous-date="switchPreviousDate"
|
||||||
|
@next-date="switchNextDate")
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import * as moment from "moment/moment";
|
||||||
import CalendarHeader from "./components/CalendarHeader.vue";
|
import CalendarHeader from "./components/CalendarHeader.vue";
|
||||||
|
moment.locale("ru");
|
||||||
export default {
|
export default {
|
||||||
name: "TheCalendar",
|
name: "TheCalendar",
|
||||||
components: { CalendarHeader },
|
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>
|
</script>
|
||||||
|
|||||||
@@ -1,30 +1,58 @@
|
|||||||
<template lang="pug">
|
<template lang="pug">
|
||||||
.calendar-header-wrapper.flex.items-center.justify-between.ml-2.py-3.pl-5.pr-6
|
.calendar-header-wrapper.flex.items-center.justify-between.ml-2.py-3.pl-5.pr-6
|
||||||
.flex
|
.flex
|
||||||
base-arrow-button.left-arrow.mr-4
|
base-arrow-button.left-arrow.mr-4(@click="previousHandler")
|
||||||
base-arrow-button.right-arrow.mr-6
|
base-arrow-button.right-arrow.mr-6(@click="nextHandler")
|
||||||
.text.flex.items-center
|
.text.flex.items-center
|
||||||
span.font-medium.text-base 24 Мая 2022
|
span.font-medium.text-base {{ dateString }}
|
||||||
span.today.font-bold.text-xxs(v-if="isToday") Сегодня
|
span.today.font-bold.text-xxs(v-if="isToday") Сегодня
|
||||||
calendar-layout-switch(@selected="changeSelectedLayout")
|
calendar-layout-switch(@selected="changeSelectedLayout")
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import * as moment from "moment/moment";
|
||||||
import BaseArrowButton from "@/components/base/buttons/BaseArrowButton.vue";
|
import BaseArrowButton from "@/components/base/buttons/BaseArrowButton.vue";
|
||||||
import CalendarLayoutSwitch from "./CalendarLayoutSwitch.vue";
|
import CalendarLayoutSwitch from "./CalendarLayoutSwitch.vue";
|
||||||
export default {
|
export default {
|
||||||
name: "CalendarHeader",
|
name: "CalendarHeader",
|
||||||
components: { BaseArrowButton, CalendarLayoutSwitch },
|
components: { BaseArrowButton, CalendarLayoutSwitch },
|
||||||
|
props: {
|
||||||
|
currentDay: Object,
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
isToday: true,
|
isToday: true,
|
||||||
selectedLayout: "",
|
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: {
|
methods: {
|
||||||
changeSelectedLayout(option) {
|
changeSelectedLayout(option) {
|
||||||
this.selectedLayout = 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>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user