From acd360740d1371599cefddc296946d36b9fb1ef4 Mon Sep 17 00:00:00 2001 From: Bastien Jacquelin Date: Wed, 15 Mar 2023 14:27:31 +0100 Subject: [PATCH] add deck to view, can click on cards --- views/card-module.js | 23 ++++++++++++++++++----- views/deck-module.js | 19 +++++++++++++------ 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/views/card-module.js b/views/card-module.js index 4e3b52b..af5860a 100644 --- a/views/card-module.js +++ b/views/card-module.js @@ -1,16 +1,29 @@ export default{ - emits:[], - props: ['card'], + emits:['unSelected','selected'], + props: ['card','id'], data: function(){ return{ + idUsed:"id"+this.id, + isClicked:false, } }, methods:{ - clicked:function () { - + clicked() { + if(!this.isClicked){ + this.isClicked=true + document.querySelector(`#${this.idUsed}`).setAttribute("style","border: 2px solid red; margin: 20px; color: red; fontSize: 20px; cursor: pointer"); + this.$emit('selected',this.id); + } + else{ + this.isClicked=false + document.querySelector(`#${this.idUsed}`).setAttribute("style","border: 2px solid black; margin: 20px; color: red; fontSize: 20px; cursor: pointer"); + this.$emit('unSelected',this.id); + } } }, template:` -
{{card}}
+
+ {{card.attributes}} +
` } \ No newline at end of file diff --git a/views/deck-module.js b/views/deck-module.js index 4804bcd..6ad78cd 100644 --- a/views/deck-module.js +++ b/views/deck-module.js @@ -2,19 +2,26 @@ export default{ emits:[], data: function(){ return{ - card:new Card({"filling":"empty"}) + card:new Card({"filling":"empty"}), + deck : new Deck([0,1,2,3],3), + id:0, + selectedCards:[] } }, methods:{ - clicked:function () { - - } + selected(id){ + console.log("selected",id); + this.selectedCards[id]=this.deck.outputCards[id-1] + }, + unSelected(id){ + console.log("unSelected",id); + }, }, template:`
-
+
{{ n }} - +
`