add style and font family
This commit is contained in:
@@ -1,9 +1,17 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onUnmounted, ref } from "vue"
|
import { computed, onUnmounted, ref } from "vue"
|
||||||
import { timeUntil } from "../services/time-until"
|
import { timeUntil } from "../services/time-until"
|
||||||
|
|
||||||
const props = defineProps<{ project?: string; target?: string }>()
|
const props = defineProps<{ project?: string; target?: string }>()
|
||||||
|
|
||||||
|
const targetDate = computed(() =>
|
||||||
|
props.target
|
||||||
|
? new Date(props.target).toLocaleDateString(undefined, {
|
||||||
|
dateStyle: "long",
|
||||||
|
})
|
||||||
|
: null
|
||||||
|
)
|
||||||
|
|
||||||
const timeUntilTarget = props.target ? timeUntil(props.target) : null
|
const timeUntilTarget = props.target ? timeUntil(props.target) : null
|
||||||
|
|
||||||
const yearsUntil = ref(timeUntilTarget?.years ?? 0)
|
const yearsUntil = ref(timeUntilTarget?.years ?? 0)
|
||||||
@@ -13,8 +21,28 @@ const hoursUntil = ref(timeUntilTarget?.hours ?? 0)
|
|||||||
const minutesUntil = ref(timeUntilTarget?.minutes ?? 0)
|
const minutesUntil = ref(timeUntilTarget?.minutes ?? 0)
|
||||||
const secondsUntil = ref(timeUntilTarget?.seconds ?? 0)
|
const secondsUntil = ref(timeUntilTarget?.seconds ?? 0)
|
||||||
|
|
||||||
|
const isYearsDisplayed = computed(() => yearsUntil.value > 0)
|
||||||
|
const isMonthsDisplayed = computed(
|
||||||
|
() => isYearsDisplayed.value || monthsUntil.value > 0
|
||||||
|
)
|
||||||
|
const isDaysDisplayed = computed(
|
||||||
|
() => isMonthsDisplayed.value || daysUntil.value > 0
|
||||||
|
)
|
||||||
|
const isHoursDisplayed = computed(
|
||||||
|
() => isDaysDisplayed.value || hoursUntil.value > 0
|
||||||
|
)
|
||||||
|
const isMinutesDisplayed = computed(
|
||||||
|
() => isHoursDisplayed.value || minutesUntil.value > 0
|
||||||
|
)
|
||||||
|
const isSecondsDisplayed = computed(
|
||||||
|
() => isMinutesDisplayed.value || secondsUntil.value > 0
|
||||||
|
)
|
||||||
|
|
||||||
const id = setInterval(() => {
|
const id = setInterval(() => {
|
||||||
const timeUntilTarget = timeUntil("2024-03-13T09:00:00.000Z")
|
if (!props.target) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const timeUntilTarget = timeUntil(props.target)
|
||||||
|
|
||||||
yearsUntil.value = timeUntilTarget.years
|
yearsUntil.value = timeUntilTarget.years
|
||||||
monthsUntil.value = timeUntilTarget.months
|
monthsUntil.value = timeUntilTarget.months
|
||||||
@@ -28,20 +56,61 @@ onUnmounted(() => clearInterval(id))
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<h1 v-if="props.project">{{ props.project }}</h1>
|
<div class="responsive-time-until">
|
||||||
<section v-if="timeUntilTarget">
|
<h1 v-if="props.project">{{ props.project }}</h1>
|
||||||
<div v-if="yearsUntil > 0" class="count">{{ yearsUntil }} years</div>
|
<section class="time" v-if="timeUntilTarget">
|
||||||
<div v-if="monthsUntil > 0" class="count">{{ monthsUntil }} months</div>
|
<div v-if="isYearsDisplayed" class="count">
|
||||||
<div v-if="daysUntil > 0" class="count">{{ daysUntil }} days</div>
|
<span class="number">{{ yearsUntil }}</span>
|
||||||
<div v-if="hoursUntil > 0" class="count">{{ hoursUntil }} hours</div>
|
<span class="moment">years</span>
|
||||||
<div v-if="minutesUntil > 0" class="count">{{ minutesUntil }} minutes</div>
|
</div>
|
||||||
<div v-if="secondsUntil > 0" class="count">{{ secondsUntil }} seconds</div>
|
<div v-if="isMonthsDisplayed" class="count">
|
||||||
</section>
|
<span class="number">{{ monthsUntil }}</span>
|
||||||
<section v-else>No target</section>
|
<span class="moment">months</span>
|
||||||
|
</div>
|
||||||
|
<div v-if="isDaysDisplayed" class="count">
|
||||||
|
<span class="number">{{ daysUntil }}</span>
|
||||||
|
<span class="moment">days</span>
|
||||||
|
</div>
|
||||||
|
<div v-if="isHoursDisplayed" class="count">
|
||||||
|
<span class="number">{{ hoursUntil }}</span>
|
||||||
|
<span class="moment">hours</span>
|
||||||
|
</div>
|
||||||
|
<div v-if="isMinutesDisplayed" class="count">
|
||||||
|
<span class="number">{{ minutesUntil }}</span>
|
||||||
|
<span class="moment">minutes</span>
|
||||||
|
</div>
|
||||||
|
<div v-if="isSecondsDisplayed" class="count">
|
||||||
|
<span class="number">{{ secondsUntil }}</span>
|
||||||
|
<span class="moment">seconds</span>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<section v-else>No target</section>
|
||||||
|
<section v-if="targetDate" class="target-date">{{ targetDate }}</section>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
section {
|
div.responsive-time-until {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex: 1;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: space-between;
|
||||||
|
height: 100vh;
|
||||||
|
width: 100vw;
|
||||||
|
}
|
||||||
|
.time {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 1rem;
|
||||||
|
}
|
||||||
|
.count {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
.number {
|
||||||
|
font-size: 36px;
|
||||||
|
}
|
||||||
|
.target-date {
|
||||||
|
margin-bottom: 1rem;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
|
@import url("https://fonts.googleapis.com/css2?family=Sono&display=swap");
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
|
font-family: "Sono", sans-serif;
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
|
|
||||||
@@ -60,9 +62,7 @@ button:focus-visible {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#app {
|
#app {
|
||||||
max-width: 1280px;
|
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
padding: 2rem;
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user