GraphQL Tutorial #36 - Styling the App

Net Ninja · Beginner ·🔧 Backend Engineering ·8y ago

Key Takeaways

Stylizes a GraphQL app using CSS

Full Transcript

all right they're my friends so we've got the functionality of this app down to a tee so we can do all kinds of magic inside it however at the minute it's looking very much like a program developed by a server-side programmer who doesn't know any CSS at all so let's try our best to rectify that and just make this look a little bit better so let's head over to the code and we can see this is the root up and we have this div right here with an ID of main so let's grab that first of all and style up that one so we'll go into index dot CSS and this is where we can add all of our CSS for this project the first thing I'd like to do then is get that main ID and we'll style the h1 inside it and we'll say color is going to be 444 and then text aligned is going to be Center so basically it 444 is kind of a deep great and we're just putting it to the center as well next we'll take the main container itself not the h1 inside it we'll give it a padding of 0 pixels and then we'll give it a box sizing of border - box that just basically takes into consideration the padding and the border when it works out the width of something and then the width is going to be set to 60 the sense of the screen and the height is going to be a 100% alright so we have the main thing sorted let's save this and view it in a browser probably not gonna look that much different to be honest at the minute okay no nothing much I do here but anyway it's getting there so let's go back into this the next thing I'd like to do is style up that book list so let's take a look at this we have down here an ID of book links we have a ul inside it and a lies inside that so let's stand up those bad boys will say book list first of all and that's going to have a padding of 0 and then after that we'll do the Li tags inside the book list so book list Li and then underneath that we want to display each one as in line block that's going to place them next to each other rather than just one on top of the other the margin is going to be around 12 pixels each way around the padding about 10 pixels and then the border Raiders border-radius rather is going to be about 4 pixels just to give it a kind of softer feel and the border itself is gonna be one pixel in width it's gonna be solid and it's gonna be a color which is kind of like a pinky color which is 8 8 then 0e then 4s all right so I have to moved on that let's give this a box shadow just to lift out of the page and give it a bit of depth so the box shadow is going to be 1 pixel to pixel 3 pixel then we'll use RGB a so we have an alpha Channel and we can set the opacity 0 0 0 and then not 0.3 for the opacity so it's like a kind of black box shadow but only semi-transparent okay so the cursor is going to be as well a pointer because when a user hovers over a book I want them to know they can click it and I want that little hand pointer instead of just an arrow and then finally the color of the text inside here is gonna be the same as the border which is 8 8 0 e F or was it 4 F yep 4 F cool all right there so are we doing something's gone wrong here or we need the semicolon at the end cool so let's save that and take a look in the browser again all right starting to look a little bit better now I'm zoomed in to X let's zoom out a little bit go to 150 or even a hundred and twenty-five percent okay so we can start to see these are looking a little bit better now so we need to stand up as well the form so let's do that next we'll go back into our CSS and so I get the form I'm just gonna give myself a little bit of room so the form is next now this form is going to have a background of white so it stands out a little bit on the page now don't do what I've done and do everything in capitals because just not good at all we'll do background of FFF so that's white it stands out on the page the padding is going to be about 20 pixels the position is going to be fixed because it's gonna be fixed in the bottom left of the screen so wanting to stay there so left is going to be zero and bottom is also going to be zero sweep the width of the forum I'm just going to set to forage of pixels for now all right so now we can start each field inside the forum if we look at book where the forum is we can see we have these different fields right and they all have a class name of field so inside the CSS we'll say for and then dot field and inside here we'll say display grid and grid template columns is going to be one fraction and one fraction again so that's for the label and the input box now if you're unsure on CSS grid I've got a whole playlist on CSS grid I'm not going to spend this video explaining the nuances of it go and check that out if you want to I'll leave the link down below so also we're going to give this a grid gap off around ten pixels that just means there's a tempest will gap between each column if you like and row so now we've done the fields let's style up the labels will say farm label and this is going to have a text align property of right so it's going to scoot over to the right for the label and a padding of six pixels something like that let's just see how it's looking at the minute go over here mmm all right looking okay so this is the grid and the text align in place we have the farm fields on the right and we have the labels on the left ball text aligned to the right so start to look a little bit better already and if I go back now to the code we can carry this on so I'd like to also style up the Select and the input fields so we'll say form select and form input like so and inside here I'd like to say the margin of each one is going to be four pixels the padding is going to be around six pixels and the box sizing is going to be border-box all right cool now we want to style up that button on the bottom left down here okay want to make it look a little more puppet and stand out so let us make some space again and say form button and this is going to have a color of white so that's the text inside it so FFF the font size is going to be two M's and the background is going to be kind of like a pinky color and the hex code for that is a D one four five seven cool all right now we want a border of zero on the button itself the padding is going to be zero top and bottom but ten pixels left and right the border radius is going to be fifty percent and what that does is turn it into a circle when the border radius is 50% or more of something it's going to turn it into a circle right so all if it allows to be a circle it's small enough to be a circle that is so the cursor is going to be a pointer so we know we can click it the position is going to be absolute and then the bottom is going to be ten pixels so it's going to shift up a little bit from the bottom and also from the left as well ten pixels so let's have a look at that button right now see what it looks like all right cool so it's looking a bit better now let me just zoom in a little all right here we go take that off so this is looking pretty good so far we have now the farm sorted and we have the list of books down here sorted I suppose all we need to do now is stand up this thing so it's some kind of panel on the right so let us go back to the code and do that if we go to book details we can see that this has an ID of book - detail so let's use that will copy it and we'll paste it over here alright so book details now the position of this thing is going to be fixed on the right hand side so we'll say top is zero so it's flush to the top and right is also zero so it's flush to the right the width is going to be 40% and the height is going to be 100% alright so we have the content on the left which is 60% in weight I think let me just check yep the main is 60% in width then we have this on the right which is going to be 40% in width make sense the height is 100% so hopefully it's going to take up the whole height of the screen all right so the background of this is going to be kind of like a pink color so we'll use that same hex code that we used for the button right here so let me just copy that and paste it down here all right the padding and we'll say about 30 pixels the overflow is going to be auto so we'll get a scrollbar if it flows over the initial height the box shadow is going to be minus 2 pixels because we want to scoot it out to the left minus 3 pixels and 5 pixels and rgba so we have an alpha channel as well again we'll do 0 0 0 which is black and not 0.3 for the opacity all right then we want a box - sizing of border box and then finally the color of the text inside is going to be white whew oh my god so that was a lot of CSS to cram into what is about seven or eight minutes so at the minute we can see no book selected if we select a book now we can see all the book details on the right all right so let's just try adding one more book my great book this doesn't exist genre let's do something else let's do horror and then we'll just assign this one to Brandon Sanderson for the hell of it ok so now we can see my great book is here if we click on that we get details about that book as well awesome so my friends there we go that is your tour into graph QL over I hope you've enjoyed this series and you've gathered some kind of useful information from it if you do like these videos with my friends please do not forget to share subscribe and like and I'm going to see you in the very next tutorial series

