Skip to content

04.3 id selector to 13 anchor like button #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
683104f
added missing solution and test files
UmiKami Aug 3, 2022
dbbb231
added solution to file
UmiKami Aug 3, 2022
e2ab594
added tests to file to check for id name and if span exists
UmiKami Aug 3, 2022
76db85e
added solution file
UmiKami Aug 3, 2022
1d99ba2
improved tests
UmiKami Aug 3, 2022
dcfad06
added solution
UmiKami Aug 4, 2022
7cc4d9f
improved tests and fixed minor issues
UmiKami Aug 4, 2022
9e629d7
added solution
UmiKami Aug 4, 2022
67b2563
fixed minor errors and improved test format
UmiKami Aug 4, 2022
62a29ac
added solution
UmiKami Aug 4, 2022
d62d736
fix minor issues and improved format
UmiKami Aug 4, 2022
2ff5fca
added solution
UmiKami Aug 4, 2022
e5ae3f2
added test to prevent user from changing default styles plus minor im…
UmiKami Aug 4, 2022
b512f71
added solutions for html and css
UmiKami Aug 4, 2022
e4452cc
fixed issue with CSS rules, improved tests
UmiKami Aug 4, 2022
a01e4bf
added solution
UmiKami Aug 4, 2022
b62745c
fixed test checking for the wrong class, improved tests overall
UmiKami Aug 4, 2022
247b554
added solution
UmiKami Aug 4, 2022
cb10a77
fixed and cleaned up tests
UmiKami Aug 4, 2022
fdaa2df
changed colors color requirements to orange and dark orange
UmiKami Aug 6, 2022
2a3353c
Update index.html
UmiKami Aug 8, 2022
4328860
Gave user specific colors to use
UmiKami Aug 10, 2022
13991d0
added solution
UmiKami Aug 10, 2022
9bf9768
improved tests and cleaned them up
UmiKami Aug 10, 2022
9aa151e
Updated typo on readme code
UmiKami Aug 16, 2022
7c58c65
Some solutions and tests modified
tommygonzaleza Sep 1, 2022
e93d52b
reversed file to original state
UmiKami Sep 2, 2022
92519aa
Added regex to check for important flag
UmiKami Sep 5, 2022
d560a45
improved exercises
UmiKami Sep 6, 2022
854e016
improved instructions and provided additional documentation on object…
UmiKami Sep 6, 2022
3047ec2
deleted unnecessary tests, added tests to check for actual solution, …
UmiKami Sep 6, 2022
90e5239
Some details added to the tests
tommygonzaleza Sep 12, 2022
b68df77
Merge branch 'master' into 04.3-id-Selector-to-13-Anchor-Like-Button
tommygonzaleza Sep 12, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions exercises/04.3-id-Selector/solution.hide.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="./styles.css" />
<title>
04.3 ID selector
</title>
</head>

<body>
<span id="button1">I should look like a button</span>
</body>
</html>
37 changes: 37 additions & 0 deletions exercises/04.3-id-Selector/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const fs = require('fs');
const path = require('path');
const html = fs.readFileSync(path.resolve(__dirname, './index.html'), 'utf8');
document.documentElement.innerHTML = html.toString();

jest.dontMock('fs');

const span = document.querySelector("span");
const link = document.querySelector("link");

test("There should be a span tag", () => {
expect(span).toBeTruthy()
});

test("The span tag should have id 'button1'", () => {
expect(span).toBeTruthy();
let id = span.id
expect(id).toBeTruthy();
expect(id).toBe('button1');
});

test("The span tag should not contain any inline style", () => {
let emptyBodyInlineStyle = {};
expect(span).toBeTruthy()
expect(span.style._values).toEqual(emptyBodyInlineStyle);
});

test("You should not change the existing head tag elements", () => {
let head = document.querySelector('head');
expect(head).toBeTruthy();

let meta = head.querySelector("meta");
expect(meta).toBe(null);

const href = link.getAttribute("href");
expect(href).toBe('./styles.css');
});
2 changes: 1 addition & 1 deletion exercises/05-Specificity/README.es.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Se trata del nivel de especificidad. Si especificas que tu `div` con `id="thirdi

## 📝 Instrucciones:

1. Anula el color de fondo (`background-color`) de `#thirditem` sin eliminar ningún código CSS, simplemente agrega al CSS una regla más específica al final del documento para anular el color de fondo a verde.
1. Anula el color de fondo (`background`) de `#thirditem` sin eliminar ningún código CSS, simplemente agrega al CSS una regla más específica al final del documento para anular el color de fondo a verde.

## 💡 Pista:

Expand Down
2 changes: 1 addition & 1 deletion exercises/05-Specificity/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ It's all about the level of Specificity. If you specify that your `div` with `id

## 📝 Instrucciones:

