✨ (interval) new way to set interval time
This commit is contained in:
53
src/components/IntervalInput.vue
Normal file
53
src/components/IntervalInput.vue
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
<template>
|
||||||
|
<div class="interval-input">
|
||||||
|
<button v-show="editable" @click="minus">-</button>
|
||||||
|
<h3>{{ interval }} {{ label }}</h3>
|
||||||
|
<button v-show="editable" @click="plus">+</button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
import { defineComponent, computed } from '@vue/composition-api'
|
||||||
|
|
||||||
|
const MIN_INTERVAL = 1
|
||||||
|
|
||||||
|
export default defineComponent({
|
||||||
|
name: 'IntervalInput',
|
||||||
|
props: {
|
||||||
|
editable: { type: Boolean, required: true },
|
||||||
|
interval: { type: Number, required: true }
|
||||||
|
},
|
||||||
|
setup(props, { emit }) {
|
||||||
|
const minus = () => {
|
||||||
|
if (props.interval > MIN_INTERVAL) {
|
||||||
|
emit('update', props.interval - 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const plus = () => {
|
||||||
|
emit('update', props.interval + 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
const label = computed(() =>
|
||||||
|
props.interval > MIN_INTERVAL ? 'minutes' : 'minute'
|
||||||
|
)
|
||||||
|
|
||||||
|
return {
|
||||||
|
minus,
|
||||||
|
plus,
|
||||||
|
label
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.interval-input {
|
||||||
|
margin: 0 auto;
|
||||||
|
max-width: 50vh;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
gap: 1rem;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -32,9 +32,3 @@ button:focus {
|
|||||||
button:active {
|
button:active {
|
||||||
transform: scale(0.99);
|
transform: scale(0.99);
|
||||||
}
|
}
|
||||||
|
|
||||||
input {
|
|
||||||
padding: 0.5rem;
|
|
||||||
text-align: center;
|
|
||||||
border-radius: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,24 +1,16 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="home">
|
<div class="home">
|
||||||
|
<IntervalInput
|
||||||
|
:interval="interval"
|
||||||
|
:editable="timeState === 'stopped'"
|
||||||
|
@update="(int) => (interval = int)"
|
||||||
|
/>
|
||||||
<section class="developers">
|
<section class="developers">
|
||||||
<DreamMaker
|
<DreamMaker
|
||||||
position="1"
|
position="1"
|
||||||
:is-turn="isProgrammer1Turn"
|
:is-turn="isProgrammer1Turn"
|
||||||
:session="session"
|
:session="session"
|
||||||
/>
|
/>
|
||||||
<div v-if="timeState === 'stopped'">
|
|
||||||
<input
|
|
||||||
id="interval"
|
|
||||||
name="interval"
|
|
||||||
placeholder="intervale"
|
|
||||||
v-model.number="interval"
|
|
||||||
type="number"
|
|
||||||
step="1"
|
|
||||||
min="1"
|
|
||||||
@keypress.enter="start"
|
|
||||||
/>
|
|
||||||
minutes
|
|
||||||
</div>
|
|
||||||
<DreamMaker
|
<DreamMaker
|
||||||
position="2"
|
position="2"
|
||||||
:is-turn="!isProgrammer1Turn"
|
:is-turn="!isProgrammer1Turn"
|
||||||
@@ -39,12 +31,14 @@ import { defineComponent, onUnmounted } from '@vue/composition-api'
|
|||||||
import { useTimer } from '@/hooks/useTimer'
|
import { useTimer } from '@/hooks/useTimer'
|
||||||
import DreamMaker from '@/components/DreamMaker.vue'
|
import DreamMaker from '@/components/DreamMaker.vue'
|
||||||
import ChilledMusic from '@/components/ChilledMusic.vue'
|
import ChilledMusic from '@/components/ChilledMusic.vue'
|
||||||
|
import IntervalInput from '@/components/IntervalInput.vue'
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'Home',
|
name: 'Home',
|
||||||
components: {
|
components: {
|
||||||
DreamMaker,
|
DreamMaker,
|
||||||
ChilledMusic
|
ChilledMusic,
|
||||||
|
IntervalInput
|
||||||
},
|
},
|
||||||
setup() {
|
setup() {
|
||||||
const {
|
const {
|
||||||
|
|||||||
Reference in New Issue
Block a user