text
stringlengths 1
81
| start
float64 0
10.1k
| duration
float64 0
24.9
|
---|---|---|
We're going to conventionally use dot
scss to stand for this is a Sass file. | 6,518.77 | 6.55 |
So here is now variables.scss. | 6,525.32 | 3.26 |
And now what I can do in Sass is
I can actually create variables | 6,528.58 | 3.1 |
in the same way that we could create
variables in a programming language, | 6,531.68 | 3.05 |
like Python, which we'll soon see. | 6,534.73 | 2.01 |
CSS normally doesn't
support variables, but Sass | 6,536.74 | 2.55 |
is going to give us that power. | 6,539.29 | 1.86 |
In Sass, all variables
begin with a dollar sign. | 6,541.15 | 3.1 |
So I can create a variable $color
to create a variable called color. | 6,544.25 | 5.02 |
And I can say the variable called
color is going to be equal to red. | 6,549.27 | 4.33 |
So this line here, line
1, is my way of telling | 6,553.6 | 2.52 |
Sass I'd like to create
a variable called color | 6,556.12 | 2.46 |
and I'd like for its value to be red. | 6,558.58 | 3.45 |
And now, I can add the
same styling I had before. | 6,562.03 | 2.19 |
I can just use normal CSS
and say for an unordered list | 6,564.22 | 3.15 |
I'd like the font size to be 14 pixels. | 6,567.37 | 2.61 |
But the color, instead of saying red
here, I can use the name of a variable. | 6,569.98 | 5.25 |
I can say $color to mean go ahead and
use the value of the variable color | 6,575.23 | 6.15 |
as the color for this unordered list. | 6,581.38 | 2.97 |
Then for an ordered list, I'll
also say font size 18 pixels | 6,584.35 | 4.56 |
and say color should also be
this variable called color. | 6,588.91 | 4.77 |
By using a variable, I've
removed the repetition. | 6,593.68 | 2.85 |
Rather than having the word red show
up in multiple places in my code | 6,596.53 | 3.31 |
where I would need to change it
twice if I ever needed to change it, | 6,599.84 | 2.84 |
now I have defined the variable once. | 6,602.68 | 2.25 |
And I only ever need to
change it in one place | 6,604.93 | 2.31 |
if I ever need to make modifications
to this particular file. | 6,607.24 | 4.09 |
So now, let's try and link this file. | 6,611.33 | 3.41 |
We'll go back to variables.html. | 6,614.74 | 2.58 |
Instead of putting the style code here,
I'll go ahead and link a style sheet | 6,617.32 | 7.21 |
and say, the href should
be variables.scss, | 6,624.53 | 3.66 |
because that's the file
where my styling exists. | 6,628.19 | 3.31 |
So now let me try and open up
variables.html after I've linked | 6,631.5 | 4.1 |
the CSS. | 6,635.6 | 1.75 |
And, all right, something
seems not quite right. | 6,637.35 | 2.34 |
I specified font sizes. | 6,639.69 | 1.44 |
I specified that
everything should be red. | 6,641.13 | 1.95 |
But it's not showing up. | 6,643.08 | 1.05 |
Everything is showing up black. | 6,644.13 | 1.69 |
And I don't see any of
the differences in sizing. | 6,645.82 | 3.41 |
And the reason for this is while the web
browser, things like Chrome and Safari | 6,649.23 | 4.41 |
and Firefox can understand CSS,
they can't by default understand | 6,653.64 | 4.71 |
SCSS, or Sass. | 6,658.35 | 1.56 |
Sass is an extension to CSS that
web browsers don't understand out | 6,659.91 | 3.96 |
of the box. | 6,663.87 | 1.48 |
So in order to solve this problem,
once we've written our Sass file, | 6,665.35 | 3.62 |
we need to compile it, convert
it, translate it, so to speak, | 6,668.97 | 3.45 |
from Sass into plain old CSS so that
our browser is able to understand it. | 6,672.42 | 5.83 |
And in order to do this,
you'll need to install | 6,678.25 | 2.3 |
a program called Sass on your computer. | 6,680.55 | 1.97 |
And you can install it
on Mac or PC or Linux. | 6,682.52 | 2.53 |
And now, in the terminal, in
order to do this compilation, | 6,685.05 | 2.91 |
I'm going to say Sass variables.scss,
the file I'd like to compile, | 6,687.96 | 7.44 |
colon variables.css. | 6,695.4 | 2.99 |
So variables.scss is the file
that I would like to compile. | 6,698.39 | 4.19 |
And the file I'd like to
generate is variables.css. | 6,702.58 | 3.44 |
I'd like to turn my Sass file
into a plain old CSS file. | 6,706.02 | 4.77 |
I'll go ahead and press Return. | 6,710.79 | 1.71 |
And all right, that compilation
process is now done. | 6,712.5 | 3.02 |
And so now, inside of variables.html,
instead of referencing the SCSS file, | 6,715.52 | 6.94 |
I'm going to reference the
CSS file as the style sheet, | 6,722.46 | 3.36 |
because my web browser only understands
CSS, it doesn't understand Sass. | 6,725.82 | 5.69 |
Now, when I load the page,
now I see the result I expect. | 6,731.51 | 3.39 |
Everything shows up as red and
the font sizes are different. | 6,734.9 | 3.27 |
So ultimately, this
was a 2-step process. | 6,738.17 | 2.4 |
I first needed to take my Sass
code, compile it into CSS. | 6,740.57 | 4.29 |
And then I could link the
CSS to this particular page. | 6,744.86 | 3.75 |
But the advantage now is that if ever
I want to make some sort of change, | 6,748.61 | 3.3 |
I want to change the color, rather
than change it in two places, | 6,751.91 | 3.13 |
or you might imagine in a more complex
page, like tens or dozens of places, | 6,755.04 | 4.13 |
I just go to the SCSS file, and I
change the color from red to blue. | 6,759.17 | 6.45 |
Now, if I refresh the page, all
right everything is still red. | 6,765.62 | 3.35 |
And that's because I forgot a step. | 6,768.97 | 1.7 |
I changed the Sass file. | 6,770.67 | 1.84 |
But that doesn't automatically
change the CSS file. | 6,772.51 | 2.91 |
I need to now recompile the CSS
file by saying Sass variables.scss | 6,775.42 | 5.76 |
variables.css, to compile the file
again using the updated Sass file. | 6,781.18 | 5.58 |
And now, I see the updated changes. | 6,786.76 | 3.09 |
And if you're curious as to what
the updated file looks like, | 6,789.85 | 2.55 |
I'm actually look at variables.css
to see what code happens to be there, | 6,792.4 | 4.47 |
and, though, it's styled
a little bit strangely. | 6,796.87 | 2.04 |
You can see that I have a UL with a
font size a 14 and a color of blue. | 6,798.91 | 4.17 |
So they've substituted the
word blue for this variable. | 6,803.08 | 2.97 |
And they've done the same thing
for ordered lists as well. | 6,806.05 | 4.07 |
Now, in practice, it's
going to be pretty annoying | 6,810.12 | 2.31 |
if I'm building a web
page, building using Sass, | 6,812.43 | 2.7 |
if I constantly need to go back
and recompile my Sass into CSS | 6,815.13 | 3.87 |
every single time. | 6,819 | 1.14 |
What I'd like to do is
just automate that process. | 6,820.14 | 2.43 |
And Sass makes it easy to do this. | 6,822.57 | 2.01 |
I can just say, Sass dash dash
watch variables.scss variables.css. | 6,824.58 | 7.19 |
And what that's going to do is now
you see Sass is watching for changes. | 6,831.77 | 3.88 |
Sass is going to monitor
the variables.scss file. | 6,835.65 | 3.9 |
And if ever I change my Sass file,
Sass is going to know about it. | 6,839.55 | 3.75 |
And it's automatically going to
recompile the corresponding CSS file. | 6,843.3 | 4.16 |
And you can do this not just with
single files, but entire directories | 6,847.46 | 2.92 |
as well if you have multiple
different Sass files. | 6,850.38 | 2.73 |
So now, what I can do is if in
the variables.scss file I change | 6,853.11 | 5.82 |
the color-- | 6,858.93 | 0.81 |
instead of blue, I now want
it to be green, for example-- | 6,859.74 | 2.96 |