1. Override the `background-color` of `#thirditem` without deleting any css code, simply append to the css a more specific rule at the end of the document to override the background-color to green.
1. Override the `background` of `#thirditem` without deleting any css code, simply append to the css a more specific rule at the end of the document to override the background-color to green.


### 💡 Hint:
Expand Down
11 changes: 11 additions & 0 deletions exercises/05-Specificity/solution.hide.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
ul li {
background: blue;
}

#thirditem {
background: yellow;
}
/****** DON NOT EDIT ANYTHING ABOVE THIS LINE ****/
#thirditem {
background: green !important;
}
7 changes: 3 additions & 4 deletions exercises/05-Specificity/styles.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
ul li{
ul li {
background: blue;
}

#thirditem{
#thirditem {
background: yellow;
}
}
/****** DON NOT EDIT ANYTHING ABOVE THIS LINE ****/

61 changes: 25 additions & 36 deletions exercises/05-Specificity/tests.js
Original file line number Diff line number Diff line change
@@ -1,61 +1,50 @@
const fs=require("fs");
const path=require("path");
const html=fs.readFileSync(path.resolve(__dirname, "./index.html"), "utf8");
const css=fs.readFileSync(path.resolve(__dirname, "./styles.css"), "utf8");
const fs = require('fs');
const path = require('path');
const html = fs.readFileSync(path.resolve(__dirname, './index.html'), 'utf8');
const css = fs.readFileSync(path.resolve(__dirname, "./styles.css"), "utf8");
document.documentElement.innerHTML = html.toString();

jest.dontMock("fs");
jest.dontMock('fs');

