From b81983acdfe22a559f69481a7da22a48a2dd857c Mon Sep 17 00:00:00 2001 From: Julien Calixte Date: Sat, 11 Jul 2020 00:52:38 +0200 Subject: [PATCH] :sparkles: (action) add pause button --- src/hooks/useTimer.ts | 9 +++++++-- src/views/Home.vue | 9 ++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/hooks/useTimer.ts b/src/hooks/useTimer.ts index ecaf7f8..d70078b 100644 --- a/src/hooks/useTimer.ts +++ b/src/hooks/useTimer.ts @@ -33,7 +33,7 @@ export const useTimer = () => { const start = () => { timeState.value = 'started' - notify('La session commence !') + notify(seconds.value ? 'La session reprend !' : 'La session commence !') stopwatchId = setInterval(() => { seconds.value++ @@ -54,7 +54,7 @@ export const useTimer = () => { }, 1000) } - const clear = () => { + const pause = () => { timeState.value = 'stopped' if (stopwatchId) { clearInterval(stopwatchId) @@ -64,6 +64,10 @@ export const useTimer = () => { clearInterval(stopWatchSessionId) stopWatchSessionId = null } + } + + const clear = () => { + pause() seconds.value = 0 sessionSeconds.value = intervalSeconds.value isProgrammer1Turn.value = true @@ -72,6 +76,7 @@ export const useTimer = () => { return { interval, start, + pause, clear, timeState, time, diff --git a/src/views/Home.vue b/src/views/Home.vue index 741c026..ccc5405 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -20,6 +20,7 @@
{{ time }}
+
@@ -38,7 +39,7 @@ v-if="hasMusic" :play="timeState === 'started'" @play="start" - @pause="clear" + @pause="pause" />
@@ -64,6 +65,7 @@ export default defineComponent({ const { interval, start, + pause, clear, timeState, time, @@ -77,6 +79,7 @@ export default defineComponent({ hasMusic, interval, start, + pause, clear, timeState, time, @@ -101,6 +104,10 @@ export default defineComponent({ flex-wrap: wrap; } +button { + margin: 0 1rem; +} + .global-time { font-size: calc(3em + 10vw); }