SASS Tutorial (build your own CSS library) #5 - Project Structure
Skills:
HTML & CSS70%
Key Takeaways
This video tutorial covers setting up a project structure for a custom CSS library using SASS, including organizing files, creating partials, and updating the Gulp file for compilation.
Full Transcript
all right then so for the rest of this series we're going to be building our own mini css library like bootstrap or tailwind or bulmer or something else and it is going to be a mini version a very simplified version of one of these and then we're just going to use that css library to design some kind of web page later on so to begin with i just want to set up a decent project structure so that we don't have sas code or sas files flying around everywhere and instead they're organized in a nice way that's going to make updating our project really easy so to do this we'll create a folder first of all to keep all of our sas files inside and i'm going to call the folder shinobe because that's what i'm going to call the css library that we're making shinobi css sounds kind of cool right so now we can move our two sas files into this folder the variables one and the index one and any other partials we create in the future are gonna go in here as well now to begin with in the index file i want to delete a lot of this dummy code that we created earlier on using those variables that's not going to be a part of our library so let's delete all of those and then the rest of this stuff at the top this reset stuff i want to extract all of that into a new partial file as well just so we're organizing our code in a nice modular way so first of all let me create a new partial file inside the shinobi folder called underscore and then base dot scss and then i'm going to copy all of the base styles including the font import at the top and i'm going to paste all of that into the base file all right then so now we need to import this base file into our index file because the index file is the one that's ultimately being compiled and bringing everything together we already import the variables one so now let's import the base one so underneath the variables down here i'm gonna do at import and then base all right then so now we've changed the structure of our sas files a little bit they're now living inside this folder what we need to do is go to our gulp file and just update where the source files are going to be because at the minute this is just looking at the top level for any file name with a sas extension so we need to update this now to tell it to look inside the shinobi folder first of all so i'm going to say look inside shinobi like this and then forward slash and then i'll do double asterisk and then forward slash asterisk so what's this well this right here means any subfolder as well so it's going to find any sas file or any subfolder with a sas file inside this folder and it will compile that so i'm going to do the same thing down here let me copy that and paste it down here so we're watching any sas file inside here as well and remember it's not going to compile all of those to different css files because we're using this underscore right here which marks this as a partial and it says to the compiler look don't compile me we're just using this in another file all right so that's now gonna all work we need to also open up the terminal cancel out the process because we're using the old one now and then run gulp again so we can run again watching that particular folder all right so that's all set up now now i want to talk about one more thing and that is the order of import in this file because the order of import right here does matter because different files might depend on code previously created in other files for example if inside this base file right here we create a selector so i'm going to say dot test and then inside here give it a color which is going to be a variable which we declare inside the variables file i'm going to call it primary or rather it's already called primary i'm just using that variable right here this is allowed because base is below variables in the input order so that means anything declared up here has been pulled in first of all and therefore by the time it gets to the base file it knows what those variables are and we can use them so if we take a look at the output css because this will have compiled then we can see we get that test selector with the primary color however if i was to change the order of these so that bass came first then this is not going to work and if i save it now and open up the terminal we can see we get an error which says that we can't read basically the primary variable it's undefined and that's because the sas compiler is working top to bottom in this file it runs through all of the base file first of all it gets to this primary color and says hang on what's going on here i don't know what this primary variable is so i'm going to give you this error down here and it's not going to compile for us so the order does matter if a file depends on a value declared in another file then it must be below the file it depends on okay so i'm going to grab the base again and bring it down here all right then so what i'm going to do is just mark in a few comments in this file so that in the future when we start to add other partials we know where they're meant to go and we're not going to get confused about the order of imports so let me first of all at the top say this is going to be for variables and also functions we don't know what functions are in sas yet but they're basically like functions in programming and other files might use them so they're going to go at the top later as well all right so after that we're going to have all of the kind of base layout stuff so base and layout because these are reset styles right so they're very kind of top level styles and the layout as well is going to be things like the grid system so that's going to come second all right so after that it's going to be the colors so things we do with colors to generate classes like for backgrounds or text colors they're all going to use variables and maybe a function so they have to come down below and then after that it's going to be components let me give a little more space here we'll say components and that's going to be for things like the button components or the card components or the nav bar etc now all of these things are probably going to use the variables and functions as well maybe something else either way they're going to come fairly near the bottom but at the very bottom let me close this is going to be the utilities so let me do utilities right here and that's going to be things like the margin classes the padding classes opacity etc so all of those are going to be at the bottom because again that probably depend on variables and functions now the order of these kind of things right here maybe it might be that these could go above the colors or these could go above components that might not matter so much the main ones is that the variables and the functions that a lot of the other files are going to go at the top but we'll just stick to this kind of general import order here as we make more files in the future
Original Description
In this SASS tutorial we'll start work on the CSS library by mapping out our project structure.
🐱👤 Get the full SASS course now on Net Ninja Pro:
https://netninja.dev/p/complete-sass-tutorial
🐱👤 Get access to all other premium courses on Net Ninja Pro:
https://netninja.dev/
🐱💻 Access the course files on GitHub:
https://github.com/iamshaunjp/complete-sass-tutorial
🐱💻 HTML & CSS Crash Course:
On Net Ninja Pro - https://netninja.dev/p/html-css-crash-course
On YouTube - https://www.youtube.com/watch?v=hu-q2zYwEYs&list=PL4cUxeGkcC9ivBf_eKCPIAYXWzLlPAm6G
🐱💻 Modern JavaScript Course:
On Net Ninja Pro - https://netninja.dev/p/modern-javascript-from-novice-to-ninja
On YouTube - https://www.youtube.com/watch?v=iWOYAxlnaww&list=PL4cUxeGkcC9haFPT7J25Q9GRB_ZkFrQAc
🐱💻 CSS Flexbox Course (on YouTube):
https://www.youtube.com/watch?v=Y8zMYaD1bz0&list=PL4cUxeGkcC9i3FXJSUfmsNOx8E7u6UuhG
🐱💻 SASS docs - https://sass-lang.com/documentation
🐱💻 VS Code - https://code.visualstudio.com/
-------------- Net Ninja Links:
🐱💻 My Social Links:
Facebook - https://www.facebook.com/thenetninjauk
Twitter - https://twitter.com/thenetninjauk
Instagram - https://www.instagram.com/thenetninja/
🐱👤 Get access premium courses on Net Ninja Pro:
https://netninja.dev/
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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Regular Expressions (RegEx) Tutorial #14 - Matching a Username
Net Ninja
Regular Expressions (RegEx) Tutorial #15 - Email RegEx Pattern
Net Ninja
Regular Expressions (RegEx) Tutorial #16 - Finishing Touches
Net Ninja
GraphQL Tutorial #1 - Introduction to GraphQL
Net Ninja
GraphQL Tutorial #2 - A Birdseye View of GraphQL
Net Ninja
GraphQL Tutorial #3 - Project (stack) Overview
Net Ninja
GraphQL Tutorial #4 - Making Queries (front-end preview)
Net Ninja
GraphQL Tutorial #5 - Express App Setup
Net Ninja
GraphQL Tutorial #6 - Setting up GraphQL
Net Ninja
GraphQL Tutorial #7 - GraphQL Schema
Net Ninja
GraphQL Tutorial #8 - Root Query
Net Ninja
GraphQL Tutorial #9 - The Resolve Function
Net Ninja
GraphQL Tutorial #10 - Testing Queries in Graphiql
Net Ninja
GraphQL Tutorial #11 - GraphQL ID Type
Net Ninja
GraphQL Tutorial #12 - Author Type
Net Ninja
GraphQL Tutorial #13 - Type Relations
Net Ninja
GraphQL Tutorial #14 - GraphQL Lists
Net Ninja
GraphQL Tutorial #15 - More on Root Queries
Net Ninja
GraphQL Tutorial #16 - Connecting to mLab
Net Ninja
GraphQL Tutorial #17 - Mongoose Models
Net Ninja
GraphQL Tutorial #18 - Mutations
Net Ninja
GraphQL Tutorial #19 - More on Mutations
Net Ninja
GraphQL Tutorial #20 - Updating the Resolve Functions
Net Ninja
GraphQL Tutorial #21 - GraphQL NonNull
Net Ninja
GraphQL Tutorial #22 - Adding a Front-end
Net Ninja
GraphQL Tutorial #23 - Create React App
Net Ninja
GraphQL Tutorial #24 - Book List Component
Net Ninja
GraphQL Tutorial #25 - Apollo Client Setup
Net Ninja
GraphQL Tutorial #26 - Making Queries from React
Net Ninja
GraphQL Tutorial #27 - Rendering Data in a Component
Net Ninja
GraphQL Tutorial #28 - Add Book Component
Net Ninja
GraphQL Tutorial #29 - External Query File
Net Ninja
GraphQL Tutorial #30 - Updating Component State
Net Ninja
GraphQL Tutorial #31 - Composing Queries
Net Ninja
GraphQL Tutorial #32 - query variables
Net Ninja
GraphQL Tutorial #33 - Re-fetching Queries
Net Ninja
GraphQL Tutorial #34 - Book Details Component
Net Ninja
GraphQL Tutorial #36 - Styling the App
Net Ninja
GraphQL Tutorial #35 - Making a Single Query
Net Ninja
Build Apps with Vue & Firebase - Udemy Course
Net Ninja
Updated Vue & Firebase Course (Udemy)
Net Ninja
Vue & Firebase Real-time Chat (Preview) #1 - Intro
Net Ninja
Vue & Firebase Real-time Chat (Preview) #2 - Project Structure
Net Ninja
Vue & Firebase Real-time Chat (Preview) #3 - Firestore Setup
Net Ninja
Vue & Firebase Real-time Chat (Preview) #4 - Welcome Screen
Net Ninja
Vue & Firebase Real-time Chat (Preview) #5 - Props in Routes
Net Ninja
Vue & Firebase Real-time Chat (Preview) #6 - Route Guards
Net Ninja
Vue & Firebase Real-time Chat (Preview) #7 - Chat Window
Net Ninja
Vue & Firebase Real-time Chat (Preview) #8 - New Message Component
Net Ninja
Object Oriented JavaScript Tutorial #1 - Introduction
Net Ninja
Object Oriented JavaScript Tutorial #2 - Object Literals
Net Ninja
Object Oriented JavaScript Tutorial #3 - Updating Properties
Net Ninja
Object Oriented JavaScript Tutorial #4 - Classes
Net Ninja
Object Oriented JavaScript Tutorial #5 - Class Constructors
Net Ninja
Object Oriented JavaScript Tutorial #6 - Class Methods
Net Ninja
Object Oriented JavaScript Tutorial #7 - Method Chaining
Net Ninja
Object Oriented JavaScript Tutorial #8 - Class Inheritance
Net Ninja
Object Oriented JavaScript Tutorial #9 - Constructors (under the hood)
Net Ninja
Object Oriented JavaScript Tutorial #10 - Prototype
Net Ninja
Object Oriented JavaScript Tutorial #11 - Prototype Inheritance
Net Ninja
More on: HTML & CSS
View skill →
🎓
Tutor Explanation
DeepCamp AI