From e96ac0b454b30237dd1499892ef1a6b4a33a31cb Mon Sep 17 00:00:00 2001 From: Diego Lopes Date: Sat, 30 May 2020 11:28:34 -0300 Subject: [PATCH 01/10] Add ConfigEditor structure and styles --- src/App.vue | 5 +- src/components/ConfigEditor.vue | 129 ++++++++++++++++++++++++++++++++ 2 files changed, 133 insertions(+), 1 deletion(-) create mode 100644 src/components/ConfigEditor.vue diff --git a/src/App.vue b/src/App.vue index ef51909..05290a7 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,5 +1,6 @@ diff --git a/src/components/StreamContent.vue b/src/components/StreamContent.vue new file mode 100644 index 0000000..54b6d06 --- /dev/null +++ b/src/components/StreamContent.vue @@ -0,0 +1,32 @@ + + + + \ No newline at end of file diff --git a/src/main.js b/src/main.js index 63eb05f..b1e8bff 100644 --- a/src/main.js +++ b/src/main.js @@ -1,8 +1,10 @@ -import Vue from 'vue' -import App from './App.vue' +import Vue from "vue"; +import App from "./App.vue"; +import store from "./store"; -Vue.config.productionTip = false +Vue.config.productionTip = false; new Vue({ render: h => h(App), -}).$mount('#app') + store +}).$mount("#app"); diff --git a/src/store/index.js b/src/store/index.js new file mode 100644 index 0000000..4b960a1 --- /dev/null +++ b/src/store/index.js @@ -0,0 +1,13 @@ +import Vue from "vue"; +import Vuex from "vuex"; +import content from "./modules/content"; +import countdownTimer from "./modules/countdownTimer"; + +Vue.use(Vuex); + +export default new Vuex.Store({ + modules: { + content, + countdownTimer + } +}); diff --git a/src/store/modules/content.js b/src/store/modules/content.js new file mode 100644 index 0000000..a30efb0 --- /dev/null +++ b/src/store/modules/content.js @@ -0,0 +1,24 @@ +export default { + namespaced: true, + state: { + title: "O live coding está começando", + streamTitle: "🐵 Hoje: Criando um Timer com Vue.js + Novos MEMEs no Canal", + streamSubtitle: "#Hashtag no Chat vira GIF na Live!", + streamParagraph: + "Enquanto você espera, apresente-se no chat, pergunte o que quiser e tente responder as perguntas dos amigos!" + }, + mutations: { + UPDATE_TITLE(state, title) { + state.title = title; + }, + UPDATE_STREAM_TITLE(state, title) { + state.streamTitle = title; + }, + UPDATE_STREAM_SUBTITLE(state, subtitle) { + state.streamSubtitle = subtitle; + }, + UPDATE_STREAM_PARAGRAPH(state, paragraph) { + state.streamParagraph = paragraph; + } + } +}; diff --git a/src/store/modules/countdownTimer.js b/src/store/modules/countdownTimer.js new file mode 100644 index 0000000..38ed955 --- /dev/null +++ b/src/store/modules/countdownTimer.js @@ -0,0 +1,26 @@ +export default { + namespaced: true, + state: { + initialCountValue: 10, + minutes: 0, + seconds: 0 + }, + mutations: { + UPDATE_INITIAL_COUNT_VALUE(state, value) { + state.initialCountValue = value; + }, + UPDATE_MINUTES(state, minutes) { + state.minutes = minutes; + }, + UPDATE_SECONDS(state, seconds) { + state.seconds = seconds; + } + }, + actions: { + changeInitialCountValue(ctx, val) { + ctx.commit("UPDATE_INITIAL_COUNT_VALUE", val); + ctx.commit("UPDATE_MINUTES", val); + ctx.commit("UPDATE_SECONDS", 0); + } + } +}; From 714c9c2d782c6c84b494c2cb4f3d7d84ed90f544 Mon Sep 17 00:00:00 2001 From: Diego Lopes Date: Sat, 30 May 2020 17:59:57 -0300 Subject: [PATCH 06/10] Add count reset button --- src/components/ConfigPanel.vue | 19 ++++++++++++++----- src/store/modules/countdownTimer.js | 4 ++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/components/ConfigPanel.vue b/src/components/ConfigPanel.vue index dc0b420..416cf2c 100644 --- a/src/components/ConfigPanel.vue +++ b/src/components/ConfigPanel.vue @@ -42,7 +42,7 @@ min="1" class="input" > - + @@ -106,6 +106,11 @@ export default { this.$store.dispatch('countdownTimer/changeInitialCountValue', val) } } + }, + methods: { + resetTimer() { + this.$store.dispatch('countdownTimer/resetCount') + } } } @@ -208,9 +213,11 @@ export default { border: 0; border-radius: 4px; height: 40px; + border-bottom: 3px solid #AE025E; + transition: all 0.3s ease; - &:hover { - background-color: #AE025E; + &:active { + transform: translateY(1px) scale(0.95); } } } @@ -240,9 +247,11 @@ export default { background-image: url(../assets/img/reset.svg); background-repeat: no-repeat; background-position: center center; + border-bottom: 3px solid #AE025E; + transition: all 0.3s ease; - &:hover { - background-color: #AE025E; + &:active { + transform: translateY(1px) scale(0.95); } } diff --git a/src/store/modules/countdownTimer.js b/src/store/modules/countdownTimer.js index 38ed955..b8dbbe7 100644 --- a/src/store/modules/countdownTimer.js +++ b/src/store/modules/countdownTimer.js @@ -21,6 +21,10 @@ export default { ctx.commit("UPDATE_INITIAL_COUNT_VALUE", val); ctx.commit("UPDATE_MINUTES", val); ctx.commit("UPDATE_SECONDS", 0); + }, + resetCount(ctx) { + ctx.commit("UPDATE_MINUTES", ctx.state.initialCountValue); + ctx.commit("UPDATE_SECONDS", 0); } } }; From 7bc13099113dd8100d8de6a6814a57888920fd17 Mon Sep 17 00:00:00 2001 From: Diego Lopes Date: Mon, 1 Jun 2020 08:22:50 -0300 Subject: [PATCH 07/10] Frozen timer when config panel is open --- src/App.vue | 2 +- src/components/CountdownTimer.vue | 9 ++++++++- src/components/StreamContent.vue | 8 +++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/App.vue b/src/App.vue index fa9280c..189c88c 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,7 +1,7 @@ diff --git a/src/components/CountdownTimer.vue b/src/components/CountdownTimer.vue index 6efa09a..9287ca4 100644 --- a/src/components/CountdownTimer.vue +++ b/src/components/CountdownTimer.vue @@ -1,5 +1,5 @@ @@ -8,6 +8,9 @@ import { mapState } from 'vuex' export default { + props: { + isFrozen: { type: Boolean, default: false } + }, data() { return { interval: null @@ -61,4 +64,8 @@ export default { div { font-size: 70px; } + +.frozen { + color: #12A5B7; +} diff --git a/src/components/StreamContent.vue b/src/components/StreamContent.vue index 54b6d06..071a64f 100644 --- a/src/components/StreamContent.vue +++ b/src/components/StreamContent.vue @@ -3,7 +3,10 @@

- +

@@ -14,6 +17,9 @@ import { mapState } from 'vuex' import CountdownTimer from "@/components/CountdownTimer.vue"; export default { + props: { + isFrozen: { type: Boolean, default: false } + }, components: { CountdownTimer }, From 84652c0bd6f4b235485a605d58ed4cf33f23573d Mon Sep 17 00:00:00 2001 From: Diego Lopes Date: Mon, 1 Jun 2020 09:02:58 -0300 Subject: [PATCH 08/10] Get and set edited texts on localstorage --- src/App.vue | 17 ++++++++------ src/components/ConfigPanel.vue | 25 ++++++++++++-------- src/components/CountdownTimer.vue | 6 ++--- src/components/StreamContent.vue | 16 ++++++------- src/store/index.js | 4 +++- src/store/modules/configPanel.js | 11 +++++++++ src/store/modules/content.js | 38 +++++++++++++++++++++++-------- 7 files changed, 79 insertions(+), 38 deletions(-) create mode 100644 src/store/modules/configPanel.js diff --git a/src/App.vue b/src/App.vue index 189c88c..ae90418 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,7 +1,7 @@ @@ -11,9 +11,6 @@ import StreamContent from "@/components/StreamContent.vue" export default { name: "App", - data: () => ({ - isConfigEditorVisible: false - }), components: { ConfigPanel, StreamContent @@ -23,10 +20,16 @@ export default { this.toggleConfigEditor(event) }) }, + computed: { + isConfigPainelOpen() { + return this.$store.state.configPanel.isConfigPainelOpen + } + }, methods: { toggleConfigEditor({key, ctrlKey, altKey}) { - if(/e/i.test(key) && ctrlKey && altKey) this.isConfigEditorVisible = !this.isConfigEditorVisible - if(event.key === 'Escape') this.isConfigEditorVisible = false + if(/e/i.test(key) && ctrlKey && altKey) + this.$store.commit('configPanel/CHANGE_IS_CONFIG_PANEL_OPEN', !this.isConfigPainelOpen) + if(event.key === 'Escape') this.$store.commit('configPanel/CHANGE_IS_CONFIG_PANEL_OPEN', false) } } }; diff --git a/src/components/ConfigPanel.vue b/src/components/ConfigPanel.vue index 416cf2c..5063175 100644 --- a/src/components/ConfigPanel.vue +++ b/src/components/ConfigPanel.vue @@ -1,6 +1,6 @@