misskey/src/client/components/header-clock.vue

102 lines
1.7 KiB
Vue
Raw Normal View History

2020-02-14 09:54:42 -08:00
<template>
<div class="eqryymyo">
<div class="header">
<time ref="time" class="_ghost">
<span class="yyyymmdd">{{ yyyy }}/{{ mm }}/{{ dd }}</span>
<br>
<span class="hhnn">{{ hh }}<span :style="{ visibility: now.getSeconds() % 2 == 0 ? 'visible' : 'hidden' }">:</span>{{ nn }}</span>
</time>
</div>
2020-02-15 00:31:45 -08:00
<div class="content _panel _ghost">
2020-02-14 09:54:42 -08:00
<mk-clock/>
</div>
</div>
</template>
<script lang="ts">
import Vue from 'vue';
import MkClock from './analog-clock.vue';
export default Vue.extend({
components: {
MkClock
},
data() {
return {
now: new Date(),
clock: null
};
},
computed: {
yyyy(): number {
return this.now.getFullYear();
},
mm(): string {
return ('0' + (this.now.getMonth() + 1)).slice(-2);
},
dd(): string {
return ('0' + this.now.getDate()).slice(-2);
},
hh(): string {
return ('0' + this.now.getHours()).slice(-2);
},
nn(): string {
return ('0' + this.now.getMinutes()).slice(-2);
}
},
mounted() {
this.tick();
this.clock = setInterval(this.tick, 1000);
},
beforeDestroy() {
clearInterval(this.clock);
},
methods: {
tick() {
this.now = new Date();
}
}
});
</script>
<style lang="scss" scoped>
.eqryymyo {
display: inline-block;
overflow: visible;
> .header {
padding: 0 12px;
2020-02-14 15:52:21 -08:00
padding-top: 4px;
2020-02-14 09:54:42 -08:00
text-align: center;
font-size: 12px;
2020-02-14 15:52:21 -08:00
font-family: Lucida Console, Courier, monospace;
2020-02-14 09:54:42 -08:00
&:hover + .content {
opacity: 1;
}
> time {
display: table-cell;
vertical-align: middle;
height: 48px;
> .yyyymmdd {
opacity: 0.7;
}
}
}
> .content {
opacity: 0;
display: block;
position: absolute;
top: auto;
right: 0;
margin: 16px 0 0 0;
padding: 16px;
width: 230px;
transition: opacity 0.2s ease;
}
}
</style>