Skip to content

Commit f140dca

Browse files
committed
fixed boilerplate for first exercise
1 parent b4587e1 commit f140dca

File tree

24 files changed

+182
-4
lines changed

24 files changed

+182
-4
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<!-- your code here -->
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<!-- your code here -->
2+
<style>
3+
p{ background: blue; }
4+
</style>
5+
<p>Coding is a basic literacy in the digital age, and it is important for kids to understand and be able to work with and understand the technology around them. Having children learn coding at a young age prepares them for the future. Coding helps children with communication, creativity, math,writing, and confidence.</p>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<link rel="stylesheet" type="text/css" href="./styles.css" />
5+
<title>02 Background</title>
6+
</head>
7+
<body>
8+
My background should be an image with th size "contain"
9+
</body>
10+
</html>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
body {
2+
background-image: url(https://4geeksacademy.github.io/exercise-assets/img/bg/small-mosaic.jpg);
3+
background-size: cover;
4+
background-repeat: no-repeat;
5+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# `01.1` The Style Tag
2+
3+
If you want to add styles into a website by writing CSS you have to always add it withing a `<style>` tag.
4+
You can have as many style tags as you want but it is recomended to have only one at the beginning of your website code.
5+
```HTML
6+
<style>
7+
/* the website CSS Styles go here */
8+
</style>
9+
```
10+
11+
## 📝 Instructions
12+
13+
Add a `<style>` tag into your website and make the select thethe `<p>` to run its text into blue color.
14+
15+
## 💻 Preview
16+
17+
It should look like this:
18+
19+
![01 Hello World Exercise Preview](https://ucarecdn.com/6719c50c-2539-43c5-9fe0-8f67d78afc32/)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<!-- add a style tag and select the p tag and make it color blue -->
2+
<p>
3+
Coding is a basic literacy in the digital age, and it is important for kids to understand and be able to work with and understand the technology
4+
around them. Having children learn coding at a young age prepares them for the future. Coding helps children with communication, creativity,
5+
math,writing, and confidence.
6+
</p>

exercises/01.1-Your-First-Style/README.md renamed to exercises/01.2-Your-First-Style/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# `01.1` Your First Style
1+
# `01.2` Your First Style
22

33
When doing CSS, the idea is to apply `css rules` to your `html elements`, you always have to select the element first, and then specify what rules you want to apply to it:
44

@@ -13,4 +13,4 @@ a {
1313
## 📝 Instructions:
1414

1515
1. Right now there is a style being applied that is responsable of making the anchor red.
16-
2. Change the style to make your anchor look yellow.
16+
2. Change the style to make your anchor look yellow.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<style>
5+
a {
6+
/* change this style to yellow */
7+
color: red;
8+
}
9+
</style>
10+
</head>
11+
<body>
12+
Hello! <a href="#">I am an anchor in red, change my color to yellow</a>
13+
</body>
14+
</html>

exercises/01.2-Your-Second-Style/README.md renamed to exercises/01.3-Your-Second-Style/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# `01.2` Your Second Style
1+
# `01.3` Your Second Style
22

33
When doing CSS, the idea is to apply `css rules` to your `html elements`, you always have to select the element first, and then specify what rules you want to apply to it:
44

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<style>
5+
/* Your code here */
6+
</style>
7+
</head>
8+
<body>
9+
Hello! My background should be blue!
10+
</body>
11+
</html>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# `02` Separate Sylesheet
2+
3+
If you use the html `<link>` tag, you can also have your styles on a separate file that we normally call `styles.css`.
4+
5+
That is an event better practice because it lets you have an CSS agnostig website, you can change the CSS later and make the website look 100% different, but still have the same exact HTML.
6+
7+
## 📝 Instructions:
8+
9+
Fill the `styles.css` with the content needed to bake the website body blue.
10+
11+
## 💡Hint:
12+
13+
Google how to change the background color of a website body.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<link rel="stylesheet" type="text/css" href="./styles.css" />
5+
</head>
6+
<body>
7+
My background should be blue.
8+
</body>
9+
</html>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/* your styles here:
2+
1. Select the body tag.
3+
2. Add the background rule equal to blue.
4+
*/

exercises/02-Background/README.md renamed to exercises/02.1-Background/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# `02` Background
1+
# `02.1` Background
22

33
The `background` CSS rule allows us to assign and work with the background of any container. The background values can be a `color` or an `image`.
44

exercises/02.1-Background/index.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<link rel="stylesheet" type="text/css" href="./styles.css" />
5+
<title>02 Background</title>
6+
</head>
7+
<body>
8+
My background should be an image with th size "contain"
9+
</body>
10+
</html>

exercises/02.1-Background/styles.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
body {
2+
background-image: url(https://4geeksacademy.github.io/exercise-assets/img/bg/small-mosaic.jpg);
3+
background-size: cover;
4+
background-repeat: no-repeat;
5+
}

exercises/02.1-Background/tests.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
const fs=require("fs");
2+
const path=require("path");
3+
const html=fs.readFileSync(path.resolve(__dirname, "./index.html"), "utf8");
4+
const css=fs.readFileSync(path.resolve(__dirname, "./styles.css"), "utf8");
5+
6+
jest.dontMock("fs");
7+
8+
describe("All the styles should be applied", function () {
9+
beforeEach(() => {
10+
//here I import the HTML into the document
11+
document.documentElement.innerHTML=html.toString();
12+
13+
//apply the styles from the stylesheet if needed
14+
15+
16+
17+
});
18+
afterEach(() => {
19+
jest.resetModules();
20+
});
21+
it("The body tag should not contains any inline style", function () {
22+
document.querySelector(
23+
"head"
24+
).innerHTML=`<style>${css.toString()}</style>`;
25+
let bodyInlineStyle=document.getElementsByTagName("body");
26+
let emptyBodyInlineStyle={};
27+
expect(bodyInlineStyle[0].style._values).toEqual(emptyBodyInlineStyle);
28+
// expect(bodyInlineStyle[0].style._values.background - repeat).toBe(
29+
// undefined
30+
// );
31+
32+
console.log(bodyInlineStyle[0].style._values);
33+
});
34+
35+
it("the background-size should be 'contain' without quotes", function () {
36+
document.querySelector(
37+
"head"
38+
).innerHTML=`<style>${css.toString()}</style>`;
39+
// get computed styles of any element you like
40+
const body=document.querySelector("body");
41+
let styles=window.getComputedStyle(body);
42+
expect(styles["background-size"]).toBe("contain");
43+
});
44+
45+
it("the background-repeat should be 'inherit' without quotes", function () {
46+
document.querySelector(
47+
"head"
48+
).innerHTML=`<style>${css.toString()}</style>`;
49+
50+
const body=document.querySelector("body");
51+
let styles=window.getComputedStyle(body);
52+
expect(styles["background-repeat"]).toBe("inherit");
53+
});
54+
it("You should not change the head tag", function () {
55+
56+
let meta1 = document.getElementsByTagName('head')[0].innerHTML.toString().indexOf("<meta c")
57+
let meta2 = document.getElementsByTagName('head')[0].innerHTML.toString().indexOf("<meta n")
58+
let link = document.getElementsByTagName('head')[0].innerHTML.toString().indexOf("<link")
59+
let title = document.getElementsByTagName('head')[0].innerHTML.toString().indexOf("<title")
60+
expect(meta1).not.toBe(-1)
61+
expect(meta2).not.toBe(-1)
62+
expect(link).not.toBe(-1)
63+
expect(title).not.toBe(-1)
64+
expect(html.toString().indexOf(`<style`)>-1).toBeFalsy();
65+
})
66+
});

0 commit comments

Comments
 (0)