Vue & Firebase Real-time Chat (Preview) #7 - Chat Window

Net Ninja · Intermediate ·🛠️ AI Tools & Apps ·8y ago

Key Takeaways

This video demonstrates how to create a chat window component using Vue.js and Firebase, including designing the template, styling the chat window, and planning for future functionality.

Full Transcript

so we have our welcome screen here now directing us to this chat component with the name so this is the component which will actually show the chat window and the messages inside it so let's start to create the template for this component so we'll go over to our chat dot view component over here and we'll create the template inside the container now I want to get rid of what's currently inside this h2 right here because we don't just want to output the name up there that makes no sense instead we'll call this ninja chat and what I'll do is give this a class as well and the class is going to be equal to center to essentially align this X to text and also teal - text so make it that blue green color okay so the next thing we need to do is a div with a class of card like so and then inside this we need some card content so again another div with a class of card - contents then inside this div what I'd like to do is output the messages now since there's going to be a series of different messages it makes sense to create a ul and loads of different Li tags inside of it one for each message so we'll do that will create a ul and this is going to have a class of messages and inside that we'll do an li tag and by the way this class right here this is nothing to do with materialized this is our own class we might use to style these things up later on so each message will be an li tag and eventually we will use v4 to output a different Li tag for each different message but since we don't have those messages yet we'll just create some dummy HTML for each different message so inside this Li tag we're going to have three things we're going to have the name of the person that sends the message we're also going to have the message content and then final it will have the time the time that the message was created so for each one of these different things I'm going to do a span tag so first of all we'll do a spun for the name and this is going to have a class of teal - text and we'll just place name there to begin with since we have no dynamic data yet and the second one will be a span with a class of gray - text and will say text - darken - three so that's going to take that gray text color and darken it by three steps okay and inside this will be the actual message content again we don't have dynamic data so we'll just place message there for now and finally spun with a class of gray - text again and also it's going to have a class of time because we'll starless up slightly differently later on and we'll use that class to do that and in here we'll just say time but we will output the timestamp there format it in some way shape or form later as well okay so that's the kind of HTML I want output for each different message we have and later on like I said we will use V - 4 on this Li Tech to cycle through each message and output this stuff for each different message we have in the database alright then so now underneath the card content over here I'd like to do another div with a class of card - action again this is a utility class provided by materialised and this is just going to separate a little bottom part of the whole car for us and this is where our form will be for a user to add a new message now for now I'm just gonna do an input box with a type of text and leave it at that and we'll come back to this shortly alright so that's the basic template done over there the next thing I'd like to do well first of all we'll preview it in a browser so this is what it looks like at the minute and this looks okay but we still need to style this up a little bit to begin with these three things are sitting next to each other and they shouldn't really do that they should probably sit on top of each other or at least the time should be done there so we'll sort that out and a couple of other things as well so let's go down to the style tags and inside here first of all we'll say chat which is the div at the top we gave that a class of chat and then we want the h2 inside of that and the font size of this H 2 will be 2.6 m/s okay and the margin bottom just to separate you from the chat window itself will be about 40 pixels alright then so we also want to grab each of the span tags inside those allies so these things right here and since they're the only span tags in the chat over here we can just say chat spun and for each of these I'd like to give a font - size of 1.4 m/s alright and then finally like one more rule will say chat time so that's that third span tag where we output the time itself we want to display this as block because we want it to go on to the next line and block level elements do them so display it as block and the font size will also be about 1.2 m/s so let's save this and view this in a browser okay I think that looks a bit better now we have the ninja chat separated from the window and also now the time is going to be displayed below these two things right here where the name and the message is plus it's also a little smaller which I think works well as well cool so that is our chat window created right there now we also have this input field right here and we did that or right here ultimately in the next lesson what we'll do is separate this section this little farm into its own component just to keep everything modular because this component right here this will be all about receiving data from firebase whereas this component right here the new message component that will be all about taking data from a user and pushing it over to firebase so they have two different roles really which is why it's nice to keep them a little separated from each other to avoid any kind of data confusion so we'll look at that in the next video

Original Description

FULL COURSE LINK - https://www.udemy.com/build-web-apps-with-vuejs-firebase/?couponCode=NINJAYT18 Use Code NINJAYT18 for discount. Discount should already be applied when using the link above! See the full course for a full Vue.js tutorial, including building 3 projects with Firebase.
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Net Ninja · Net Ninja · 48 of 60

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
▶ 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

Create a chat window component using Vue.js and Firebase, and style it using CSS. Plan for future functionality, such as separating the input field into its own component.

Key Takeaways
  1. Create a new Vue.js component for the chat window
  2. Design the template for the chat window
  3. Add styling to the chat window using CSS
  4. Plan for future functionality, such as separating the input field into its own component
💡 Separating components into smaller, modular pieces can help avoid data confusion and make the application easier to maintain.

Related Reads

📰
Patbase API vs Traditional Prior Art Frameworks
Learn how Patbase API outperforms traditional prior art frameworks for patent search and analysis
Dev.to AI
📰
Convolvger 0.5.0: archive your AI conversations locally — ChatGPT, Claude, Gemini, and now Grok
Archive AI conversations locally with Convolvger 0.5.0, supporting ChatGPT, Claude, Gemini, and Grok, to keep a record of your conversations beyond sharing links
Dev.to · Fahad Bilal Saleem
📰
AI Made My Documentation Faster. It Also Made It Wrong.
Learn how to use AI-generated documentation effectively and catch errors with 5 specific prompts for technical writers
Medium · AI
📰
OpenAI, Claude, Gemini Compatible Summarization API in Node.js (One Contract)
Implement a summarization API in Node.js to extract costs from invoices using OpenAI, Claude, or Gemini models
Dev.to AI
Up next
How to Get Your Brand Cited by ChatGPT, Claude and Gemini
Arvow
Watch →