Original Description

DONATE :) - https://www.paypal.me/thenetninja ----- COURSE LINKS: + Course files - https://github.com/iamshaunjp/graphql-playlist + Atom editor - https://atom.io/a + CMDER - http://cmder.net/ + Node Download - https://nodejs.org/en/ ======== Other Tutorials ========= ----- NODE.JS TUTORIALS https://www.youtube.com/playlist?list=PL4cUxeGkcC9gcy9lrvMJ75z9maRw4byYp ----- MONGODB TUTORIALS https://www.youtube.com/playlist?list=PL4cUxeGkcC9jpvoYriLI0bY8DOgWZfi6u ----- REACT TUTORIALS https://www.youtube.com/playlist?list=PL4cUxeGkcC9i0_2FF-WhtRIfIJ1lXlTZR ----- SUBSCRIBE TO CHANNEL - https://www.youtube.com/channel/UCW5YeuERMmlnqo4oq8vwUpg?sub_confirmation=1 ======== Social Links ========== Twitter - @TheNetNinja - https://twitter.com/thenetninjauk Patreon - https://www.patreon.com/thenetninja
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Net Ninja · Net Ninja · 38 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
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 AI Lessons

Up next
This Cop Was Held Accountable For His Brutality! #police #lawyer
Hampton Law
Watch →