diff --git a/src/components/celestials/CelestialCard.vue b/src/components/celestials/CelestialCard.vue index 4d61454..84e7d12 100644 --- a/src/components/celestials/CelestialCard.vue +++ b/src/components/celestials/CelestialCard.vue @@ -42,6 +42,15 @@

+
+ + info + +
+

@@ -75,12 +84,13 @@

- - Détails - + favorite +
@@ -89,6 +99,8 @@ @@ -121,8 +147,18 @@ export default defineComponent({ .card-icon { display: block; position: absolute; - top: 0; + top: 20px; + bottom: 20px; + left: 0; right: 0; + user-select: none; + pointer-events: none; + opacity: 4%; + img { + height: 100%; + width: 100%; + z-index: -1; + } } > * { @@ -135,6 +171,30 @@ export default defineComponent({ flex: 1 1 auto; min-height: 30px; } + + .card-info { + position: absolute; + top: 0; + right: 0; + } + + .card-actions { + color: #afafaf; + .favourite { + .icon { + color: #afafaf; + } + &.active { + .icon { + position: relative; + display: inline-block; + will-change: font-size; + animation: toggleFavHeart 0.6s cubic-bezier(0.17, 0.89, 0.32, 1.49); + animation-fill-mode: forwards; + } + } + } + } } } diff --git a/src/store/index.ts b/src/store/index.ts index 765e2f0..82f088d 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -3,6 +3,7 @@ import { createStore } from "vuex"; export default createStore({ state: () => ({ user: { + avatarUrl: "", favourites: Array<{ id: string }>() } }), @@ -12,7 +13,7 @@ export default createStore({ return state.user.favourites.length; }, // Returns true if celestial is fav - isAlreadyFav: state => (celestialId: string) => { + isFav: state => (celestialId: string) => { return state.user.favourites.find(fav => fav.id === celestialId); } }, @@ -21,13 +22,15 @@ export default createStore({ state.user.favourites.push({ id: celestialId }); }, removeFav: (state, celestialId: string) => { - state.user.favourites = state.user.favourites.filter(fav => fav.id != celestialId); + state.user.favourites = state.user.favourites.filter( + fav => fav.id != celestialId + ); } }, actions: { toggleFav: ({ commit, getters }, celestialId: string) => { // If the celestial is not faved - if (!getters.isAlreadyFav(celestialId)) { + if (!getters.isFav(celestialId)) { // ... favs it commit("addFav", celestialId); } else { diff --git a/src/views/celestials/Celestial.vue b/src/views/celestials/Celestial.vue index 50cb7cc..02c8dda 100644 --- a/src/views/celestials/Celestial.vue +++ b/src/views/celestials/Celestial.vue @@ -8,7 +8,6 @@
Une erreur est survenue : {{ error }}
{{ celestial }}
-
@@ -19,8 +18,6 @@