Vue 3 Animations Tutorial #2 - Starter Project Walkthrough

Net Ninja · Beginner ·🌐 Frontend Engineering ·5y ago

Key Takeaways

Walks through the starter project for Vue 3 Animations

Full Transcript

all right then gang so in this video i'm gonna walk you through the code that makes up this project right here and demo how it works in the browser and that way when i'm switching between components and adding animations in the future you're gonna understand what parts of the app i'm working on now if you want to skip this and move straight on to animating then feel free you can go to the next lesson but for the rest of us first of all let's run this in the browser so the home page is just a simple to-do list we have two already there and we can add new ones if i type in here and press enter we can delete them and if i delete all of them we get a message right here saying woohoo nothing left to do and if i try to add a blank to do we get this error message at the top so first of all let's have a look at the code for this home page in the text editor so let's dive into the source folder then interviews which is where all of our page components go so we have a different component for each page on the website so the homepage right here this is what we see on the homepage here and it's simple at first glance we have this toast component which is this notification at the top when we tried to add in a bad to-do and then also the to-do's themselves which is this input field and the list so let's dive into this thing first of all and take a look at that and by the way this thing this is a custom events and we'll see more about that later on this is what is fired when we try to add that bad to do but anyway into the to do's component which is inside this folder then to do's so we have a div that surrounds the whole thing with a class of to-do's then an input at the top which is this thing and what we're doing is giving this a v model and setting it equal to a ref call new to do and that is inside the setup function right here and that's so we can track what a user is typing into it so whatever we type into the input is being stored in the value of this ref then under that we have this key press event and this modifier enter and that means that whenever we press enter inside the input field it's going to fire this function add to do now that again is set up inside this setup function add to do and what we do is see does new to do have a value have they typed something into the input field first of all if they have then what we do is create a new id by using math.random then we take the to-do's ref which is storing the to-do's and each object is a to-do with text and id and we add that new to-do to the array and then we assign that new array to to-do's.value so every time they add a new item it's been added to this ref right here okay then after that we reset new to do back to be an empty string and that's so that when we add a new to do this goes clear again all right cool now if we don't have a value if a user presses enter and there's nothing in new to do we get this error right here and that's because what we're doing here is saying look if we don't have a value emit this custom event and the reason we can use emit is that we've destructed it from the second argument the context object inside setup and we emit this custom event bad value now if we take a look at the home page again we can see that we listen for that custom event and when it occurs we fire this function trigger toast and that is down here and what we do inside here is set the value of show toast which is this ref to be true now when this value is true the toast will show because we have this v if attached to it and it's only going to show this if this is true so when we try to add in a blank to do it's going to fire this event it's going to fire this function it's going to update this to true and show that toast at the top that error and we also set a timeout so that we turn this back to false after three seconds and that means after three seconds it's gonna disappear again so we see the error at the top for three seconds only okay so that's how this works and we'll see this component later on anyway back in here up here we check do we have to do's dot length because we only want to output the to do's if we have a length in this array if the length is zero it's not going to output them and we output this instead where we say v else but if we do have length then we have a ul and then we output an li tag for each to do so we're cycling through the to do's which is this right here and for each one we output an li tag where the key is the to-do id right here and we also attach a click event to each one which is going to fire a function called delete to do and it passes in the id of the to-do that we want to delete so that function is down here delete to do we're taking the id and all we're doing is updating that to do's value whereby we're filtering out the to do with the id so when we click it it takes out the array okay now inside the li tag we just output the text of each to do so that's pretty much it inside this components let's now have a look inside this toast component very simple we just have a toast wrapper and then a toast itself and then a message and we style those down here i'm not going to get into too much detail about how these styles work basically we just give it some simple ones position fixed background color etc etc and it shows up like this at the top okay cool so that's the home page but we also have two other pages the about page right here which is really simple and also this contact page so the about page is this component dead simple just an h1 and some paragraph tags and very simple styles that's all there is to it the contact page a little bit more complex because we have icons we have each of these things right here now first of all i'm loading in material icons to the index page right here using google fonts so we have that library and when we have that library in order to output an icon all we have to do is use a span with a class of material icons and then the name of the icon in that span and when google fonts sees that it's going to replace it with an icon okay so each icon has its own name and we have the icon stored inside this ref in the name property so this is the name of the first icon this is the name of the second this is the name of the third and the fourth etc so when google font sees those it replaces it with these icons right here we also have a text property for each one which is the text we see underneath the icons so all we're doing inside the template is cycling through these icons and we're outputting an li tag for each one whereby the key is the icon name because it is unique for each case and then in a df we output the icon text all right then we style these down here we say the ul displays grid and the columns are one fraction to the left and one to the right which is why we see two next to each other and then a grid gap of 20 pixels max width of 400 pixels margin auto left and right which is why it sits in the center of the page and then each li tag we say list style type non background white yada yada very simple styles now finally i just want to go to the app.view because we have this nav that sits at the top of every page this router view this is where our page components are output but this div with an id of nav has three links two forward slash forward slash about and then forward slash contact so that's these three things at the top and i registered those routes inside the index router file right here so that is about it it's a very simple website but enough of one to show you how to add some nice view transitions and animations so let's get started in the next lesson by learning about the view transition component

