2019-10-05 21:17:18 +02:00
|
|
|
<docs>
|
|
|
|
### Example
|
|
|
|
```vue
|
|
|
|
<DateCalendarIcon date="2019-10-05T18:41:11.720Z" />
|
|
|
|
```
|
|
|
|
|
|
|
|
```vue
|
|
|
|
<DateCalendarIcon
|
|
|
|
:date="new Date()"
|
|
|
|
/>
|
|
|
|
```
|
|
|
|
</docs>
|
|
|
|
|
2019-03-21 20:23:42 +01:00
|
|
|
<template>
|
2020-02-18 08:57:00 +01:00
|
|
|
<time class="datetime-container" :datetime="dateObj.getUTCSeconds()">
|
|
|
|
<span class="month">{{ month }}</span>
|
|
|
|
<span class="day">{{ day }}</span>
|
|
|
|
</time>
|
2019-03-21 20:23:42 +01:00
|
|
|
</template>
|
|
|
|
<script lang="ts">
|
2020-02-18 08:57:00 +01:00
|
|
|
import { Component, Prop, Vue } from "vue-property-decorator";
|
2019-03-21 20:23:42 +01:00
|
|
|
|
|
|
|
@Component
|
2019-04-03 17:29:03 +02:00
|
|
|
export default class DateCalendarIcon extends Vue {
|
2019-10-05 21:17:18 +02:00
|
|
|
/**
|
|
|
|
* `date` can be a string or an actual date object.
|
|
|
|
*/
|
2019-03-21 20:23:42 +01:00
|
|
|
@Prop({ required: true }) date!: string;
|
|
|
|
|
2020-10-13 20:39:59 +02:00
|
|
|
get dateObj(): Date {
|
2019-04-03 17:29:03 +02:00
|
|
|
return new Date(this.$props.date);
|
2019-03-21 20:23:42 +01:00
|
|
|
}
|
|
|
|
|
2020-10-13 20:39:59 +02:00
|
|
|
get month(): string {
|
2020-02-18 08:57:00 +01:00
|
|
|
return this.dateObj.toLocaleString(undefined, { month: "short" });
|
2019-03-21 20:23:42 +01:00
|
|
|
}
|
|
|
|
|
2020-10-13 20:39:59 +02:00
|
|
|
get day(): string {
|
2020-02-18 08:57:00 +01:00
|
|
|
return this.dateObj.toLocaleString(undefined, { day: "numeric" });
|
2019-03-21 20:23:42 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2020-02-18 08:57:00 +01:00
|
|
|
time.datetime-container {
|
2020-06-24 10:05:22 +02:00
|
|
|
background: $backgrounds;
|
|
|
|
border: 1px solid $borders;
|
2020-02-18 08:57:00 +01:00
|
|
|
border-radius: 8px;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
justify-content: center;
|
|
|
|
/*height: 50px;*/
|
|
|
|
width: 50px;
|
|
|
|
padding: 8px;
|
|
|
|
text-align: center;
|
2019-03-21 20:23:42 +01:00
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
span {
|
|
|
|
display: block;
|
|
|
|
font-weight: 600;
|
2019-03-21 20:23:42 +01:00
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
&.month {
|
2020-06-24 10:05:22 +02:00
|
|
|
color: $danger;
|
2020-02-18 08:57:00 +01:00
|
|
|
padding: 2px 0;
|
|
|
|
font-size: 12px;
|
|
|
|
line-height: 12px;
|
|
|
|
text-transform: uppercase;
|
|
|
|
}
|
2019-03-21 20:23:42 +01:00
|
|
|
|
2020-02-18 08:57:00 +01:00
|
|
|
&.day {
|
2020-06-24 10:05:22 +02:00
|
|
|
color: $violet-3;
|
2020-02-18 08:57:00 +01:00
|
|
|
font-size: 20px;
|
|
|
|
line-height: 20px;
|
2019-03-21 20:23:42 +01:00
|
|
|
}
|
|
|
|
}
|
2020-02-18 08:57:00 +01:00
|
|
|
}
|
2019-03-21 20:23:42 +01:00
|
|
|
</style>
|