-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(timers): Redesign timers and remove dependency on day.js (#186)
* feat(timer): Redesign traditional timer * feat(timer): Make traditional timer mobile-friendly * feat(timer): Percentage timer calculates its value by itself * feat(timer): Update approximate timer Timer does not depend on DayJS anymore and its design was updated * feat(timer): Timers emit their own page titles using `@tick` * fix(timer): Adjust font sizes for mobile * refactor: Remove day.js dependency * refactor: Remove day.js specific commands from i18nwatcher * refactor: Compact settingsTime time formatting * refactor: Remove settingsTime dependency on day.js * refactor(timer): Remove Source Sans Pro from percentage timer * chore: Remove commented Source Sans Pro from Nuxt config * chore: Remove unused Source Sans Pro SCSS
- Loading branch information
Showing
14 changed files
with
124 additions
and
131 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,63 @@ | ||
<template> | ||
<div :class="['timer-traditional font-bold text-7xl lg:text-[14rem] timer-display', { 'active': running }]" v-text="$dayjs.formatMs(timeOriginal - timeElapsed, {})" /> | ||
<div | ||
:class="['flex flex-row gap-0 md:text-[14rem] text-[9rem] leading-none timer-display relative', { 'active': running }]" | ||
> | ||
<transition-group | ||
name="transition-traditional" | ||
enter-class="translate-x-4 opacity-0" | ||
enter-active-class="duration-500" | ||
enter-to-class="" | ||
leave-class="" | ||
leave-active-class="duration-300 absolute" | ||
leave-to-class="opacity-0" | ||
move-class="duration-500" | ||
class="flex flex-col items-center md:flex-row" | ||
tag="div" | ||
> | ||
<div | ||
v-for="key in timeLeftStructured.displayKeys" | ||
:key="key" | ||
class="transition flex flex-row" | ||
:class="{ 'font-bold': key === 'minutes', 'md:text-9xl md:self-start': key === 'seconds', 'md:mr-4': key === 'hours' }" | ||
tag="div" | ||
> | ||
<span | ||
v-for="(char, idx) in timeLeftStructured.num[key].toString().padStart(2, '0')" | ||
:key="`${key}-${idx}`" | ||
class="w-[1ch]" | ||
:class="{ 'md:text-right text-center': idx === 0, 'md:text-left text-center': idx === 1 }" | ||
v-text="char" | ||
/> | ||
</div> | ||
</transition-group> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import TimerMixin from '@/assets/mixins/timerMixin' | ||
export default { | ||
mixins: [TimerMixin] | ||
} | ||
</script> | ||
mixins: [TimerMixin], | ||
computed: { | ||
timeLeftStructured () { | ||
const sLeft = Math.round((this.timeOriginal - this.timeElapsed) / 1000) | ||
const hours = Math.floor(sLeft / (60 * 60)) | ||
const minutes = Math.floor((sLeft % (60 * 60)) / (60)) | ||
const seconds = Math.floor(sLeft % 60) | ||
<style lang="scss" scoped> | ||
@import '@/assets/scss/SourceSansPro_Numbers.scss'; | ||
const returnObject = { | ||
num: { hours, minutes, seconds }, | ||
displayKeys: ['hours', 'minutes', 'seconds'].filter(value => value !== 'hours' || hours > 0) | ||
} | ||
.timer-traditional { | ||
font-family: 'Source Sans Pro', monospace; | ||
font-variant-numeric: tabular-nums; | ||
font-feature-settings: "lnum" on; | ||
letter-spacing: 0.5rem; | ||
this.$emit( | ||
'tick', | ||
returnObject.displayKeys | ||
.map(key => returnObject.num[key].toString().padStart(2, '0')) | ||
.join(':') | ||
) | ||
return returnObject | ||
} | ||
} | ||
} | ||
</style> | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.