Original Description

In this tutorial I'll walk you through the starter project I already created for tis playlist. Get it from here - https://github.com/iamshaunjp/vue-animations/tree/starter 🐱‍💻 🐱‍💻 Course Files: + https://github.com/iamshaunjp/vue-animations 🐱‍👤🐱‍👤 JOIN THE GANG - https://www.youtube.com/channel/UCW5YeuERMmlnqo4oq8vwUpg/join 🐱‍💻 🐱‍💻 My Udemy Courses: + Modern JavaScript - https://www.thenetninja.co.uk/udemy/modern-javascript + Vue JS 3 & Firebase - https://www.thenetninja.co.uk/udemy/vue-and-firebase + D3.js & Firebase - https://www.thenetninja.co.uk/udemy/d3-and-firebase 🐱‍💻 🐱‍💻 Helpful Links: + Vue 3 Crash Course - https://www.youtube.com/playlist?list=PL4cUxeGkcC9hYYGbV60Vq3IXYNfDk8At1 + HTML & CSS Course - https://www.youtube.com/watch?v=hu-q2zYwEYs&list=PL4cUxeGkcC9ivBf_eKCPIAYXWzLlPAm6G + Modern JavaScript course - https://www.youtube.com/watch?v=iWOYAxlnaww&list=PL4cUxeGkcC9haFPT7J25Q9GRB_ZkFrQAc + Get VS Code - https://code.visualstudio.com/ 🐱‍💻 🐱‍💻 Social Links: Facebook - https://www.facebook.com/thenetninjauk Twitter - https://twitter.com/thenetninjauk Instagram - https://www.instagram.com/thenetninja/
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Net Ninja · Net Ninja · 0 of 60

