-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create card component with flip effect
- Loading branch information
Showing
7 changed files
with
156 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,41 @@ | ||
<template> | ||
<main-screen v-if="statusMatch === 'default'"/> | ||
<interact-screen v-if="statusMatch === 'match'"/> | ||
<main-screen v-if="statusMatch === 'default'" @onStart="onHandleBeforeStart($event)" /> | ||
<interact-screen v-if="statusMatch === 'match'" /> | ||
</template> | ||
|
||
<script> | ||
import MainScreen from './components/MainScreen.vue'; | ||
import InteractScreen from './components/InteractScreen.vue'; | ||
import MainScreen from "./components/MainScreen.vue"; | ||
import InteractScreen from "./components/InteractScreen.vue"; | ||
export default { | ||
name: 'App', | ||
name: "App", | ||
components: { | ||
MainScreen, | ||
InteractScreen, | ||
}, | ||
data() { | ||
return { | ||
statusMatch: "default" | ||
settings: { | ||
totalOfBlocks: 0, | ||
cardsContext: [], | ||
startedAt: null, | ||
}, | ||
timer: 0, | ||
statusMatch: "default", | ||
}; | ||
}, | ||
components: { | ||
MainScreen, | ||
InteractScreen | ||
methods: { | ||
onHandleBeforeStart(configs) { | ||
console.log("Configs:", configs); // Kiểm tra giá trị của configs | ||
this.settings.totalOfBlocks = configs.size; // Đảm bảo rằng bạn dùng 'size' thay vì 'totalOfBlocks' | ||
console.log("Total of blocks:", this.settings.totalOfBlocks); // Kiểm tra giá trị của totalOfBlocks | ||
const firstCards = Array.from( | ||
{ length: this.settings.totalOfBlocks / 2 }, | ||
(_, i) => i + 1 | ||
); | ||
console.log("First cards:", firstCards); // Kiểm tra mảng firstCards | ||
this.statusMatch = "match"; | ||
}, | ||
}, | ||
} | ||
</script> | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,18 @@ | ||
/* Variables CSS */ | ||
:root { | ||
--dark: #212121; | ||
--light: #f3f3f3; | ||
--front: "VT323", serif; | ||
} | ||
* { | ||
padding: 0; | ||
margin: 0; | ||
box-sizing: border-box; | ||
|
||
} | ||
|
||
body { | ||
font-family: var(--front); | ||
font-size: 16px; | ||
width: 100%; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<template> | ||
<div class="card"> | ||
<div | ||
class="card__inner" | ||
:class="{ 'is-flipped': isFlipped }" | ||
@click="ontoggleFlipCard" | ||
> | ||
<div class="card_face card__face--front"> | ||
<div class="card__content">Front</div> | ||
</div> | ||
<div class="card_face card__face--back"> | ||
<div class="card__content">Back</div> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
<script> | ||
export default { | ||
data() { | ||
return { | ||
isFlipped: false, | ||
}; | ||
}, | ||
methods: { | ||
ontoggleFlipCard() { | ||
this.isFlipped = !this.isFlipped; | ||
}, | ||
}, | ||
}; | ||
</script> | ||
<style lang="css" scope> | ||
.card { | ||
display: inline-block; | ||
margin-right: 1rem; | ||
margin-bottom: 1rem; | ||
width: 90px; | ||
height: 120px; | ||
} | ||
.card__inner { | ||
width: 100%; | ||
height: 100%; | ||
transition: transform 1s; | ||
transform-style: preserve-3d; | ||
cursor: pointer; | ||
position: relative; | ||
} | ||
.card__inner.is-flipped { | ||
transform: rotateY(-180deg); | ||
} | ||
.card_face { | ||
position: absolute; | ||
width: 100%; | ||
height: 100%; | ||
backface-visibility: hidden; | ||
overflow: hidden; | ||
border-radius: 1rem; | ||
padding: 1rem; | ||
box-shadow: 0 3px 10px 3px rgba(0, 0, 0, 0.2); | ||
} | ||
.card__face--back { | ||
background-color: var(--light); | ||
transform: rotateY(-180deg); | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,15 @@ | ||
<template> | ||
<h1> | ||
Welcome to Pokemon GO! | ||
</h1> | ||
</template> | ||
<div class="screen"> | ||
<base-card></base-card> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import BaseCard from "./BaseCard"; | ||
export default { | ||
components: { | ||
BaseCard, | ||
}, | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,34 @@ | ||
<template> | ||
<div class="screen"> | ||
<h1> | ||
Pokemon - GO | ||
</h1> | ||
<h3>Select mode to start game</h3> | ||
<div class="actions"> | ||
<button> | ||
<span>4x4</span> | ||
<span>Easy</span> | ||
</button> | ||
<button> | ||
<span>6x6</span> | ||
<span>Normal</span> | ||
</button> | ||
<button> | ||
<span>8x8</span> | ||
<span>Hard</span> | ||
</button> | ||
<button> | ||
<span>10x10</span> | ||
<span>Supper Hard</span> | ||
</button> | ||
</div> | ||
<div class="screen"> | ||
<h1>Pokemon - GO</h1> | ||
<h3>Select mode to start game</h3> | ||
<div class="actions"> | ||
<button @click="onStart(16)"> | ||
<span>4x4</span> | ||
<span>Easy</span> | ||
</button> | ||
<button @click="onStart(36)"> | ||
<span>6x6</span> | ||
<span>Normal</span> | ||
</button> | ||
<button @click="onStart(64)"> | ||
<span>8x8</span> | ||
<span>Hard</span> | ||
</button> | ||
<button @click="onStart(100)"> | ||
<span>10x10</span> | ||
<span>Supper Hard</span> | ||
</button> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
} | ||
methods: { | ||
onStart(size) { | ||
this.$emit("onStart", { size }); | ||
}, | ||
}, | ||
}; | ||
</script> | ||
|