describe("All the styles should be applied", function () {
beforeEach(() => {
//here I import the HTML into the document
document.documentElement.innerHTML=html.toString();

});
afterEach(() => {
jest.resetModules();
});


it("You should not change the existing head tag elements", function () {
test("You should not change the existing head tag elements", function () {
let head = document.querySelector('head')
expect(head).toBeTruthy()

let meta = head.querySelector("meta")
expect(meta).not.toBe(null)

const pathname = new URL(document.querySelector('link').href).pathname
expect(pathname).toBe('/styles.css')

let title = head.querySelector('title')
expect(title).not.toBe(null)
})
it("You should not delete or edit the existing code", function () {

document.querySelector(
"head"
).innerHTML=`<style>${css.toString()}</style>`;
let cssArray=document.styleSheets[0].cssRules[0].selectorText;
// console.log("cssArray:",cssArray)
let cssArrayBackground= document.styleSheets[0].cssRules[0].style.background
console.log("back:",cssArrayBackground)
let thirdItSelector=document.styleSheets[0].cssRules[1].selectorText;
let thirdItBackground = document.styleSheets[0].cssRules[1].style.background
test("You should not delete or edit the existing code", function () {
document.querySelector("head").innerHTML = `<style>${css.toString()}</style>`;

let cssArray = document.styleSheets[0].cssRules[0].selectorText;
let cssArrayBackground = document.styleSheets[0].cssRules[0].style.background;
let thirdItSelector = document.styleSheets[0].cssRules[1].selectorText;
let thirdItBackground = document.styleSheets[0].cssRules[1].style.background;

expect(thirdItSelector).toBe("#thirditem");
expect(thirdItBackground).toBe("yellow");
expect(cssArray).toBe("ul li");
expect(cssArrayBackground).toBe("blue");
})
it("You should use a more specific rule using the !important annotation ", function () {
test("You should use a more specific rule using the !important annotation ", function () {

document.querySelector(
"head"
).innerHTML=`<style>${css.toString()}</style>`;
let cssArray=document.styleSheets[0].cssRules;
// console.log("NEW", cssArray[2].style._importants)
let orangeHoverSelector="";
for (let i=0; i<cssArray.length; i++) {
if (cssArray[i].selectorText==="#thirditem"&&cssArray[i].style._importants.background==="important") {
orangeHoverSelector=cssArray[i].style.background;
).innerHTML = `<style>${css.toString()}</style>`;
let cssArray = document.styleSheets[0].cssRules;
let orangeHoverSelector = "";
for (let i = 0; i < cssArray.length; i++) {
if (cssArray[i].selectorText === "#thirditem" && cssArray[i].style._importants.background === "important") {
orangeHoverSelector = cssArray[i].style.background;
}
}

Expand Down
8 changes: 4 additions & 4 deletions exercises/06-Practicing-Rules/README.es.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@

1. Establece esta URL como la imagen de fondo de la página y repítela solo verticalmente: `../../.learn/assets/background-vertical.jpg?raw=true`

2. Cambia el tipo de fuente (`font-type`) del `h1` a `Courier` y el resto del sitio web a `Times New Roman`.
2. Cambia el tipo de fuente (`font-family`) del `h1` a `Courier` y el resto del sitio web a `Times New Roman`.

3. Cambia el color del `h1` a rojo(`red`).

4. Haz todos los `h2` tengan subrayado.

5. Centra el `h1`.
5. Agrega un `left padding` a todo el documento de `20px` para que sea más fácil de leer.

6. Agrega un `left padding` a todo el documento de `20px` para que sea más fácil de leer.
6. Agrega un fondo blanco semitransparente (`semi-transparent background 0.2`) al primer párrafo de "3 reasons you know you are learning" para que sea más fácil de leer (tienes que usar `rgba` para esto).

7. Agrega un fondo blanco semitransparente (`semi-transparent background 0.2`) al primer párrafo de "3 reasons you know you are learning" para que sea más fácil de leer (tienes que usar `rgba` para esto), y luego aplica un `padding` de `5px` a todos los lados de ese párrafo.
7. Luego aplica un `padding` de `5px` a todos los lados de ese párrafo.

8. Cambia el color del `anchor` "hover" a verde (`green`) y elimina el subrayado (tienes que colocar el anchor para probarlo).

Expand Down
8 changes: 4 additions & 4 deletions exercises/06-Practicing-Rules/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ tutorial: "https://www.youtube.com/watch?v=4wguurrl-lU"

1. Set this URL as the background image of the page, and repeat it vertically only: `../../.learn/assets/background-vertical.jpg?raw=true`

2. Change the font-type of the `h1` to `Courier` and the rest of the website to `Times new Roman`.
2. Change the font-family of the `h1` to `Courier` and the rest of the website to `Times new Roman`.

3. Change the color of `h1` to `red`.

4. Make all the `h2's` with an `underline`.

5. Center the `h1` to the middle.
5. Add a `left padding` to the whole document of `20px` to make it easier to read.

6. Add a `left padding` to the whole document of `20px` to make it easier to read.
6. Add a white `semi-transparent background (0.2)` to the `first paragraph` to make it easier to read (you have tu use `rgba` for that) and write down "3 reasons you know you are learning".

7. Add a white `semi-transparent background (0.2)` to the `first paragraph` to make it easier to read (you have tu use `rgba` for that) and write down "3 reasons you know you are learning". Then apply a `padding` of `5px` to all sides of that paragraph.
7. Then apply a `padding` of `5px` to all sides of that paragraph.

8. Change the `anchor` "hover" color to `green` and remove the underline (you have to actually hover the anchor to test it).

Expand Down
46 changes: 23 additions & 23 deletions exercises/06-Practicing-Rules/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@
</head>

<body>
<h1>The learning essay</h1>
<h2>3 reasons you know you are learning</h2>
<p id="id1">
We are going to explain in this pharagraph the 3 most comon signs that you should look into yourself to recognize if you are learning.
</p>
<ol>
<li>You are able to complete the exercises by yourself.</li>
<li>You understand what the teacher is talking about</li>
<li>Your are able to have conversations about the topic</li>
</ol>
<h2>3 reasons you know love what you are learning</h2>
<ul>
<li>Time passes fast.</li>
<li>
You are anxious to finish this excercise and start the next one.
</li>
<li>Is 12am and you don't want to go to sleep.</li>
</ul>
<p>
If you can't sleep, what better than watching videos of cats?
<a href="https://www.youtube.com/watch?v=WEgWMOzQ8IE">click here</a>
</p>
<div style="width: 640px">
<h1>The learning essay</h1>
<h2>3 reasons you know you are learning</h2>
<p id="id1">
We are going to explain in this pharagraph the 3 most comon signs that you should look into yourself to recognize if you are learning.
</p>
<ol>
<li>You are able to complete the exercises by yourself.</li>
<li>You understand what the teacher is talking about</li>
<li>Your are able to have conversations about the topic</li>
</ol>
<h2>3 reasons you know love what you are learning</h2>
<ul>
<li>Time passes fast.</li>
<li>You are anxious to finish this excercise and start the next one.</li>
<li>Is 12am and you don't want to go to sleep.</li>
</ul>
<p>
If you can't sleep, what better than watching videos of cats?
<a href="https://www.youtube.com/watch?v=WEgWMOzQ8IE">click here</a>
</p>
</div>
</body>
</html>
</html>
25 changes: 25 additions & 0 deletions exercises/06-Practicing-Rules/solution.hide.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* add your styles here */
body {
background: url("../../.learn/assets/background-vertical.jpg?raw=true") repeat-y;
font-family: "Times New Roman";
padding-left: 20px;
}

#id1 {
background: rgba(255, 255, 255, 0.2);
padding: 5px;
}

h1 {
font-family: "Courier";
color: red;
}

h2 {
text-decoration: underline;
}

a:hover {
color: green;
text-decoration: none;
}
2 changes: 1 addition & 1 deletion exercises/06-Practicing-Rules/styles.css
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/* add your styles here */
/* add your styles here */
Loading