💫 (interval) add animation to plus and minus

This commit is contained in:
2020-07-15 00:54:22 +02:00
parent 965ce9f1cb
commit 556a25c908
5 changed files with 52 additions and 49 deletions

15
src/assets/minus.svg Normal file
View File

@@ -0,0 +1,15 @@
<svg
xmlns="http://www.w3.org/2000/svg"
class="icon icon-tabler icon-tabler-minus"
width="44"
height="44"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="#2c3a47"
fill="none"
stroke-linecap="round"
stroke-linejoin="round"
>
<path stroke="none" d="M0 0h24v24H0z" />
<line x1="5" y1="12" x2="19" y2="12" />
</svg>

After

Width:  |  Height:  |  Size: 335 B

16
src/assets/plus.svg Normal file
View File

@@ -0,0 +1,16 @@
<svg
xmlns="http://www.w3.org/2000/svg"
class="icon icon-tabler icon-tabler-plus"
width="44"
height="44"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="#2c3a47"
fill="none"
stroke-linecap="round"
stroke-linejoin="round"
>
<path stroke="none" d="M0 0h24v24H0z" />
<line x1="12" y1="5" x2="12" y2="19" />
<line x1="5" y1="12" x2="19" y2="12" />
</svg>

After

Width:  |  Height:  |  Size: 376 B

View File

@@ -1,41 +1,18 @@
<template> <template>
<div class="interval-input"> <div class="interval-input">
<button v-show="editable" @click="minus"> <transition name="fade" mode="out-in">
<svg <button v-show="editable" @click="minus">
xmlns="http://www.w3.org/2000/svg" <img key="minus" src="@/assets/minus.svg" alt="minus" />
class="icon icon-tabler icon-tabler-minus" </button>
width="44" </transition>
height="44" <transition name="fade" mode="out-in">
viewBox="0 0 24 24" <h2>{{ label }}</h2>
stroke-width="1.5" </transition>
stroke="#2c3a47" <transition name="fade" mode="out-in">
fill="none" <button v-show="editable" @click="plus">
stroke-linecap="round" <img key="plus" src="@/assets/plus.svg" alt="plus" />
stroke-linejoin="round" </button>
> </transition>
<path stroke="none" d="M0 0h24v24H0z" />
<line x1="5" y1="12" x2="19" y2="12" />
</svg>
</button>
<h2>{{ label }}</h2>
<button v-show="editable" @click="plus">
<svg
xmlns="http://www.w3.org/2000/svg"
class="icon icon-tabler icon-tabler-plus"
width="44"
height="44"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="#2c3a47"
fill="none"
stroke-linecap="round"
stroke-linejoin="round"
>
<path stroke="none" d="M0 0h24v24H0z" />
<line x1="12" y1="5" x2="12" y2="19" />
<line x1="5" y1="12" x2="19" y2="12" />
</svg>
</button>
</div> </div>
</template> </template>
@@ -48,18 +25,16 @@ export default defineComponent({
props: { props: {
editable: { type: Boolean, required: true } editable: { type: Boolean, required: true }
}, },
setup(props) { setup() {
const { interval, minInterval, minus, plus } = useInterval() const { interval, minInterval, minus, plus } = useInterval()
const label = computed(() => { const label = computed(() => {
if (interval.value > 1) { if (interval.value > 1) {
return props.editable return `${interval.value} minute session`
? `${interval.value} minutes`
: `${interval.value} minute session`
} }
if (interval.value === minInterval) { if (interval.value === minInterval) {
return props.editable ? '30 seconds' : '30 second session' return '30 second session'
} }
return `${interval.value} minute` return `${interval.value} minute`

View File

@@ -54,7 +54,7 @@ a {
.fade-enter-active, .fade-enter-active,
.fade-leave-active { .fade-leave-active {
transition: opacity 0.3s ease; transition: opacity 0.25s ease;
} }
.fade-enter, .fade-enter,
.fade-leave-to { .fade-leave-to {

View File

@@ -24,12 +24,16 @@
v-if="timeState === 'stopped'" v-if="timeState === 'stopped'"
src="@/assets/play.svg" src="@/assets/play.svg"
alt="play" alt="play"
width="44px"
height="44px"
/> />
<img <img
key="pause" key="pause"
v-if="timeState === 'started'" v-if="timeState === 'started'"
src="@/assets/pause.svg" src="@/assets/pause.svg"
alt="pause" alt="pause"
width="44px"
height="44px"
/> />
</transition> </transition>
</button> </button>
@@ -140,11 +144,4 @@ footer {
font-style: italic; font-style: italic;
font-size: 1rem; font-size: 1rem;
} }
$button-size: 44px;
button {
width: $button-size;
height: $button-size;
}
</style> </style>