65. Setting up the Quiz Application
npm create vue@latest
이 강의에서는 퀴즈 애플리케이션을 만드는 프로젝트를 시작합니다.
이 프로젝트에서는 앞서 배운 Vue의 개념들을 활용하여 애플리케이션을 여러 컴포넌트로 나누고, 애니메이션을 추가하여 흥미롭게 만들 계획입니다.
프로젝트를 준비하기 위해, 시작 파일들이 포함된 zip 파일을 제공하며, 이 파일에는 HTML, CSS, 데이터 파일 등이 포함되어 있습니다.
이 프로젝트를 위해 새로운 Vue 프로젝트를 생성하고, 기본 코드를 정리한 후, 다운로드한 HTML과 CSS를 프로젝트에 추가하는 과정을 거칩니다.
이 과정을 통해 퀴즈 애플리케이션의 기본 구조와 스타일을 설정하고, 이후에 Vue를 통해 이를 확장해 나갈 예정입니다.
src/main.ts
import './assets/main.css'
import { createApp } from 'vue'
import App from './App.vue'
createApp(App).mount('#app')
src/App.vue
<script setup lang="ts">
</script>
<template>
<div class="ctr">
<div class="questions-ctr">
<div class="progress">
<div class="bar"></div>
<div class="status">1 out of 3 questions answered</div>
</div>
<div class="single-question">
<div class="question">Sample Question 1</div>
<div class="answers">
<div class="answer">Sample Answer 1</div>
<div class="answer">Sample Answer 2</div>
<div class="answer">Sample Answer 3</div>
<div class="answer">Sample Answer 4</div>
</div>
</div>
</div>
<div class="result">
<div class="title">You got sample result 1!</div>
<div class="desc">
Enter a short description here about the result.
</div>
</div>
<button type="button" class="reset-btn">Reset</button>
</div>
</template>
src/assets/main.css
* {
box-sizing: border-box;
}
body {
font-size: 20px;
font-family: sans-serif;
padding-top: 20px;
background: #e6ecf1;
}
.ctr {
margin: 0 auto;
max-width: 600px;
width: 100%;
box-sizing: border-box;
position: relative;
}
.questions-ctr {
position: relative;
width: 100%;
}
.question {
width: 100%;
padding: 20px;
font-size: 32px;
font-weight: bold;
text-align: center;
background-color: #00ca8c;
color: #fff;
box-sizing: border-box;
}
.single-question {
position: relative;
width: 100%;
}
.answer {
border: 1px solid #8e959f;
padding: 20px;
font-size: 18px;
width: 100%;
background-color: #fff;
transition: 0.2s linear all;
}
.answer span {
display: inline-block;
margin-left: 5px;
font-size: 0.75em;
font-style: italic;
}
.progress {
height: 50px;
margin-top: 10px;
background-color: #ddd;
position: relative;
}
.bar {
height: 50px;
background-color: #ff6372;
transition: all 0.3s linear;
}
.status {
position: absolute;
top: 15px;
left: 0;
text-align: center;
color: #fff;
width: 100%;
}
.answer:not(.is-answered) {
cursor: pointer;
}
.answer:not(.is-answered):hover {
background-color: #8ce200;
border-color: #8ce200;
color: #fff;
}
.title {
width: 100%;
padding: 20px;
font-size: 32px;
font-weight: bold;
text-align: center;
background-color: #12cbc4;
color: #fff;
box-sizing: border-box;
}
.desc {
border: 1px solid #8e959f;
padding: 20px;
font-size: 18px;
width: 100%;
background-color: #fff;
transition: 0.4s linear all;
text-align: center;
}
.fade-enter-from {
opacity: 0;
}
.fade-enter-active {
transition: all 0.3s linear;
}
.fade-leave-active {
transition: all 0.3s linear;
opacity: 0;
position: absolute;
}
.fade-leave-to {
opacity: 0;
}
.reset-btn {
background-color: #ff6372;
border: 0;
font-size: 22px;
color: #fff;
padding: 10px 25px;
margin: 10px auto;
display: block;
}
.result{
width: 100%;
}
.reset-btn:active, .reset-btn:focus, .reset-btn:hover{
border: 0;
outline: 0;
}