add a new project
This commit is contained in:
parent
a6760b1ba4
commit
4350cd5bb5
|
@ -0,0 +1,3 @@
|
|||
> 1%
|
||||
last 2 versions
|
||||
not dead
|
|
@ -0,0 +1,17 @@
|
|||
module.exports = {
|
||||
root: true,
|
||||
env: {
|
||||
node: true
|
||||
},
|
||||
'extends': [
|
||||
'plugin:vue/vue3-essential',
|
||||
'eslint:recommended'
|
||||
],
|
||||
parserOptions: {
|
||||
parser: 'babel-eslint'
|
||||
},
|
||||
rules: {
|
||||
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
||||
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off'
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
.DS_Store
|
||||
node_modules
|
||||
/dist
|
||||
|
||||
# local env files
|
||||
.env.local
|
||||
.env.*.local
|
||||
|
||||
# Log files
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
|
||||
# Editor directories and files
|
||||
.idea
|
||||
.vscode
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"singleQuote": true
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
module.exports = {
|
||||
presets: [
|
||||
'@vue/cli-plugin-babel/preset'
|
||||
]
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"name": "vue-first-app",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"serve": "vue-cli-service serve",
|
||||
"build": "vue-cli-service build",
|
||||
"lint": "vue-cli-service lint"
|
||||
},
|
||||
"dependencies": {
|
||||
"core-js": "^3.6.5",
|
||||
"vue": "^3.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vue/cli-plugin-babel": "~4.5.0",
|
||||
"@vue/cli-plugin-eslint": "~4.5.0",
|
||||
"@vue/cli-service": "~4.5.0",
|
||||
"@vue/compiler-sfc": "^3.0.0-0",
|
||||
"babel-eslint": "^10.1.0",
|
||||
"eslint": "^6.7.2",
|
||||
"eslint-plugin-vue": "^7.0.0-0"
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
|
@ -0,0 +1,17 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
|
||||
<title><%= htmlWebpackPlugin.options.title %></title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>
|
||||
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
|
||||
</noscript>
|
||||
<div id="app"></div>
|
||||
<!-- built files will be auto injected -->
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,46 @@
|
|||
<template>
|
||||
<learning-survey @survey-submit="storeSurvey"></learning-survey>
|
||||
<user-experiences :results="savedSurveyResults"></user-experiences>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import LearningSurvey from './components/survey/LearningSurvey.vue';
|
||||
import UserExperiences from './components/survey/UserExperiences.vue';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
LearningSurvey,
|
||||
UserExperiences,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
savedSurveyResults: [],
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
storeSurvey(surveyData) {
|
||||
const surveyResult = {
|
||||
name: surveyData.userName,
|
||||
rating: surveyData.rating,
|
||||
id: new Date().toISOString(),
|
||||
};
|
||||
this.savedSurveyResults.push(surveyResult);
|
||||
console.log(surveyResult);
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
html {
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
</style>
|
|
@ -0,0 +1,22 @@
|
|||
<template>
|
||||
<button>
|
||||
<slot></slot>
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
button {
|
||||
font: inherit;
|
||||
border: 1px solid #360032;
|
||||
background-color: #360032;
|
||||
color: white;
|
||||
padding: 0.5rem 2rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
button:hover,
|
||||
button:active {
|
||||
background-color: #5c0556;
|
||||
border-color: #5c0556;
|
||||
}
|
||||
</style>
|
|
@ -0,0 +1,15 @@
|
|||
<template>
|
||||
<div>
|
||||
<slot></slot>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
div {
|
||||
margin: 2rem auto;
|
||||
max-width: 40rem;
|
||||
padding: 1rem;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.26);
|
||||
}
|
||||
</style>
|
|
@ -0,0 +1,80 @@
|
|||
<template>
|
||||
<section>
|
||||
<base-card>
|
||||
<h2>How was you learning experience?</h2>
|
||||
<form @submit.prevent="submitSurvey">
|
||||
<div class="form-control">
|
||||
<label for="name">Your Name</label>
|
||||
<input type="text" id="name" name="name" v-model.trim="enteredName" />
|
||||
</div>
|
||||
<h3>My learning experience was ...</h3>
|
||||
<div class="form-control">
|
||||
<input type="radio" id="rating-poor" value="poor" name="rating" v-model="chosenRating" />
|
||||
<label for="rating-poor">Poor</label>
|
||||
</div>
|
||||
<div class="form-control">
|
||||
<input
|
||||
type="radio"
|
||||
id="rating-average"
|
||||
value="average"
|
||||
name="rating"
|
||||
v-model="chosenRating"
|
||||
/>
|
||||
<label for="rating-average">Average</label>
|
||||
</div>
|
||||
<div class="form-control">
|
||||
<input type="radio" id="rating-great" value="great" name="rating" v-model="chosenRating" />
|
||||
<label for="rating-great">Great</label>
|
||||
</div>
|
||||
<p
|
||||
v-if="invalidInput"
|
||||
>One or more input fields are invalid. Please check your provided data.</p>
|
||||
<div>
|
||||
<base-button>Submit</base-button>
|
||||
</div>
|
||||
</form>
|
||||
</base-card>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
enteredName: '',
|
||||
chosenRating: null,
|
||||
invalidInput: false,
|
||||
};
|
||||
},
|
||||
emits: ['survey-submit'],
|
||||
methods: {
|
||||
submitSurvey() {
|
||||
if (this.enteredName === '' || !this.chosenRating) {
|
||||
this.invalidInput = true;
|
||||
return;
|
||||
}
|
||||
this.invalidInput = false;
|
||||
|
||||
this.$emit('survey-submit', {
|
||||
userName: this.enteredName,
|
||||
rating: this.chosenRating,
|
||||
});
|
||||
|
||||
this.enteredName = '';
|
||||
this.chosenRating = null;
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.form-control {
|
||||
margin: 0.5rem 0;
|
||||
}
|
||||
|
||||
input[type='text'] {
|
||||
display: block;
|
||||
width: 20rem;
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
</style>
|
|
@ -0,0 +1,49 @@
|
|||
<template>
|
||||
<li>
|
||||
<p>
|
||||
<span class="highlight">{{ name }}</span> rated the learning experience
|
||||
<span :class="ratingClass">{{ rating }}</span>.
|
||||
</p>
|
||||
</li>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: ['name', 'rating'],
|
||||
computed: {
|
||||
ratingClass() {
|
||||
return 'highlight rating--' + this.rating;
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
li {
|
||||
margin: 1rem 0;
|
||||
border: 1px solid #ccc;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
h3,
|
||||
p {
|
||||
font-size: 1rem;
|
||||
margin: 0.5rem 0;
|
||||
}
|
||||
|
||||
.highlight {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.rating--poor {
|
||||
color: #b80056;
|
||||
}
|
||||
|
||||
.rating--average {
|
||||
color: #330075;
|
||||
}
|
||||
|
||||
.rating--great {
|
||||
color: #008327;
|
||||
}
|
||||
</style>
|
|
@ -0,0 +1,37 @@
|
|||
<template>
|
||||
<section>
|
||||
<base-card>
|
||||
<h2>Submitted Experiences</h2>
|
||||
<div>
|
||||
<base-button>Load Submitted Experiences</base-button>
|
||||
</div>
|
||||
<ul>
|
||||
<survey-result
|
||||
v-for="result in results"
|
||||
:key="result.id"
|
||||
:name="result.name"
|
||||
:rating="result.rating"
|
||||
></survey-result>
|
||||
</ul>
|
||||
</base-card>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import SurveyResult from './SurveyResult.vue';
|
||||
|
||||
export default {
|
||||
props: ['results'],
|
||||
components: {
|
||||
SurveyResult,
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
ul {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
</style>
|
|
@ -0,0 +1,20 @@
|
|||
import { createApp } from 'vue';
|
||||
|
||||
import BaseCard from './components/UI/BaseCard.vue';
|
||||
import BaseButton from './components/UI/BaseButton.vue';
|
||||
import App from './App.vue';
|
||||
|
||||
const app = createApp(App);
|
||||
|
||||
app.component('base-card', BaseCard);
|
||||
app.component('base-button', BaseButton);
|
||||
|
||||
app.mount('#app');
|
||||
|
||||
if (module.hot) {
|
||||
module.hot.accept(); // already had this init code
|
||||
|
||||
module.hot.addStatusHandler(status => {
|
||||
if (status === 'prepare') console.clear();
|
||||
});
|
||||
}
|
Reference in New Issue