← Previous Next →
1 Regular Expressions (RegEx) Tutorial #14 - Matching a Username
Regular Expressions (RegEx) Tutorial #14 - Matching a Username
Net Ninja
2 Regular Expressions (RegEx) Tutorial #15 - Email RegEx Pattern
Regular Expressions (RegEx) Tutorial #15 - Email RegEx Pattern
Net Ninja
3 Regular Expressions (RegEx) Tutorial #16 - Finishing Touches
Regular Expressions (RegEx) Tutorial #16 - Finishing Touches
Net Ninja
4 GraphQL Tutorial #1 - Introduction to GraphQL
GraphQL Tutorial #1 - Introduction to GraphQL
Net Ninja
5 GraphQL Tutorial #2 - A Birdseye View of GraphQL
GraphQL Tutorial #2 - A Birdseye View of GraphQL
Net Ninja
6 GraphQL Tutorial #3 - Project (stack) Overview
GraphQL Tutorial #3 - Project (stack) Overview
Net Ninja
7 GraphQL Tutorial #4 - Making Queries (front-end preview)
GraphQL Tutorial #4 - Making Queries (front-end preview)
Net Ninja
8 GraphQL Tutorial #5 - Express App Setup
GraphQL Tutorial #5 - Express App Setup
Net Ninja
9 GraphQL Tutorial #6 - Setting up GraphQL
GraphQL Tutorial #6 - Setting up GraphQL
Net Ninja
10 GraphQL Tutorial #7 - GraphQL Schema
GraphQL Tutorial #7 - GraphQL Schema
Net Ninja
11 GraphQL Tutorial #8 - Root Query
GraphQL Tutorial #8 - Root Query
Net Ninja
12 GraphQL Tutorial #9 - The Resolve Function
GraphQL Tutorial #9 - The Resolve Function
Net Ninja
13 GraphQL Tutorial #10 - Testing Queries in Graphiql
GraphQL Tutorial #10 - Testing Queries in Graphiql
Net Ninja
14 GraphQL Tutorial #11 - GraphQL ID Type
GraphQL Tutorial #11 - GraphQL ID Type
Net Ninja
15 GraphQL Tutorial #12 - Author Type
GraphQL Tutorial #12 - Author Type
Net Ninja
16 GraphQL Tutorial #13 - Type Relations
GraphQL Tutorial #13 - Type Relations
Net Ninja
17 GraphQL Tutorial #14 - GraphQL Lists
GraphQL Tutorial #14 - GraphQL Lists
Net Ninja
18 GraphQL Tutorial #15 - More on Root Queries
GraphQL Tutorial #15 - More on Root Queries
Net Ninja
19 GraphQL Tutorial #16 - Connecting to mLab
GraphQL Tutorial #16 - Connecting to mLab
Net Ninja
20 GraphQL Tutorial #17 - Mongoose Models
GraphQL Tutorial #17 - Mongoose Models
Net Ninja
21 GraphQL Tutorial #18 - Mutations
GraphQL Tutorial #18 - Mutations
Net Ninja
22 GraphQL Tutorial #19 - More on Mutations
GraphQL Tutorial #19 - More on Mutations
Net Ninja
23 GraphQL Tutorial #20 - Updating the Resolve Functions
GraphQL Tutorial #20 - Updating the Resolve Functions
Net Ninja
24 GraphQL Tutorial #21 - GraphQL NonNull
GraphQL Tutorial #21 - GraphQL NonNull
Net Ninja
25 GraphQL Tutorial #22 - Adding a Front-end
GraphQL Tutorial #22 - Adding a Front-end
Net Ninja
26 GraphQL Tutorial #23 - Create React App
GraphQL Tutorial #23 - Create React App
Net Ninja
27 GraphQL Tutorial #24 - Book List Component
GraphQL Tutorial #24 - Book List Component
Net Ninja
28 GraphQL Tutorial #25 - Apollo Client Setup
GraphQL Tutorial #25 - Apollo Client Setup
Net Ninja
29 GraphQL Tutorial #26 - Making Queries from React
GraphQL Tutorial #26 - Making Queries from React
Net Ninja
30 GraphQL Tutorial #27 - Rendering Data in a Component
GraphQL Tutorial #27 - Rendering Data in a Component
Net Ninja
31 GraphQL Tutorial #28 - Add Book Component
GraphQL Tutorial #28 - Add Book Component
Net Ninja
32 GraphQL Tutorial #29 - External Query File
GraphQL Tutorial #29 - External Query File
Net Ninja
33 GraphQL Tutorial #30 - Updating Component State
GraphQL Tutorial #30 - Updating Component State
Net Ninja
34 GraphQL Tutorial #31 - Composing Queries
GraphQL Tutorial #31 - Composing Queries
Net Ninja
35 GraphQL Tutorial #32 - query variables
GraphQL Tutorial #32 - query variables
Net Ninja
36 GraphQL Tutorial #33 - Re-fetching Queries
GraphQL Tutorial #33 - Re-fetching Queries
Net Ninja
37 GraphQL Tutorial #34 - Book Details Component
GraphQL Tutorial #34 - Book Details Component
Net Ninja
38 GraphQL Tutorial #36 - Styling the App
GraphQL Tutorial #36 - Styling the App
Net Ninja
39 GraphQL Tutorial #35 - Making a Single Query
GraphQL Tutorial #35 - Making a Single Query
Net Ninja
40 Build Apps with Vue & Firebase - Udemy Course
Build Apps with Vue & Firebase - Udemy Course
Net Ninja
41 Updated Vue & Firebase Course (Udemy)
Updated Vue & Firebase Course (Udemy)
Net Ninja
42 Vue & Firebase Real-time Chat (Preview) #1 - Intro
Vue & Firebase Real-time Chat (Preview) #1 - Intro
Net Ninja
43 Vue & Firebase Real-time Chat (Preview) #2 - Project Structure
Vue & Firebase Real-time Chat (Preview) #2 - Project Structure
Net Ninja
44 Vue & Firebase Real-time Chat (Preview) #3 - Firestore Setup
Vue & Firebase Real-time Chat (Preview) #3 - Firestore Setup
Net Ninja
45 Vue & Firebase Real-time Chat (Preview) #4 - Welcome Screen
Vue & Firebase Real-time Chat (Preview) #4 - Welcome Screen
Net Ninja
46 Vue & Firebase Real-time Chat (Preview) #5 - Props in Routes
Vue & Firebase Real-time Chat (Preview) #5 - Props in Routes
Net Ninja
47 Vue & Firebase Real-time Chat (Preview) #6 - Route Guards
Vue & Firebase Real-time Chat (Preview) #6 - Route Guards
Net Ninja
48 Vue & Firebase Real-time Chat (Preview) #7 - Chat Window
Vue & Firebase Real-time Chat (Preview) #7 - Chat Window
Net Ninja
49 Vue & Firebase Real-time Chat (Preview) #8 - New Message Component
Vue & Firebase Real-time Chat (Preview) #8 - New Message Component
Net Ninja
50 Object Oriented JavaScript Tutorial #1 - Introduction
Object Oriented JavaScript Tutorial #1 - Introduction
Net Ninja
51 Object Oriented JavaScript Tutorial #2 - Object Literals
Object Oriented JavaScript Tutorial #2 - Object Literals
Net Ninja
52 Object Oriented JavaScript Tutorial #3 - Updating Properties
Object Oriented JavaScript Tutorial #3 - Updating Properties
Net Ninja
53 Object Oriented JavaScript Tutorial #4 - Classes
Object Oriented JavaScript Tutorial #4 - Classes
Net Ninja
54 Object Oriented JavaScript Tutorial #5  - Class Constructors
Object Oriented JavaScript Tutorial #5 - Class Constructors
Net Ninja
55 Object Oriented JavaScript Tutorial #6 - Class Methods
Object Oriented JavaScript Tutorial #6 - Class Methods
Net Ninja
56 Object Oriented JavaScript Tutorial #7 - Method Chaining
Object Oriented JavaScript Tutorial #7 - Method Chaining
Net Ninja
57 Object Oriented JavaScript Tutorial #8 - Class Inheritance
Object Oriented JavaScript Tutorial #8 - Class Inheritance
Net Ninja
58 Object Oriented JavaScript Tutorial #9 - Constructors (under the hood)
Object Oriented JavaScript Tutorial #9 - Constructors (under the hood)
Net Ninja
59 Object Oriented JavaScript Tutorial #10 - Prototype
Object Oriented JavaScript Tutorial #10 - Prototype
Net Ninja
60 Object Oriented JavaScript Tutorial #11 - Prototype Inheritance
Object Oriented JavaScript Tutorial #11 - Prototype Inheritance
Net Ninja

Related Reads

📰
Browser-Based PDF Editing with Vue 3 and pdf-lib
Learn to build a browser-based PDF editor using Vue 3 and pdf-lib, enabling users to edit PDFs directly in the browser
Dev.to · sunshey
📰
Say Goodbye To Electron?
Learn about a new approach to building native applications without Electron, using frontend-style development
Medium · Programming
📰
Why Vanilla JS? In the article below, I am sharing my story of building SaaS product in vanilla js and explaining why I decided to go with this approach. https://guseyn.com/html/posts/why-vanilla-js.html
Learn why choosing Vanilla JS can be a great approach for building SaaS products and how it can simplify development
Dev.to · Guseyn Ismayylov
📰
How to Create a Cursor Tail Using HTML, CSS, and JavaScript
Learn to create a colorful cursor tail using HTML, CSS, and JavaScript for a unique user interface effect
Medium · JavaScript
Up next
How To Build A Twitter Clone - React Next JS - Appwrite Crash Course
Adrian Twarog
Watch →