Creating and Using Snippets
Snippets are like shortcuts for code or text that you can reuse. They're super handy for saving time and
avoiding repetitive typing. They are specially good if there is a piece of code you use often. To create
one you take a piece of code you have used before and that can be customized for future purposes. For
this, its important that you add placeholder to the values, so that when you add it you can put the
values you need for that code.
Some of the placeholders that we used:
- ${1:placeholder}
- ${2:placeholder}
- ${3:placeholder}
- ${4:placeholder}
(You would replace placeholder with the actual value of the property, for example first-name, last-name,
age, item, date).
Snippets for Lab Notes
<section>
<h1>Lab ${1:Labnumber}</h1>
</section>
<article>
<h1>${1:Lab-title}</h1>
</article>
SCSS
- I think one of the most important benefits is that you can add variables. This is benefitial because
it provides consistency to the whole document.
- The other function we used that was incredibly benefitial was Nesting with SCSS. This reduce the
content of our stylesheet but still applied the same properties. This is easier for rules that
share the same selector but then have different classes or id within them.
- We have not explore the other benefits it brings, but from what I have observes so far, it is better for plain old CSS which makes you work more.
- Original CSS for the rules with worked 65-77
#OrderInfo td:nth-child(odd),
#Addresses td:nth-child(odd) {
text-align: right;
padding-right: 10px;
}
#OrderInfo td:nth-child(odd)::after,
#Addresses td:nth-child(odd)::after {
content: ':'
}
#Addresses tr:first-child td:nth-child(even) {
border: none;
}
#OrderInfo td:nth-child(even),
#Addresses td:nth-child(even) {
border: 1px solid #000;
padding-left: 10px;
text-align: left;
}
#OrderDetailsTable .subtotals td,
#OrderDetailsTable .shipping td,
#OrderDetailsTable .total td {
border-left: none;
}
#OrderDetailsTable td,
#OrderDetailsTable th {
border-left: 1px solid black;
}
#OrderDetailsTable tr *:not([class='numeric']) {
padding-left: 10px;
}
#OrderDetailsTable th {
font-weight: bold;
color: #FFF;
background-color: #036;
text-align: left;
font-size: 16px;
}
The final SCSS version of the rule
#OrderInfo, #Addresses { td:nth-child(odd) {
text-align: right;
padding-right: 10px;
&:after {
content: ':'
}
}
td:nth-child(even) {border: 1px solid #000;
padding-left: 10px;
text-align: left;}
}
#OrderDetailsTable {
.subtotals td, .shipping td, .total td { border-left: none;}
td, th {border-left: 1px solid black;}
tr *:not([class='numeric']){
padding-left: 10px; }
th {font-weight: bold;
color: #FFF;
background-color: $hopeBlue;
text-align: left;
font-size: 16px;}
}