Last active
December 3, 2024 12:42
-
-
Save JeffreyWay/7ebe043f72ddd64fb54528c74c102bc7 to your computer and use it in GitHub Desktop.
Learn Vue 3: Step By Step, Episode 7, Bring it All Together - https://laracasts.com/series/learn-vue-3-step-by-step/episodes/7
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
import Assignments from "./Assignments.js"; | |
export default { | |
components: { Assignments }, | |
template: ` | |
<assignments></assignments> | |
`, | |
} |
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
export default { | |
template: ` | |
<li> | |
<label> | |
{{ assignment.name }} | |
<input type="checkbox" v-model="assignment.complete"> | |
</label> | |
</li> | |
`, | |
props: { | |
assignment: Object | |
} | |
} |
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
import Assignment from "./Assignment.js"; | |
export default { | |
components: { Assignment }, | |
template: ` | |
<section v-show="assignments.length"> | |
<h2 class="font-bold mb-2">{{ title }}</h2> | |
<ul> | |
<assignment | |
v-for="assignment in assignments" | |
:key="assignment.id" | |
:assignment="assignment" | |
></assignment> | |
</ul> | |
</section> | |
`, | |
props: { | |
assignments: Array, | |
title: String | |
} | |
} |
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
import AssignmentList from "./AssignmentList.js"; | |
export default { | |
components: { AssignmentList }, | |
template: ` | |
<section class="space-y-6"> | |
<assignment-list :assignments="filters.inProgress" title="In Progress"></assignment-list> | |
<assignment-list :assignments="filters.completed" title="Completed"></assignment-list> | |
</section> | |
`, | |
data() { | |
return { | |
assignments: [ | |
{ name: 'Finish project', complete: false, id: 1 }, | |
{ name: 'Read Chapter 4', complete: false, id: 2 }, | |
{ name: 'Turn in Homework', complete: false, id: 3 }, | |
] | |
} | |
}, | |
computed: { | |
filters() { | |
return { | |
inProgress: this.assignments.filter(assignment => ! assignment.complete), | |
completed: this.assignments.filter(assignment => assignment.complete) | |
}; | |
} | |
} | |
} |
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
<!doctype html> | |
<html lang="en" class="h-full"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Episode 6: Bring it All Together</title> | |
<script src="https://unpkg.com/vue@3"></script> | |
<script src="https://cdn.tailwindcss.com"></script> | |
</head> | |
<body class="h-full grid place-items-center"> | |
<div id="app"></div> | |
<script type="module"> | |
import App from './js/components/App.js'; | |
Vue.createApp(App).mount('#app'); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment