From 398c2616242bc412e5f448b9c001cb83332949ea Mon Sep 17 00:00:00 2001 From: RemiSaurel Date: Thu, 25 Aug 2022 23:46:57 +0200 Subject: [PATCH] first use of vuex --- src/App.vue | 55 ++++++++++--------------------------- src/components/Infos.vue | 17 ++++++++++++ src/components/Settings.vue | 9 +++--- src/components/Socials.vue | 30 ++++++++++++++++++++ src/components/ToDoList.vue | 1 + src/store/index.js | 14 ++++++++++ 6 files changed, 81 insertions(+), 45 deletions(-) create mode 100644 src/components/Socials.vue diff --git a/src/App.vue b/src/App.vue index 727a82c..8e72fac 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,7 +1,10 @@ @@ -34,6 +25,7 @@ import ToDoList from "@/components/ToDoList"; import Pomodoro from "@/components/Pomodoro"; import YtbPlayer from "@/components/YtbPlayer"; import Settings from "@/components/Settings"; +import Socials from "@/components/Socials"; export default { name: 'App', @@ -41,7 +33,8 @@ export default { ToDoList, Pomodoro, YtbPlayer, - Settings + Settings, + Socials } } @@ -81,6 +74,14 @@ footer > div { margin-right: 16px; } +#nav-bar { + margin-top: 8px; + margin-left: 16px; + margin-right: 8px; + display: flex; + flex-direction: column; +} + #ytb-player { background: #504746; margin-top: 16px; @@ -101,7 +102,6 @@ footer > div { #todo-container { width: 40%; - margin-right: 16px; } #right-side { @@ -112,31 +112,6 @@ footer > div { margin-left: 32px; } -/* TEXT UNDERLINE */ -.underline { - display: inline-block; - position: relative; - color: #79624c; -} - -.underline:after { - content: ''; - position: absolute; - width: 100%; - transform: scaleX(0); - height: 2px; - bottom: -2px; - left: 0; - background-color: #79624c; - transform-origin: bottom right; - transition: transform 0.5s ease-out; -} - -.underline:hover:after { - transform: scaleX(1); - transform-origin: bottom left; -} - @media (max-width: 330px) { #right-side { display: none; diff --git a/src/components/Infos.vue b/src/components/Infos.vue index f6ae073..e992e9b 100644 --- a/src/components/Infos.vue +++ b/src/components/Infos.vue @@ -79,6 +79,7 @@ export default { }) }, getDefinition(word) { + console.log(this.$store.getters.itemsFinished) const url = 'https://api.dictionaryapi.dev/api/v2/entries/en/' + word; return fetch(url) .then(response => response.json()) @@ -101,6 +102,22 @@ export default { this.generateDateOfTheDay(); this.getCurrentTime(); this.getNewWordEveryday() + }, + computed: { + itemsFinished() { + return this.$store.getters.itemsFinished; + }, + colorSelected() { + return this.$store.getters.colorSelected; + } + }, + watch: { + itemsFinished: function(items) { + console.log(items); + }, + colorSelected: function(color) { + document.getElementById("word").style.color = color; + } } } diff --git a/src/components/Settings.vue b/src/components/Settings.vue index 49ee800..d121950 100644 --- a/src/components/Settings.vue +++ b/src/components/Settings.vue @@ -17,8 +17,8 @@ export default { default: "#fdde95", greenBlue: "#9acabf", green: "#ABCEA7", - salmon: "#E6CEBD", - grey: "#babbc8" + grey: "#d4d4e8", + salmon: "#E6CEBD" }, activeColor: "#504746" } @@ -28,6 +28,7 @@ export default { this.removeActiveColorFromPalette() event.target.style.borderColor = this.activeColor; document.body.style.backgroundColor = color; + this.$store.commit("setColorSelected", color); }, removeActiveColorFromPalette() { const palette = document.querySelectorAll(".color-palette-item"); @@ -55,9 +56,7 @@ export default { flex-direction: column; justify-content: space-between; align-items: center; - margin-top: 8px; - margin-right: 8px; - margin-left: 16px; + margin-bottom: 8px; } .color-palette-item { diff --git a/src/components/Socials.vue b/src/components/Socials.vue new file mode 100644 index 0000000..e0d5404 --- /dev/null +++ b/src/components/Socials.vue @@ -0,0 +1,30 @@ + + + + + \ No newline at end of file diff --git a/src/components/ToDoList.vue b/src/components/ToDoList.vue index ed2d2e4..3439345 100644 --- a/src/components/ToDoList.vue +++ b/src/components/ToDoList.vue @@ -44,6 +44,7 @@ export default { this.items = this.items.filter(e => e !== item ) + this.$store.commit("addItemFinished", item); this.clearItem() }, clearItem() { diff --git a/src/store/index.js b/src/store/index.js index 2a7fd70..0f637ff 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -7,10 +7,24 @@ Vue.use(Vuex); export default new Vuex.Store({ state: { + itemsFinished: [], + colorSelected: "" }, getters: { + itemsFinished(state) { + return state.itemsFinished; + }, + colorSelected(state) { + return state.colorSelected; + } }, mutations: { + addItemFinished(state, item) { + state.itemsFinished.push(item); + }, + setColorSelected(state, color) { + state.colorSelected = color; + } }, actions: { }