diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..fa719874 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,35 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/javascript-node +{ + "name": "Node.js", + // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile + "image": "mcr.microsoft.com/devcontainers/javascript-node:0-16", + "customizations": { + "vscode": { + "settings": { + "editor.defaultFormatter": "esbenp.prettier-vscode", + "workbench.editorAssociations": { + "*.md": "vscode.markdown.preview.editor" + } + }, + "extensions": ["learn-pack.learnpack-vscode"] + } + }, + + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + "onCreateCommand": "npm i jest@24.8.0 -g && npm i @learnpack/learnpack@2.1.26 -g && learnpack plugins:install learnpack-html@0.0.20" + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "yarn install", + + // Configure tool-specific properties. + // "customizations": {}, + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} diff --git a/.github/workflows/learnpack-audit.yml b/.github/workflows/learnpack-audit.yml new file mode 100644 index 00000000..52644d89 --- /dev/null +++ b/.github/workflows/learnpack-audit.yml @@ -0,0 +1,29 @@ +# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions + +name: Learnpack audit + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [14.x] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node-version }} + - run: npm install @learnpack/learnpack@latest -g + - run: learnpack audit \ No newline at end of file diff --git a/.gitignore b/.gitignore index 8f255a69..b54a1f9f 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,8 @@ !bc.json !learn.json !README.md +!README.es.md +!.vscode !/exercises !/exercises/* diff --git a/.gitpod.Dockerfile b/.gitpod.Dockerfile index 31389fd0..c303edbf 100644 --- a/.gitpod.Dockerfile +++ b/.gitpod.Dockerfile @@ -4,4 +4,4 @@ FROM gitpod/workspace-full:latest USER gitpod RUN npm i jest@24.8.0 -g -RUN npm i learnpack@0.0.88 -g && learnpack plugins:install learnpack-html@0.0.17 +RUN npm i @learnpack/learnpack@2.1.26 -g && learnpack plugins:install learnpack-html@0.0.20 diff --git a/.gitpod.yml b/.gitpod.yml index c83d6cc1..fbb44ce0 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -4,9 +4,13 @@ image: ports: - port: 3000 - onOpen: open-preview -tasks: - - command: learnpack start --disableGrading; + onOpen: ignore + +vscode: + extensions: + - learn-pack.learnpack-vscode + + github: prebuilds: # enable for the master/default branch (defaults to true) diff --git a/.learn/assets/4geeks-icon-blue.png b/.learn/assets/4geeks-icon-blue.png new file mode 100644 index 00000000..6dbdabee Binary files /dev/null and b/.learn/assets/4geeks-icon-blue.png differ diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..2f5ad94d --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,8 @@ +{ + "files.autoSave": "afterDelay", + "files.autoSaveDelay": 700, + "editor.minimap.enabled": false, + "workbench.editorAssociations": { + "*.md": "vscode.markdown.preview.editor" + } +} \ No newline at end of file diff --git a/README.es.md b/README.es.md new file mode 100644 index 00000000..77217f4a --- /dev/null +++ b/README.es.md @@ -0,0 +1,100 @@ +# Tutorial de Ejercicios de CSS de 4Geeks Academy + + + + + + +
+ + + follow on Twitter + +
+ +¡Hola! Soy [Alejandro Sanchez @alesanchezr](https://github.com/alesanchezr), ¡muy emocionado de tenerte aquí! 🎉 😂 Aprender a programar es difícil, ¡necesitas entrenamiento! [Envíame un DM en Twitter](https://twitter.com/alesanchezr) si tienes alguna pregunta. + + +## En este tutorial aprenderás los siguientes conceptos: + +1. Cómo aplicar CSS a su sitio web de 3 maneras diferentes: en línea, agrupándolos dentro de una etiqueta ` -Click me to open google.com -``` - -Tenemos un enlace de HTML `` que lleva a las personas a google.com cuando se hace clic. -Usamos CSS para selectionar todas las etiquetas `` y luego hacerlas `pink`. - -## 📝 Instrucciones - -Pega este código en tu sitio web para ver los resultados. - -## 💻 Preview - -Debería verse así: - -![01 Hello World Exercise Preview](https://ucarecdn.com/7e9496c0-549a-4767-b771-13b9bfc5d9c2/) \ No newline at end of file diff --git a/exercises/01-Hello-World/README.md b/exercises/01-Hello-World/README.md deleted file mode 100644 index 50db2a76..00000000 --- a/exercises/01-Hello-World/README.md +++ /dev/null @@ -1,37 +0,0 @@ ---- -tutorial: "https://www.youtube.com/watch?v=rbtHLA813pU" ---- -# `01` Hello World in CSS - -CSS is about styles. To apply styles you always have to follow this steps: - -1. Read the HTML and pick in your mind what element you want to decorate or apply styles to. -1. Programatically select the element you want to style using CSS Selectors. -2. Write the styling that you want by using CSS rules. - -That is it! The rest is just semantics! 😁 - -Look at this example: - -```HTML - -Click me to open google.com -``` - -We have an HTML anchor `` that takes people to google.com when clicked. -We use CSS to tell (selected) all the anchor tags and make then pink. - -## 📝 Instructions - -Paste this code on your website to see the results. - -## 💻 Preview - -It should look like this: - -![01 Hello World Exercise Preview](https://github.com/4GeeksAcademy/css-tutorial-exercises-course/blob/master/.learn/assets/01-1.png?raw=true) diff --git a/exercises/01-Hello-World/index.html b/exercises/01-Hello-World/index.html deleted file mode 100644 index 03ae0584..00000000 --- a/exercises/01-Hello-World/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/exercises/01-Style-tag/README.es.md b/exercises/01-Style-tag/README.es.md new file mode 100644 index 00000000..d356ddaf --- /dev/null +++ b/exercises/01-Style-tag/README.es.md @@ -0,0 +1,36 @@ + +# `01` Hello World in CSS + +CSS trata sobre estilos (styles). Para aplicar estilos, siempre debes seguir estos pasos: + +1. Lee el HTML y elige qué elemento deseas decorar o aplicarle estilos. + +2. Programáticamente selecciona el elemento que deseas decorar con los selectores de CSS. + +3. Escribe el estilo que quieras usando las reglas CSS. + +¡Eso es todo! El resto es solo semántica. 😁 + +Mira este ejemplo: + +```html + +Click me to open google.com +``` + +Tenemos un enlace de HTML `` que lleva a las personas a google.com cuando se hace clic. +Usamos CSS para seleccionar todas las etiquetas `` y luego hacerlas `pink`. + +## 📝 Instrucciones + +1. Pega este código en tu sitio web para ver los resultados. + +## 💻 Vista previa: + +Debería verse así: + +![01 Hello World Exercise Preview](../../.learn/assets/01-1.png?raw=true) diff --git a/exercises/01-Style-tag/README.md b/exercises/01-Style-tag/README.md new file mode 100644 index 00000000..d146fc05 --- /dev/null +++ b/exercises/01-Style-tag/README.md @@ -0,0 +1,38 @@ +--- +tutorial: "https://www.youtube.com/watch?v=rbtHLA813pU" +--- +# `01` Hello World in CSS + +CSS is about styles. To apply styles you always have to follow these steps: + +1. Read the HTML and pick what element (tag) you want to decorate or apply styles to. + +2. Programmatically select the element you want to style using [CSS Selectors](https://4geeks.com/lesson/what-is-css-learn-css#wait-what-is-a-selector). + +3. Write the styling that you want by using [CSS property rules](https://4geeks.com/lesson/what-is-css-learn-css#properties). + +That is it! The rest is just semantics! 😁 + +Look at this example: + +```html + +Click me to open google.com +``` + +We have an HTML anchor `` that takes people to google.com when clicked. +We use CSS to select all the anchor tags and make them pink. + +## 📝 Instructions: + +1. Paste this code on your website to see the results. + +## 💻 Preview: + +It should look like this: + +![01 Hello World Exercise Preview](../../.learn/assets/01-1.png?raw=true) diff --git a/exercises/01-Style-tag/index.html b/exercises/01-Style-tag/index.html new file mode 100644 index 00000000..93d4ce1c --- /dev/null +++ b/exercises/01-Style-tag/index.html @@ -0,0 +1 @@ + diff --git a/exercises/01-Style-tag/solution.hide.html b/exercises/01-Style-tag/solution.hide.html new file mode 100644 index 00000000..b2ad5b0e --- /dev/null +++ b/exercises/01-Style-tag/solution.hide.html @@ -0,0 +1,7 @@ + + +Click me to open google.com diff --git a/exercises/01-Style-tag/test.js b/exercises/01-Style-tag/test.js new file mode 100644 index 00000000..479b0469 --- /dev/null +++ b/exercises/01-Style-tag/test.js @@ -0,0 +1,34 @@ +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 a = document.querySelector("a"); + +test("There should be an anchor tag", ()=>{ + expect(a).toBeTruthy() +}) + +test("The anchor tag should be pink", ()=>{ + let styles = window.getComputedStyle(a); + expect(styles["color"]).toBe("pink"); +}); + +test("There should be a href attribute pointing to 'https://google.com'", ()=>{ + let href = a.getAttribute('href'); + expect(href).toBeTruthy(); + expect(href).toBe("https://google.com"); +}) + +test("There should be a target attribute pointing to '_blank'", ()=>{ + let target = a.getAttribute('target'); + expect(target).toBeTruthy(); + expect(target).toBe("_blank"); +}) + +test("The anchor tag should not contain any inline style", ()=>{ + let emptyBodyInlineStyle = {}; + expect(a.style._values).toEqual(emptyBodyInlineStyle); +}); diff --git a/exercises/01.1-Add-a-style-tag/README.es.md b/exercises/01.1-Add-a-style-tag/README.es.md new file mode 100644 index 00000000..c69508dd --- /dev/null +++ b/exercises/01.1-Add-a-style-tag/README.es.md @@ -0,0 +1,21 @@ + +# `01.1` The Style Tag + +Si quieres añadir estilos a tu sitio web escribiendo CSS siempre debes hacerlo dentro de una etiqueta ` +``` + +## 📝 Instrucciones: + +1. Añade una etiqueta ` +``` + +## 📝 Instructions + +1. Add a ` +

+ 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. +

diff --git a/exercises/01.1-Add-a-style-tag/test.js b/exercises/01.1-Add-a-style-tag/test.js new file mode 100644 index 00000000..0b3c714b --- /dev/null +++ b/exercises/01.1-Add-a-style-tag/test.js @@ -0,0 +1,22 @@ +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 p = document.querySelector("p"); + +test("There should be a

tag", ()=>{ + expect(p).toBeTruthy(); +}) + +test("The

tag color should be blue", ()=>{ + let styles = window.getComputedStyle(p); + expect(styles["color"]).toBe("blue"); +}); + +test("The

tag should not contain any inline style", ()=>{ + let emptyBodyInlineStyle = {}; + expect(p.style._values).toEqual(emptyBodyInlineStyle); +}); diff --git a/exercises/01.1-The-Style-Tag/README.es.md b/exercises/01.1-The-Style-Tag/README.es.md deleted file mode 100644 index 9f6a1023..00000000 --- a/exercises/01.1-The-Style-Tag/README.es.md +++ /dev/null @@ -1,20 +0,0 @@ - -# `01.1` Etiqueta Style - -Si quieres añadir estilos a tu sitio web escribiendo CSS siempre debes hacerlo dentro de una etiqueta ` -``` - -## 📝 Instruccciones -Añade una etiqueta ` -``` - -## 📝 Instructions - -Add a ` + + + Hello! I am an anchor in red, change my color to yellow + + diff --git a/exercises/01.2-RGBA-colors/tests.js b/exercises/01.2-RGBA-colors/tests.js new file mode 100644 index 00000000..32bf609b --- /dev/null +++ b/exercises/01.2-RGBA-colors/tests.js @@ -0,0 +1,34 @@ +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'); + +describe("All the styles should be applied", ()=>{ + const a = document.querySelector("a"); + + test("The anchor tag should be yellow", ()=>{ + let styles = window.getComputedStyle(a); + expect(styles["color"]).toBe("yellow"); + }); + + test("The tag should not contain any inline style", ()=>{ + let bodyInlineStyle = document.getElementsByTagName("body"); + let emptyBodyInlineStyle = {}; + expect(bodyInlineStyle[0].style._values).toEqual(emptyBodyInlineStyle); + }); + + test("The anchor tag should not contain any inline style", ()=>{ + let emptyBodyInlineStyle = {}; + expect(a.style._values).toEqual(emptyBodyInlineStyle); + }); + + test("You should not change the existing tag elements", ()=>{ + let head = document.querySelector('head') + expect(head).toBeTruthy() + + let meta = head.querySelector("meta") + expect(meta).toBe(null) + }) +}); diff --git a/exercises/01.2-Your-First-Style/README.es.md b/exercises/01.2-Your-First-Style/README.es.md deleted file mode 100644 index b1c7613c..00000000 --- a/exercises/01.2-Your-First-Style/README.es.md +++ /dev/null @@ -1,16 +0,0 @@ -# `01.2` Tu Primer Estilo - -Cuando usas CSS, la idea es aplicar `reglas css` a tus` elementos html`, siempre debes seleccionar primero el elemento y luego especificar qué reglas deseas aplicarle: - -Por ejemplo, este es el código si quiero que todos los anchors de mi sitio web (etiquetas ``) sean azules (blue): - -```css -a { - color: blue; -} -``` - -## 📝 Instrucciones: - -1. En este momento, se está aplicando un estilo que se encarga de hacer el enlace rojo (red). -2. Cambia el estilo para que tu enlace se vea amarillo (yellow). diff --git a/exercises/01.2-Your-First-Style/README.md b/exercises/01.2-Your-First-Style/README.md deleted file mode 100644 index 1e006510..00000000 --- a/exercises/01.2-Your-First-Style/README.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -tutorial: "https://www.youtube.com/watch?v=8b12AFC6bWs" ---- - -# `01.2` Your First Style - -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: - -For example, this is the code if I want to make all my website anchors (` tag's`) blue: - -```css -a { - color: blue; -} -``` - -## 📝 Instructions: - -1. Right now there is a style being applied that is responsable of making the anchor red. -2. Change the style to make your anchor look yellow. diff --git a/exercises/01.2-Your-First-Style/tests.js b/exercises/01.2-Your-First-Style/tests.js deleted file mode 100644 index 8c42761d..00000000 --- a/exercises/01.2-Your-First-Style/tests.js +++ /dev/null @@ -1,38 +0,0 @@ -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"); - -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("The background should be blue", function() { - const body = document.querySelector("body"); - var styles = window.getComputedStyle(body); - expect(styles["background"]).toBe("blue"); - }); - it("The body tag should not contains any inline style", function() { - let bodyInlineStyle = document.getElementsByTagName("body"); - let emptyBodyInlineStyle = {}; - expect(bodyInlineStyle[0].style._values).toEqual(emptyBodyInlineStyle); - // console.log(bodyInlineStyle[0].style._values.background); - }); - it("You should not change the existing head tag elements", function () { - - let meta1 = document.getElementsByTagName('head')[0].innerHTML.toString().indexOf("`) sean azules: +Por ejemplo, este es el código si quiero que todos los anchors de mi sitio web (etiquetas ``) sean azules: ```css a { @@ -13,4 +13,5 @@ a { ## 📝 Instrucciones: 1. Haz que el fondo de tu sitio web sea azul (blue) seleccionando el `body` y aplicando la regla `background` con valor `blue`. -2. Compila y muestra una vista previa del ejercicio y tu resultado debe ser un body azul en la página (toda la página azul). + +2. Compila y muestra una vista previa del ejercicio y tu resultado debe ser un `body` azul (`blue`), es decir, toda la página azul. diff --git a/exercises/01.3-Your-Second-Style/README.md b/exercises/01.3-Your-Second-Style/README.md index fea640b4..74f39c93 100644 --- a/exercises/01.3-Your-Second-Style/README.md +++ b/exercises/01.3-Your-Second-Style/README.md @@ -6,7 +6,7 @@ tutorial: "https://www.youtube.com/watch?v=W0CAqLIAoZI" 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: -For example, this is the code if I want to make all my website anchors (` tag's`) blue: +For example, this is the code if you want to make all your website anchors (`` tags) blue: ```css a { @@ -17,4 +17,5 @@ a { ## 📝 Instructions: 1. Make your website background blue by selecting the `body` and applying the `background` rule with a `blue` value. -2. Build and preview the exercise and your result should be a blue body of the page (the whole page blue). + +2. Build and preview the exercise and your result should be a blue `body` (the whole page blue). diff --git a/exercises/01.3-Your-Second-Style/solution.hide.html b/exercises/01.3-Your-Second-Style/solution.hide.html new file mode 100644 index 00000000..9b239409 --- /dev/null +++ b/exercises/01.3-Your-Second-Style/solution.hide.html @@ -0,0 +1,14 @@ + + + + + + + Hello! My background should be blue! + + diff --git a/exercises/01.3-Your-Second-Style/tests.js b/exercises/01.3-Your-Second-Style/tests.js index 8c42761d..8b52f01d 100644 --- a/exercises/01.3-Your-Second-Style/tests.js +++ b/exercises/01.3-Your-Second-Style/tests.js @@ -1,38 +1,28 @@ -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'); +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(); - }); +describe("All the styles should be applied", ()=>{ + const body = document.querySelector("body"); - it("The background should be blue", function() { - const body = document.querySelector("body"); - var styles = window.getComputedStyle(body); + test("The background should be blue", ()=>{ + let styles = window.getComputedStyle(body); expect(styles["background"]).toBe("blue"); }); - it("The body tag should not contains any inline style", function() { - let bodyInlineStyle = document.getElementsByTagName("body"); + + test("The body tag should not contain any inline style", ()=>{ let emptyBodyInlineStyle = {}; - expect(bodyInlineStyle[0].style._values).toEqual(emptyBodyInlineStyle); - // console.log(bodyInlineStyle[0].style._values.background); + expect(body.style._values).toEqual(emptyBodyInlineStyle); }); - it("You should not change the existing head tag elements", function () { - - let meta1 = document.getElementsByTagName('head')[0].innerHTML.toString().indexOf("{ + let head = document.querySelector('head') + expect(head).toBeTruthy() + + let meta = head.querySelector("meta") + expect(meta).toBe(null) }) }); diff --git a/exercises/02-Separate-Stylesheet/README.es.md b/exercises/02-Separate-Stylesheet/README.es.md index 88208dea..d0e74a41 100644 --- a/exercises/02-Separate-Stylesheet/README.es.md +++ b/exercises/02-Separate-Stylesheet/README.es.md @@ -1,16 +1,15 @@ -# `02` Hoja de estilos separada +# `02` Separate Stylesheet Si usas la etiqueta html ``, puedes tener tus estilos en un archivo separado que normalmente se llama `styles.css`. -Esa es una práctica aún mejor porque te permite tener un sitio web a quien no le importe el diseño, puedes cambiar el CSS después y hacer que tu sitio web se vea 100% diferente, pero teniendo exactamente el mismo HTML. +Esa es una mejor práctica porque te permite tener un sitio web sin diseño, puedes cambiar el CSS después y hacer que tu sitio web se vea 100% diferente, pero teniendo exactamente el mismo HTML. ## 📝 Instrucciones: -LLena el `styles.css` con el contenido necesario para que el body del sitio web azul (blue). - +Llena el `styles.css` con el contenido necesario para que el `body` del sitio web sea azul (blue). ## 💡 Pista: -Busca en Google cómo cambiar el color de fondo (background) de un body de un sitio web. ++ Busca en Google cómo cambiar el color de fondo (`background-color`) del `body` de un sitio web. - \ No newline at end of file + diff --git a/exercises/02-Separate-Stylesheet/README.md b/exercises/02-Separate-Stylesheet/README.md index 24fc0c6a..7c4637c1 100644 --- a/exercises/02-Separate-Stylesheet/README.md +++ b/exercises/02-Separate-Stylesheet/README.md @@ -4,14 +4,14 @@ tutorial: "https://www.youtube.com/watch?v=T0anCc5fvSg" # `02` Separate Stylesheet -If you use the html `` tag, you can also have your styles on a separate file that we normally call `styles.css`. +If you use the html `` tag, you can also have your styles on a separate file that we usually call `styles.css`. -That is an event better practice because it lets you have an CSS agnostic website, you can change the CSS later and make the website look 100% different, but still have the same exact HTML. +That is an even better practice because it lets you have a CSS agnostic website, you can change the CSS later and make the website look 100% different, but still have the same exact HTML. ## 📝 Instructions: -Fill the `styles.css` with the content needed to make the website body blue. +Fill the `styles.css` with the content needed to make the website's `body` blue. -## 💡Hint: +## 💡 Hint: -Google how to change the background color of a website body. ++ Google how to change the `background-color` of a website's `body`. diff --git a/exercises/02-Separate-Stylesheet/solution.hide.css b/exercises/02-Separate-Stylesheet/solution.hide.css new file mode 100644 index 00000000..5250e305 --- /dev/null +++ b/exercises/02-Separate-Stylesheet/solution.hide.css @@ -0,0 +1,7 @@ +/* your styles here: + 1. Select the body tag. + 2. Add the background rule equal to blue. + */ +body { + background: blue; +} diff --git a/exercises/02-Separate-Stylesheet/tests.js b/exercises/02-Separate-Stylesheet/tests.js index 2e3da762..2a46c829 100644 --- a/exercises/02-Separate-Stylesheet/tests.js +++ b/exercises/02-Separate-Stylesheet/tests.js @@ -1,66 +1,34 @@ const fs=require("fs"); const path=require("path"); -const html=fs.readFileSync(path.resolve(__dirname, "./index.html"), "utf8"); +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"); -describe("All the styles should be applied", function () { - beforeEach(() => { - //here I import the HTML into the document - document.documentElement.innerHTML=html.toString(); +describe("All the styles should be applied", ()=>{ + const link = document.querySelector("link"); + const body = document.querySelector("body"); - //apply the styles from the stylesheet if needed - - - - }); - afterEach(() => { - jest.resetModules(); - }); - it("The body tag should not contains any inline style", function () { - document.querySelector( - "head" - ).innerHTML=``; - let bodyInlineStyle=document.getElementsByTagName("body"); + test("The tag should not contain any inline style", ()=>{ + document.querySelector("head").innerHTML = ``; let emptyBodyInlineStyle={}; - expect(bodyInlineStyle[0].style._values).toEqual(emptyBodyInlineStyle); - // expect(bodyInlineStyle[0].style._values.background - repeat).toBe( - // undefined - // ); - - console.log(bodyInlineStyle[0].style._values); + expect(body.style._values).toEqual(emptyBodyInlineStyle) }); - it("the background-size should be 'contain' without quotes", function () { - document.querySelector( - "head" - ).innerHTML=``; - // get computed styles of any element you like - const body=document.querySelector("body"); - let styles=window.getComputedStyle(body); - expect(styles["background-size"]).toBe("contain"); + test("You should not change the existing tag elements", ()=>{ + let head = document.querySelector('head') + expect(head).toBeTruthy() + + let meta = head.querySelector("meta") + expect(meta).toBe(null) + + let href = link.getAttribute("href") + expect(href).toEqual('./styles.css') }); - - it("the background-repeat should be 'inherit' without quotes", function () { - document.querySelector( - "head" - ).innerHTML=``; - - const body=document.querySelector("body"); - let styles=window.getComputedStyle(body); - expect(styles["background-repeat"]).toBe("inherit"); - }); - it("You should not change the head tag", function () { - - let meta1 = document.getElementsByTagName('head')[0].innerHTML.toString().indexOf("-1).toBeFalsy(); + + test("Your tag background color should be blue", ()=>{ + let styles = window.getComputedStyle(body) + expect(styles["background-color"]).toBe("blue") }) }); diff --git a/exercises/02.1-Background/README.es.md b/exercises/02.1-Background/README.es.md index 5c728192..561e0451 100644 --- a/exercises/02.1-Background/README.es.md +++ b/exercises/02.1-Background/README.es.md @@ -1,22 +1,27 @@ -# `02.1` Background (fondo) +# `02.1` Background -La regla `background` del CSS nos permite asignar y trabajar con el background de cualquier contenedor (container). Los valores de background pueden ser `color` o una `imagen`. +La regla `background` (fondo) de CSS nos permite asignar y trabajar con el background de cualquier contenedor (container). Los valores de background pueden ser `color` o una `imagen`. -Si es una imagen, puedes especificar si quieres que la imagen se repita horizontalmente, verticalmente, ambas o ninguna, y también puedes especificar si quieres cambiar el tamaño y ajustar su tamaño al contenedor completo, entre otras propiedades eso puede ser modificado. +Si es una imagen, puedes especificar si quieres que la imagen se repita horizontalmente, verticalmente, ambas o ninguna, y también puedes especificar si quieres cambiar el tamaño y ajustar su tamaño al contenedor completo, entre otras propiedades, eso puede modificarse. ## 📝 Instrucciones: -1. Construye el ejercicio. -2. Verifica la vista previa. -3. En el archivo styles.css pon el background-size a 'contain' (verifica la pestaña styles.css) -4. Construye y previsualiza el ejercicio nuevamente. -5. Cambia el background-repeat a 'inherit' para que se repita sobre el eje x y el eje y. -6. Construye y previsualiza el ejercicio nuevamente. +1. Construye el ejercicio. +2. Verifica la vista previa. -## 💡Pista: +3. En el archivo styles.css cambia el `background-size` a `contain` (verifica la pestaña styles.css). + +4. Construye y previsualiza el ejercicio nuevamente. + +5. Cambia el `background-repeat` a `repeat` para que se repita sobre el eje x y el eje y. + +6. Construye y previsualiza el ejercicio nuevamente. + +## 💡 Pista: Google es tu mejor amigo: -- Como usar el background-size: http://lmgtfy.com/?q=css+background-size -- Como usar el background-repeat: http://lmgtfy.com/?q=css+background-repeat +- Recomendamos buscar en google `css background-size` para entender un poco mejor esta propiedad. + +- También recomendamos buscar `css background-repeat` diff --git a/exercises/02.1-Background/README.md b/exercises/02.1-Background/README.md index 383149ad..afbfa795 100644 --- a/exercises/02.1-Background/README.md +++ b/exercises/02.1-Background/README.md @@ -6,22 +6,27 @@ tutorial: "https://www.youtube.com/watch?v=MJI0-sFmTe8" 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`. -If it is an image you can specify if you want the image to repeat horizontally, vertically, both, or not at all, and you can also specify if you want it to resize and fit the whole container where its being applied, among other properties that can be modified. +If it is an image, you can specify if you want the image to be repeated horizontally, vertically, or both, or not at all, and you can also specify if you want it to resize and fit the whole container where it is being applied, among other properties that can be modified. ## 📝 Instructions: 1. Build the exercise. + 2. Check the Preview. -3. On the styles.css file the background-size to 'contain' (check the styles.css tab). + +3. On the styles.css file change the background-size to 'contain' (check the styles.css tab). + 4. Build and Preview the exercise again. -5. Change the background-repeat to 'inherit' to make it repeat over the x axis and y axis. + +5. Change the background-repeat to 'repeat' to make it repeat over the x-axis and y-axis. + 6. Build and Preview the exercise again. -## 💡Hint: +## 💡 Hint: Google is your best friend: -- How to use the background-size: http://lmgtfy.com/?q=css+background-size -- How to use the background-repeat: http://lmgtfy.com/?q=css+background-repeat +- We recommend googling: `css background-size` and reading about it on w3schools or any other websites. +- We also recommend googling about `css background-repeat`. diff --git a/exercises/02.1-Background/index.html b/exercises/02.1-Background/index.html index ce03ce24..cf841f1e 100644 --- a/exercises/02.1-Background/index.html +++ b/exercises/02.1-Background/index.html @@ -5,6 +5,6 @@ 02 Background - My background should be an image with th size "contain" + My background should be an image with the size "contain" diff --git a/exercises/02.1-Background/solution.hide.css b/exercises/02.1-Background/solution.hide.css new file mode 100644 index 00000000..a2c6b305 --- /dev/null +++ b/exercises/02.1-Background/solution.hide.css @@ -0,0 +1,5 @@ +body { + background-image: url(https://4geeksacademy.github.io/exercise-assets/img/bg/small-mosaic.jpg); + background-size: contain; + background-repeat: repeat; +} diff --git a/exercises/02.1-Background/tests.js b/exercises/02.1-Background/tests.js index 2e3da762..b0612a23 100644 --- a/exercises/02.1-Background/tests.js +++ b/exercises/02.1-Background/tests.js @@ -1,66 +1,53 @@ -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"); -describe("All the styles should be applied", function () { - beforeEach(() => { - //here I import the HTML into the document - document.documentElement.innerHTML=html.toString(); - - //apply the styles from the stylesheet if needed - - - - }); - afterEach(() => { - jest.resetModules(); - }); - it("The body tag should not contains any inline style", function () { +describe("All the styles should be applied", ()=>{ + const body = document.querySelector("body"); + const link = document.querySelector("link"); + const title = document.querySelector('title'); + + test("The tag should not contain any inline style", ()=>{ document.querySelector( "head" - ).innerHTML=``; - let bodyInlineStyle=document.getElementsByTagName("body"); - let emptyBodyInlineStyle={}; - expect(bodyInlineStyle[0].style._values).toEqual(emptyBodyInlineStyle); - // expect(bodyInlineStyle[0].style._values.background - repeat).toBe( - // undefined - // ); - - console.log(bodyInlineStyle[0].style._values); + ).innerHTML = ``; + let emptyBodyInlineStyle = {}; + expect(body.style._values).toEqual(emptyBodyInlineStyle); }); - it("the background-size should be 'contain' without quotes", function () { + test("the background-size should be 'contain' without quotes", ()=>{ document.querySelector( "head" - ).innerHTML=``; + ).innerHTML = ``; // get computed styles of any element you like - const body=document.querySelector("body"); - let styles=window.getComputedStyle(body); + let styles = window.getComputedStyle(body); expect(styles["background-size"]).toBe("contain"); }); - it("the background-repeat should be 'inherit' without quotes", function () { + test("the background-repeat should be 'repeat' without quotes", ()=>{ document.querySelector( "head" - ).innerHTML=``; + ).innerHTML = ``; - const body=document.querySelector("body"); - let styles=window.getComputedStyle(body); - expect(styles["background-repeat"]).toBe("inherit"); + let styles = window.getComputedStyle(body); + expect(styles["background-repeat"]).toBe("repeat"); }); - it("You should not change the head tag", function () { + + test("You should not change the existing 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') - let meta1 = document.getElementsByTagName('head')[0].innerHTML.toString().indexOf("-1).toBeFalsy(); + let titleInner = title.innerHTML + expect(titleInner).toBe('02 Background') }) }); diff --git a/exercises/03-Inline-Styles/README.es.md b/exercises/03-Inline-Styles/README.es.md deleted file mode 100644 index addc132b..00000000 --- a/exercises/03-Inline-Styles/README.es.md +++ /dev/null @@ -1,25 +0,0 @@ -# `03` Inline Styles (estilos en la línea) - -Los estilos inline son una muy mala idea a menos que no tengas otra opción (y esa es una situación muy poco común). Lamentablemente, tenemos que enseñarte cómo hacerlo porque existe la posibilidad de que necesites usarlos en algún momento. - -Para usar estilos inline, en lugar de declarar una etiqueta `; + let emptyBodyInlineStyle = {}; + expect(body.style._values).toEqual(emptyBodyInlineStyle) + }); + + test("There should be two

tags", () => { + expect(p.length).toBe(2) + }); + test("Both

tags should have a class name 'b-blue'", () => { + p.forEach(e=>{ + let eClass = e.getAttribute("class"); + expect(eClass).toBe("b-blue") + }) + }); +}); diff --git a/exercises/04.1-Combined-Rules/README.es.md b/exercises/04.1-Combined-Rules/README.es.md index 6bc1fcc9..c116f5cb 100644 --- a/exercises/04.1-Combined-Rules/README.es.md +++ b/exercises/04.1-Combined-Rules/README.es.md @@ -1,8 +1,8 @@ -# `04.1` Reglas Combinadas +# `04.1` Combined Rules Los archivos CSS ocupan espacio en tu servidor y también tardan en descargarse (como todo); es otro documento de texto que el navegador debe descargar antes de mostrar la página, por lo que es importante mantener el documento CSS lo más pequeño posible. -Una forma de hacerlo es combinando varias propiedades en una, como con "border": +Una forma de hacerlo es combinando varias propiedades en una, como con `border`: ```css border-color: black; @@ -16,17 +16,23 @@ Las propiedades de border se pueden consolidar en una sola línea así: border: black 1px solid; ``` -# 📝 Instrucciones: +## 📝 Instrucciones: -1. Combina las 4 reglas de padding una sola utilizando la regla "padding". -2. Combina todas las reglas de background, menos el background size, en una sola línea usando la regla "background:". +1. Combina las 4 reglas de padding en una sola utilizando la regla `padding`. +2. Combina todas las reglas de background en una sola línea usando la regla `background`. +*Las propiedades `background-position` y `background-size` pueden usar el mismo tipo de datos por lo que entrarán en conflicto, así que en vez de separar estas propiedades con un **espacio**, debes separarlas con una barra `/` de esta forma:* -P.S: The background size no se puede combinar, los navegadores aún no lo admiten.\*\* +```css +background: 50px / cover +``` + +Donde el valor de la izquierda de la barra `/` es la propiedad `background-position` y la derecha es el `background-size`. + +## 💡 Pista: -# Hint: +- Cómo usar el background: https://www.w3schools.com/cssref/css3_pr_background.php -- Como usar el background-size: http://lmgtfy.com/?q=css+background -- Como usar el padding: http://lmgtfy.com/?q=css+padding +- Cómo usar el padding: https://www.w3schools.com/css/css_padding.asp diff --git a/exercises/04.1-Combined-Rules/README.md b/exercises/04.1-Combined-Rules/README.md index 8d2deab5..b75e02dd 100644 --- a/exercises/04.1-Combined-Rules/README.md +++ b/exercises/04.1-Combined-Rules/README.md @@ -1,12 +1,8 @@ ---- -tutorial: "https://youtu.be/watch?v=uQS5QeEE-B4" ---- - # `04.1` Combined Rules -CSS files take space on your server and also take time to download (like everything); it is yet another text document that the browser has to download before rendering the page, which is why is important to keep the CSS document as small as possible. +CSS files take up space on your server and also take time to download (like everything); it is yet another text document that the browser has to download before rendering the page, which is why it's important to keep the CSS document as small as possible. -One way to do that is by combining several properties into one such as with "border": +One way to do that is by combining several properties into one, such as with `border`: ```css border-color: black; @@ -14,23 +10,28 @@ border-style: solid; border-width: 1px; ``` -Border's properties can be consolidated into a single line as: +Border's properties can be consolidated into a single line like this: ```css border: black 1px solid; ``` -# 📝 Instructions: +## 📝 Instructions: + +1. Combine the 4 padding rules into only one using the `padding` rule. +2. Combine all background rules into only one using the `background` rule. -1. Combine the 4 padding rules into just one using the "padding" rule. -2. Combine the all background rules, but the background size, into just one line using the "background:" rule. +*The `background-position` and the `background-size` properties will conflict because they can handle the same type of values, so instead of separating these properties with a `space` you must separate them with a forward slash `/` as follows:* +```css +background: 50px / cover +``` +Where the left side value of the forward slash `/` is the `background-position` rule and the right value is the `background-size` rule. -P.S: The background size cannot be combined, the browsers don't support it yet.\*\* +## 💡 Hint: -# Hint: +- How to use the background: https://www.w3schools.com/cssref/css3_pr_background.php -- How to use the background-size: http://lmgtfy.com/?q=css+background -- How to use the padding: http://lmgtfy.com/?q=css+padding +- How to use the padding: https://www.w3schools.com/css/css_padding.asp diff --git a/exercises/04.1-Combined-Rules/index.html b/exercises/04.1-Combined-Rules/index.html index 2af5a24c..1525b6cf 100644 --- a/exercises/04.1-Combined-Rules/index.html +++ b/exercises/04.1-Combined-Rules/index.html @@ -2,9 +2,7 @@ - - 04 Combined Rules - + 04.1 Combined Rules diff --git a/exercises/04.1-Combined-Rules/solution.hide.css b/exercises/04.1-Combined-Rules/solution.hide.css new file mode 100644 index 00000000..fb1bc3ee --- /dev/null +++ b/exercises/04.1-Combined-Rules/solution.hide.css @@ -0,0 +1,9 @@ +.myBox { + width: 50px; + height: 50px; + padding: 10px 190px 50px 30px; + + background: rgb(189, 189, 189) + url(https://github.com/4GeeksAcademy/css-tutorial-exercises-course/blob/3a2d1dd03f58167a5a4894155af2d3aa4d41d647/.learn/assets/baby.jpg?raw=true) + no-repeat 100px / contain; +} diff --git a/exercises/04.1-Combined-Rules/tests.js b/exercises/04.1-Combined-Rules/tests.js index 3971bb19..e325ce5f 100644 --- a/exercises/04.1-Combined-Rules/tests.js +++ b/exercises/04.1-Combined-Rules/tests.js @@ -1,157 +1,109 @@ -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"); -describe("All the styles should be applied", function () { - beforeEach(() => { - //here I import the HTML into the document - document.documentElement.innerHTML=html.toString(); +describe("All the styles should be applied", ()=> { + const body = document.querySelector("body"); + const link = document.querySelector("link"); + const title = document.querySelector('title'); - //apply the styles from the stylesheet if needed - // document.querySelector( - // "head" - // ).innerHTML = ``; - }); - afterEach(() => { - jest.resetModules(); - }); - - // it("The styles.css file should be empty", function () { - // console.log(css); - // expect(css.toString()==="").toBeTruthy(); - // }); - // it("The Head tag should includes a Style tag", function () { - // expect(html.toString().indexOf(`-1).toBeTruthy(); - // }); - it("The body tag should not contains any inline style", function () { + test("The tag should not contain any inline style", ()=> { document.querySelector( "head" - ).innerHTML=``; - let bodyInlineStyle=document.getElementsByTagName("style"); - let emptyBodyInlineStyle={}; - expect(bodyInlineStyle[0].style._values).toEqual(emptyBodyInlineStyle); - console.log("sty: ", bodyInlineStyle[0]); + ).innerHTML = ``; + let emptyBodyInlineStyle = {}; + expect(body.style._values).toEqual(emptyBodyInlineStyle); }); - it("the width should be '50px'", function () { + + test("The width should be '50px'", ()=> { // get computed styles of any element you like document.querySelector( "head" - ).innerHTML=``; + ).innerHTML = ``; - let cssArray=document.styleSheets[0].cssRules; - // console.log("$$$:", cssArray) - let orangeHoverSelector=""; - for (let i=0; i< cssArray.length; i++) { + if (cssArray[i].selectorText === ".myBox") { + orangeHoverSelector = cssArray[i].style.width; } } - expect(orangeHoverSelector).toBe('50px'); + expect(orangeHoverSelector).toBe('50px'); }); - it("the height should be '50px'", function () { + + test("The height should be '50px'", ()=> { // get computed styles of any element you like document.querySelector( "head" - ).innerHTML=``; + ).innerHTML = ``; - let cssArray=document.styleSheets[0].cssRules; - // console.log("$$$:", cssArray) - let orangeHoverSelector=""; - for (let i=0; i< cssArray.length; i++) { + if (cssArray[i].selectorText === ".myBox") { + orangeHoverSelector = cssArray[i].style.height; } } - expect(orangeHoverSelector).toBe('50px'); + expect(orangeHoverSelector).toBe('50px'); }); - // it("the background should be in rgb code rgb(189, 189, 189)", function() { - // // get computed styles of any element you like - // const body = document.querySelector(".myBox"); - // var styles = window.getComputedStyle(body); - // expect(styles["background"]).toBe("rgb(189, 189, 189)"); - // }); - - // it("the padding-top should be deleted", function () { - // // get computed styles of any element you like - // const body=document.querySelector(".myBox"); - // var styles=window.getComputedStyle(body); - // expect(styles["padding-top"]).toBeFalsy(); - // expect(styles["padding-bottom"]).toBeFalsy(); - // expect(styles["padding-right"]).toBeFalsy(); - // expect(styles["padding-left"]).toBeFalsy(); - - // }); - - it("the background-size should be contain", function () { - document.querySelector( - "head" - ).innerHTML=``; - let cssArray=document.styleSheets[0].cssRules; - // console.log("$$$:", cssArray) - let orangeHoverSelector=""; - for (let i=0; i { document.querySelector( "head" - ).innerHTML=``; + ).innerHTML = ``; - let cssArray=document.styleSheets[0].cssRules; - console.log("$$$:", cssArray) - let orangeHoverSelector=""; + let cssArray = document.styleSheets[0].cssRules; + let orangeHoverSelector = ""; let backImg = ""; let backColor = ""; let backPos = ""; let backRepeat = ""; - for (let i=0; i< cssArray.length; i++) { + if (cssArray[i].selectorText === ".myBox") { + orangeHoverSelector = cssArray[i].style.background; + backImg = cssArray[i].style['background-image']; + backColor = cssArray[i].style['background-color']; + backPos = cssArray[i].style['background-position-x']; + backRepeat = cssArray[i].style['background-repeat']; } } expect(backColor).toBeFalsy(); expect(backImg).toBeFalsy(); expect(backPos).toBeFalsy(); expect(backRepeat).toBeFalsy(); - expect(orangeHoverSelector).toContain('#bdbdbd'); + expect(orangeHoverSelector).toContain('rgb(189, 189, 189)'); expect(orangeHoverSelector).toContain('no-repeat'); expect(orangeHoverSelector).toContain('100px'); expect(orangeHoverSelector).toContain('url(https://github.com/4GeeksAcademy/css-tutorial-exercises-course/blob/3a2d1dd03f58167a5a4894155af2d3aa4d41d647/.learn/assets/baby.jpg?raw=true)'); }); - it("the padding should include the shorthand property in the right order (top, right, bottom, left)", function () { + test("The padding should include the shorthand property in the right order (top, right, bottom, left)", ()=> { document.querySelector( "head" - ).innerHTML=``; + ).innerHTML = ``; - let cssArray=document.styleSheets[0].cssRules; + let cssArray = document.styleSheets[0].cssRules; // console.log("$$$:", cssArray) - let orangeHoverSelector=""; - let padTop= ""; - let padRight= ""; - let padBottom= ""; - let padLeft= ""; - for (let i=0; i< cssArray.length; i++) { + if (cssArray[i].selectorText === ".myBox") { + orangeHoverSelector = cssArray[i].style.padding; + padTop = cssArray[i].style['padding-top'] + padRight = cssArray[i].style['padding-right'] + padBottom = cssArray[i].style['padding-bottom'] + padLeft = cssArray[i].style['padding-left'] } } expect(orangeHoverSelector).toBe('10px 190px 50px 30px'); @@ -160,16 +112,17 @@ describe("All the styles should be applied", function () { expect(padBottom).toBeFalsy(); expect(padLeft).toBeFalsy(); }); - it("You should not change the head tag", function () { - - let meta1 = document.getElementsByTagName('head')[0].innerHTML.toString().indexOf("-1).toBeFalsy(); + + test("You should not change the existing 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') + + expect(title).toBeTruthy() }) }); diff --git a/exercises/04.2-Apply-several-classes/README.es.md b/exercises/04.2-Apply-several-classes/README.es.md index 9555b6f3..fc6b5b80 100644 --- a/exercises/04.2-Apply-several-classes/README.es.md +++ b/exercises/04.2-Apply-several-classes/README.es.md @@ -1,21 +1,24 @@ -# `04.2` Aplica varias clases +# `04.2` Apply several classes -Hemos preparado un pequeña hoja de estilos CSS que contiene estilos CSS para replicar cartas de poker. -Vamos a usar clases y aplicarlas al mismo elemento `

`. +Hemos preparado una pequeña hoja de estilos CSS que contiene estilos CSS para replicar cartas de poker. + +Vamos a usar dos clases y aplicarlas al mismo elemento `
`. ```html
9
``` -La clase `card`contiene las reglas de estilo para hacer que el div se vea como una carta: Bordes, ancho, etc. +La clase `card` contiene las reglas de estilo para hacer que el div se vea como una carta: bordes, ancho, alto, etc. + +La clase `spades` contiene las reglas de estilo requeridas para convertir la carta a la pinta de picas (negra con el símbolo de picas). -La clase `spades` contienes las reglas de estilo requeridas para convertir la carta a la pinta de picas (negra con el símbolo de picas). +Hay dos posibles clases de palos/pintas que puedes aplicar al elemento html y hará que se vea como una carta de poker real. -Hay dos posibles clases de pintas que puedes aplicar al elemento html y hará que se vea como una carta de poker real. +## 📝 Instrucciones: -# 📝 Instrucciones: +Reemplaza la propiedad `spades` de la clase del `
` por la clase `heart` y observa los resultados. -Remmplaza la propiedad `spades` de la clase del `
` por la clase `heart` y observa los resultados. +## Resultado: -![Poker Card Heart](https://github.com/4GeeksAcademy/css-tutorial-exercises-course/blob/master/.learn/assets/04.2-1.png?raw=true) +![Poker Card Heart](../../.learn/assets/04.2-1.png?raw=true) diff --git a/exercises/04.2-Apply-several-classes/README.md b/exercises/04.2-Apply-several-classes/README.md index 0a38d6f0..c98cf025 100644 --- a/exercises/04.2-Apply-several-classes/README.md +++ b/exercises/04.2-Apply-several-classes/README.md @@ -6,19 +6,23 @@ tutorial: "https://www.youtube.com/watch?v=da4tJDx48CY" We have prepared a small CSS Stylesheet that contains the CSS styles to replicate poker cards. -We are going to use to classes and apply them to the same `
` element. +We are going to use two classes and apply them to the same `
` element. ```html
9
``` -The class `card` contains the styling rules to make the div look like a card: Borders, Height, Width, etc. +The class `card` contains the styling rules to make the div look like a card: borders, height, width, etc. + The class `spades` contains the styling rules needed to make the card turn into a spades suite (black and with a spades symbol). -There are two possible suite classes you can apply to the html element and it will make it look like a real poker card. +There are two possible suite classes you can apply to the html element to make it look like a real poker card. -# 📝 Instructions: +## 📝 Instructions: Replace the class property `spades` of the `
` with the class `heart` and look at the results. -![Poker Card Heart](https://github.com/4GeeksAcademy/css-tutorial-exercises-course/blob/master/.learn/assets/04.2-1.png?raw=true) + +## Expected result: + +![Poker Card Heart](../../.learn/assets/04.2-1.png?raw=true) diff --git a/exercises/04.2-Apply-several-classes/index.html b/exercises/04.2-Apply-several-classes/index.html index a64723af..3a293815 100644 --- a/exercises/04.2-Apply-several-classes/index.html +++ b/exercises/04.2-Apply-several-classes/index.html @@ -2,9 +2,7 @@ - - 04 Class selector - + 04.2 Apply several classes diff --git a/exercises/04.2-Apply-several-classes/solution.hide.html b/exercises/04.2-Apply-several-classes/solution.hide.html new file mode 100644 index 00000000..95de441b --- /dev/null +++ b/exercises/04.2-Apply-several-classes/solution.hide.html @@ -0,0 +1,11 @@ + + + + + 04.2 Apply several classes + + + +
9
+ + diff --git a/exercises/04.2-Apply-several-classes/styles.css b/exercises/04.2-Apply-several-classes/styles.css index efacee56..9995d367 100644 --- a/exercises/04.2-Apply-several-classes/styles.css +++ b/exercises/04.2-Apply-several-classes/styles.css @@ -1,15 +1,14 @@ .card { - display: inline-block; - width: 50px; - height: 80px; - position: relative; + width: 150px; + height: 240px; border: 1px solid black; text-align: center; - line-height: 80px; + line-height: 240px; border-radius: 5px; + font-size: 1.5rem; } .card:after { - font-size: 70%; + font-size: 80%; font-weight: bold; } diff --git a/exercises/04.2-Apply-several-classes/test.js b/exercises/04.2-Apply-several-classes/test.js new file mode 100644 index 00000000..cb04bc16 --- /dev/null +++ b/exercises/04.2-Apply-several-classes/test.js @@ -0,0 +1,18 @@ +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"); + +describe("You should change the class on the div tag", () => { + const div = document.querySelector("div"); + + test('The
should NOT have the "spades" class', () => { + expect(div.classList.contains("spade")).toBe(false); + }); + + test('The
should have the "heart" class', () => { + expect(div.classList.contains("heart")).toBe(true); + }); +}); diff --git a/exercises/04.3-id-Selector/README.es.md b/exercises/04.3-id-Selector/README.es.md index 30df0b3b..c9e5a36c 100644 --- a/exercises/04.3-id-Selector/README.es.md +++ b/exercises/04.3-id-Selector/README.es.md @@ -1,20 +1,21 @@ -# `04.3` Selector de ID +# `04.3` The ID CSS Selector También puedes seleccionar un elemento por su `#id` y aplicarle estilos. -#### El selector `#id` +## El selector `#id` ```css #small{ font-size: 9px; } ``` -Usa la propiedad id del elemento HTML para seleccionar. Las IDs deberían ser únicas, solo un elemento puede tener la misma ID. -Nota: La etiqueta HTML con `id="my_number_one"` tendrá un font-size de 9px. +Usa la propiedad `id` del elemento HTML para seleccionarlo. Los `id` deben ser únicos, así que no uses el mismo `id` en más de un elemento. -# 📝 Instrucciones: +*La etiqueta HTML con `id="small"` tendrá un font-size de `9px`.* -Añade el id `button1` a la etiqueta `` y compila para ver el resultado en la consola. +## 📝 Instrucciones: + +1. Añade el id `button1` a la etiqueta `` y compila para ver el resultado en la consola. diff --git a/exercises/04.3-id-Selector/README.md b/exercises/04.3-id-Selector/README.md index fd4a6f67..377f6c8c 100644 --- a/exercises/04.3-id-Selector/README.md +++ b/exercises/04.3-id-Selector/README.md @@ -4,18 +4,20 @@ tutorial: "https://www.youtube.com/watch?v=9906LCSQJ8M" # `04.3` The ID CSS Selector -You can also select an element by `#id` and apply stiles to it. +You can also select an element by `#id` and apply styles to it. -#### The `#id` selector +## The `#id` selector ```css #small{ font-size: 9px; } ``` -Use the id property of the HTML element to select it. IDs should be unique, only one element must have the same ID. -Note: The html tag with the `id="my_number_one"` will have a font-size of 9px. -# 📝 Instructions: +Use the `id` property of the HTML element to select it. `ids` should be unique, don't use the same `id` on more than one element. -Add the id `button1` on to the `` tag and compile to check the result on the console. +*The HTML tag with the `id="small"` will have a font-size of `9px`.* + +## 📝 Instructions: + +1. Add the id `button1` on to the `` tag and compile to check the result on the console. diff --git a/exercises/04.3-id-Selector/solution.hide.html b/exercises/04.3-id-Selector/solution.hide.html new file mode 100644 index 00000000..a7964559 --- /dev/null +++ b/exercises/04.3-id-Selector/solution.hide.html @@ -0,0 +1,13 @@ + + + + + + 04.3 ID selector + + + + + I should look like a button + + diff --git a/exercises/04.3-id-Selector/styles.css b/exercises/04.3-id-Selector/styles.css index e020d28b..c6058338 100644 --- a/exercises/04.3-id-Selector/styles.css +++ b/exercises/04.3-id-Selector/styles.css @@ -1,5 +1,8 @@ #button1 { - background: #BDBDBD; - border: #5E5E5E; - border-radius: 5px; + background-color: #4caf50; /* Green */ + color: white; + padding: 15px 32px; + text-align: center; + display: inline-block; + border-radius: 5px; } diff --git a/exercises/04.3-id-Selector/test.js b/exercises/04.3-id-Selector/test.js new file mode 100644 index 00000000..ed2b823e --- /dev/null +++ b/exercises/04.3-id-Selector/test.js @@ -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 tag", () => { + expect(span).toBeTruthy() +}); + +test("The tag should have the id 'button1'", () => { + expect(span).toBeTruthy(); + let id = span.id + expect(id).toBeTruthy(); + expect(id).toBe('button1'); +}); + +test("The 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 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'); +}); diff --git a/exercises/05-Specificity/README.es.md b/exercises/05-Specificity/README.es.md index 32721c69..ceeca044 100644 --- a/exercises/05-Specificity/README.es.md +++ b/exercises/05-Specificity/README.es.md @@ -1,20 +1,16 @@ -# `05` Especificidad +# `05` Specificity -Al crear un documento CSS, debe comenzar desde el selector más genérico y terminar con el más específico, esa es la forma en que funciona CSS. +Al crear un documento CSS, se debe comenzar desde el selector más genérico y terminar con el más específico, esa es la forma en que funciona CSS. -Se trata del nivel de especificidad. Si especificas que tu div con id="thirditem" tiene un fondo (background) azul, y más adelante en el documento especificas que todos los divs tendrán un fondo amarillo, #thirditem mantendrá su fondo azul. ¡y punto! +Se trata del nivel de **especificidad**. Si especificas que tu `div` con `id="thirditem"` tiene un fondo (`background-color`) azul (`blue`), y más adelante en el documento especificas que todos los `divs` tendrán un fondo amarillo (`yellow`), `#thirditem` mantendrá su fondo azul (`blue`). ¡Y punto! -Porque cuanto más específico, más prioridad tiene. -## 📝 Instrucciones: - -```Plain/Text -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. -``` +*Porque cuanto más específico, más prioridad tiene.* -Tip: +## 📝 Instrucciones: -Puedes usar la anotación **!important** : -https://css-tricks.com/when-using-important-is-the-right-choice/ +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: ++ Puedes usar la notación **!important** : https://css-tricks.com/when-using-important-is-the-right-choice/ diff --git a/exercises/05-Specificity/README.md b/exercises/05-Specificity/README.md index c64d7a8b..f1edfa0f 100644 --- a/exercises/05-Specificity/README.md +++ b/exercises/05-Specificity/README.md @@ -4,20 +4,19 @@ tutorial: "https://www.youtube.com/watch?v=3JxXkhxyAnI" # `05` Specificity -When creating a CSS document, you need to start from the most generic selector and end with the most specific ones, that is the way CSS works. +When creating a CSS document, you need to start from the most generic selectors and end with the most specific ones, that is the way CSS works. -It's all about the level of Specificity. -If you specify that your div with id="thirditem" has a blue background, and later in the document you specify that all divs will have yellow background, #thirditem will keep his blue background. punto! -Because the more specific, the more priority it has. +It's all about the level of **specificity**. If you specify that your `div` with `id="thirditem` has a yellow background, and later in the document you specify that all `divs` will have blue background, `#thirditem` will keep his yellow background. punto! -## 📝 Instrucciones: +*Because the more specific, the more priority it has.* -```Plain/Text -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. -``` +## 📝 Instructions: -Tip: +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: You can use the **!important** annotation: https://css-tricks.com/when-using-important-is-the-right-choice/ diff --git a/exercises/05-Specificity/index.html b/exercises/05-Specificity/index.html index 3d68946c..154a071a 100644 --- a/exercises/05-Specificity/index.html +++ b/exercises/05-Specificity/index.html @@ -11,7 +11,7 @@
  • My first item of the list
  • My second item of the list
  • My third item of the list
  • -
  • My forth item of the list
  • +
  • My fourth item of the list
  • My fifth item of the list
  • diff --git a/exercises/05-Specificity/solution.hide.css b/exercises/05-Specificity/solution.hide.css new file mode 100644 index 00000000..fabc5750 --- /dev/null +++ b/exercises/05-Specificity/solution.hide.css @@ -0,0 +1,12 @@ +ul li { + background: blue; +} + +li + #thirditem { + background: yellow; +} +/**** DO NOT EDIT ANYTHING ABOVE THIS LINE ****/ + +#thirditem { + background: green !important; +} diff --git a/exercises/05-Specificity/styles.css b/exercises/05-Specificity/styles.css index db471c2b..1255fbbc 100644 --- a/exercises/05-Specificity/styles.css +++ b/exercises/05-Specificity/styles.css @@ -1,9 +1,8 @@ -ul li{ +ul li { background: blue; } -#thirditem{ +li + #thirditem { background: yellow; -} -/****** DON NOT EDIT ANYTHING ABOVE THIS LINE ****/ - \ No newline at end of file +} +/**** DO NOT EDIT ANYTHING ABOVE THIS LINE ****/ diff --git a/exercises/05-Specificity/tests.js b/exercises/05-Specificity/tests.js index 407a91f8..3ea381ec 100644 --- a/exercises/05-Specificity/tests.js +++ b/exercises/05-Specificity/tests.js @@ -1,69 +1,54 @@ -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 head tag", function () { - - let meta1 = document.getElementsByTagName('head')[0].innerHTML.toString().indexOf("-1).toBeFalsy(); + test("You should not change the existing 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) + }) + test("You should not delete or edit the existing code", function () { + document.querySelector("head").innerHTML = ``; - }) - it("You should not delete or edit the existing code", function () { + 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; - document.querySelector( - "head" - ).innerHTML=``; - 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 - expect(thirdItSelector).toBe("#thirditem"); + expect(thirdItSelector).toBe("li + #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=``; - let cssArray=document.styleSheets[0].cssRules; - // console.log("NEW", cssArray[2].style._importants) - let orangeHoverSelector=""; - for (let i=0; i${css.toString()}`; + let cssArray = document.styleSheets[0].cssRules; + let orangeHoverSelector = ""; + for (let i = 0; i < cssArray.length; i++) { + if (cssArray[i].selectorText.endsWith("#thirditem") && cssArray[i].style._importants.background === "important" || cssArray[i].style._importants["background-color"] === "important") { + orangeHoverSelector = cssArray[i].style.background || cssArray[i].style["background-color"]; } } expect(orangeHoverSelector).toBe("green"); }); -}); \ No newline at end of file +}); diff --git a/exercises/06-Practicing-Rules/README.es.md b/exercises/06-Practicing-Rules/README.es.md index 61dfd055..78942479 100644 --- a/exercises/06-Practicing-Rules/README.es.md +++ b/exercises/06-Practicing-Rules/README.es.md @@ -1,28 +1,23 @@ -# `06` Practicando las reglas +# `06` Practicing Rules ## 📝 Instrucciones: +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` -1. Establece esta URL como la imagen de fondo de la página y repítela solo verticalmente: - https://github.com/4GeeksAcademy/css-tutorial-exercises-course/blob/master/.learn/assets/background-vertical.jpg?raw=true +2. Cambia el tipo de fuente (`font-family`) del `h1` a `Courier` y el resto del sitio web a `Times New Roman`. -2. Cambia el tipo de fuente (font-size) del h1 a Courier - y el resto del sitio web a Times New Roman. +3. Cambia el color del `h1` a rojo (`red`). -3. Cambia el color del h1 a rojo. +4. Haz que todos los `h2` tengan subrayado (`underline`). -4. Haz todos los h2 con un subrayado. +5. Agrega un `left padding` a todo el documento de `20px` para que sea más fácil de leer. -5. Centra el h1 en el medio. +6. Agrega un fondo blanco semitransparente (`semi-transparent background (0.2)`) al **primer párrafo** para que sea más fácil de leer (tienes que usar `rgba` para esto). -6. Agrega un left padding a todo el documento de 20px para que sea más fácil de leer. +7. Luego aplica un `padding` de `5px` a todos los lados de ese párrafo. -7. Agrega un fondo blanco semitransparente (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. +8. Cambia el color del `anchor` **hover** a verde (`green`) y elimina el subrayado (tienes que pasar el cursor encima del anchor para probarlo). -8. Cambia el color del anchor/enlace "hover" a verde (green) y elimina el subrayado. -    (tienes que colocar el anchor para probarlo). +## El resultado debería ser algo como esto: - -El resultado debería ser algo como esto: - -![Example Image](https://github.com/4GeeksAcademy/css-tutorial-exercises-course/raw/master/.learn/assets/06-1.png?raw=true) +![Example Image](../../.learn/assets/06-1.png?raw=true) diff --git a/exercises/06-Practicing-Rules/README.md b/exercises/06-Practicing-Rules/README.md index 5d3e6e4c..2beed784 100644 --- a/exercises/06-Practicing-Rules/README.md +++ b/exercises/06-Practicing-Rules/README.md @@ -6,31 +6,22 @@ tutorial: "https://www.youtube.com/watch?v=4wguurrl-lU" ## 📝 Instructions: +1. Set this URL as the background image of the page, and repeat it vertically only: `../../.learn/assets/background-vertical.jpg?raw=true` -1. Set this URL as the background image of the page, and repeat it vertically only: - https://github.com/4GeeksAcademy/css-tutorial-exercises-course/blob/master/.learn/assets/background-vertical.jpg?raw=true +2. Change the `font-family` of the `h1` to `Courier` and the rest of the website to `Times new Roman`. -2. Change the font-type of the h1 to Courier - and the rest of the website to Times new Roman. +3. Change the color of `h1` to `red`. -3. Change the color of h1 to red. +4. Make all the `h2` have an `underline`. -4. Make all the h2's with an underline. +5. Add a `left padding` to the whole document of `20px` to make it easier to read. -5. Center the h1 to the middle. +6. Add a white `semi-transparent background (0.2)` to the **first paragraph** to make it easier to read (you have to use `rgba` for that). -6. Add a left padding to the whole document - of 20px to make it easier to read. +7. Then apply a `padding` of `5px` to all sides of that paragraph. -7. Add a white semi-transparent background (0.2) to the first paragraph - of "3 reasons you know you are learning" to make it easier to - read (you have tu use rgba for that), and 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). -8. Change the anchor "hover" color to green and remove the underline. - (you have to actually hover the anchor to test it). +## The result should be something like this: - -The result should be something like this: - -![Example Image](https://github.com/4GeeksAcademy/css-tutorial-exercises-course/blob/master/.learn/assets/06-1.png?raw=true) +![Example Image](../../.learn/assets/06-1.png?raw=true) diff --git a/exercises/06-Practicing-Rules/index.html b/exercises/06-Practicing-Rules/index.html index 4119acb5..8c0b2b50 100644 --- a/exercises/06-Practicing-Rules/index.html +++ b/exercises/06-Practicing-Rules/index.html @@ -8,27 +8,27 @@ -

    The learning essay

    -

    3 reasons you know you are learning

    -

    - 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. -

    -
      -
    1. You are able to complete the exercises by yourself.
    2. -
    3. You understand what the teacher is talking about
    4. -
    5. Your are able to have conversations about the topic
    6. -
    -

    3 reasons you know love what you are learning

    -
      -
    • Time passes fast.
    • -
    • - You are anxious to finish this excercise and start the next one. -
    • -
    • Is 12am and you don't want to go to sleep.
    • -
    -

    - If you can't sleep, what better than watching videos of cats? - click here -

    +
    - \ No newline at end of file + diff --git a/exercises/06-Practicing-Rules/solution.hide.css b/exercises/06-Practicing-Rules/solution.hide.css new file mode 100644 index 00000000..4026152e --- /dev/null +++ b/exercises/06-Practicing-Rules/solution.hide.css @@ -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; +} diff --git a/exercises/06-Practicing-Rules/styles.css b/exercises/06-Practicing-Rules/styles.css index d89b1a47..9a7fae86 100644 --- a/exercises/06-Practicing-Rules/styles.css +++ b/exercises/06-Practicing-Rules/styles.css @@ -1 +1 @@ -/* add your styles here */ \ No newline at end of file +/* add your styles here */ diff --git a/exercises/06-Practicing-Rules/tests.js b/exercises/06-Practicing-Rules/tests.js index 65c75a18..3bcecea6 100644 --- a/exercises/06-Practicing-Rules/tests.js +++ b/exercises/06-Practicing-Rules/tests.js @@ -1,147 +1,117 @@ -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(); +describe("All the styles should be applied", () => { + let meta = document.querySelector("meta") + let link = document.querySelector("link") + let title = document.querySelector('title') - // apply the styles from the stylesheet if needed - - }); - afterEach(() => { - jest.resetModules(); - }); - - - - it("the background should match", function () { + test("The background should match", () => { document.querySelector( "head" - ).innerHTML=``; - let body=document.querySelector("body"); - let styles=window.getComputedStyle(body); + ).innerHTML = ``; + let body = document.querySelector("body"); + let styles = window.getComputedStyle(body); expect(styles["background"]).toBe( - `url(https://github.com/4GeeksAcademy/css-tutorial-exercises-course/blob/3a2d1dd03f58167a5a4894155af2d3aa4d41d647/.learn/assets/background-vertical.jpg?raw=true) repeat-y` + `url(../../.learn/assets/background-vertical.jpg?raw=true) repeat-y` ); }); - it("the font-family should be 'Times New Roman'", function () { + test("The font-family should be 'Times New Roman'", () => { document.querySelector( "head" - ).innerHTML=``; - let body=document.querySelector("body"); - let styles=window.getComputedStyle(body); - expect(styles["font-family"]).toBe("Times New Roman"); + ).innerHTML = ``; + let body = document.querySelector("body"); + let styles = window.getComputedStyle(body); + expect(styles["font-family"].toLowerCase()).toBe("\"times new roman\""); }); - it("the padding-left should be '20px'", function () { + test("The padding-left should be '20px'", () => { document.querySelector( "head" - ).innerHTML=``; - let body=document.querySelector("body"); - let styles=window.getComputedStyle(body); + ).innerHTML = ``; + let body = document.querySelector("body"); + let styles = window.getComputedStyle(body); expect(styles["padding-left"]).toBe("20px"); }); - it("the font-family in the H1 Tag should be 'Courier'", function () { + test("The font-family in the

    tag should be 'Courier'", () => { document.querySelector( "head" - ).innerHTML=``; - let h1Tag=document.querySelector("h1"); - let h1TagStyles=window.getComputedStyle(h1Tag); + ).innerHTML = ``; + let h1Tag = document.querySelector("h1"); + let h1TagStyles = window.getComputedStyle(h1Tag); // get computed styles of any element you like - expect(h1TagStyles["font-family"]).toBe("Courier"); + expect(h1TagStyles["font-family"].toLowerCase()).toBe("\"courier\""); }); - it("the color in the H1 Tag should be 'red'", function () { + test("The color in the

    tag should be 'red'", () => { document.querySelector( "head" - ).innerHTML=``; - let h1Tag=document.querySelector("h1"); - let h1TagStyles=window.getComputedStyle(h1Tag); + ).innerHTML = ``; + let h1Tag = document.querySelector("h1"); + let h1TagStyles = window.getComputedStyle(h1Tag); // get computed styles of any element you like expect(h1TagStyles["color"]).toBe("red"); }); - it("the text-align in the H1 Tag should be 'center'", function () { + test("the text-decoration in the

    tag should be 'underline'", () => { document.querySelector( "head" - ).innerHTML=``; - let h1Tag=document.querySelector("h1"); - let h1TagStyles=window.getComputedStyle(h1Tag); + ).innerHTML = ``; // get computed styles of any element you like - expect(h1TagStyles["text-align"]).toBe("center"); - }); - it("the text-decoration in the H2 Tag should be 'underline'", function () { - document.querySelector( - "head" - ).innerHTML=``; - // get computed styles of any element you like - const h2Tag=document.querySelector("h2"); - let h2TagStyles=window.getComputedStyle(h2Tag); + const h2Tag = document.querySelector("h2"); + let h2TagStyles = window.getComputedStyle(h2Tag); expect(h2TagStyles["text-decoration"]).toBe("underline"); }); - it("the padding in the #id1 Tag should be '5px'", function () { + test("The padding in the p tag should be '5px'", () => { document.querySelector( "head" - ).innerHTML=``; + ).innerHTML = ``; // get computed styles of any element you like - const idTag=document.querySelector("#id1"); - let idTagStyles=window.getComputedStyle(idTag); + const idTag = document.querySelector("#id1"); + let idTagStyles = window.getComputedStyle(idTag); expect(idTagStyles["padding"]).toBe("5px"); }); - it("the background-color in the #id1 Tag should be 'semi transparent white'", function () { - document.querySelector( - "head" - ).innerHTML=``; - // get computed styles of any element you like - const idTag=document.querySelector("#id1"); - let idTagStyles=window.getComputedStyle(idTag); - console.log("$$$:", idTagStyles) - expect(idTagStyles["background-color"]).toBe("rgba(255, 255, 255, 0.2)"); - }); - it("The a hover underline should be removed", function () { + + test("The a:hover underline should be removed", () => { document.querySelector( "head" - ).innerHTML=``; - let cssArray=document.styleSheets[0].cssRules; - // console.log("$$$:", cssArray) - let orangeHoverSelector=""; - for (let i=0; i${css.toString()}`; + let cssArray = document.styleSheets[0].cssRules; + let orangeHoverSelector = ""; + for (let i = 0; i < cssArray.length; i++) { + if (cssArray[i].selectorText === "a:hover") { + orangeHoverSelector = cssArray[i].style['text-decoration']; } } expect(orangeHoverSelector).toBe("none"); }); - it("The a hover color should be green", function () { + test("The a:hover color should be green", () => { document.querySelector( "head" - ).innerHTML=``; + ).innerHTML = ``; + let cssArray = document.styleSheets[0].cssRules; + let orangeHoverSelector = ""; - let cssArray=document.styleSheets[0].cssRules; - console.log("$$$:", cssArray[0]) - let orangeHoverSelector=""; - for (let i=0; i< cssArray.length; i++) { + if (cssArray[i].selectorText === "a:hover") { + orangeHoverSelector = cssArray[i].style.color; } } expect(orangeHoverSelector).toBe('green'); }); - it("You should not change the head tag", function () { + test("You should not change the existing tag elements", () => { + let head = document.querySelector('head') + expect(head).toBeTruthy() + + expect(meta).toBeTruthy() + + let pathname = link.getAttribute("href") + expect(pathname).toBe('./styles.css') - let meta1 = document.getElementsByTagName('head')[0].innerHTML.toString().indexOf("-1).toBeFalsy(); + expect(title).toBeTruthy() }) }); diff --git a/exercises/07-Very-Specific-Rules/README.es.md b/exercises/07-Very-Specific-Rules/README.es.md index a8b31623..df781b9a 100644 --- a/exercises/07-Very-Specific-Rules/README.es.md +++ b/exercises/07-Very-Specific-Rules/README.es.md @@ -1,18 +1,21 @@ -# `07` Reglas Muy Especificas +# `07` Very Specific Rules -# **Importante:** +## 🔎 Importante: -En este ejercicio, puedes agregar tu código solo arriba del **READ ONLY BLOCK** del código, puedes agregar tantas líneas como desees, pero siempre arriba. +En este ejercicio, puedes agregar tu código solo arriba del **READ-ONLY BLOCK** del código, puedes agregar tantas líneas como desees, pero siempre arriba. ## 📝 Instrucciones: +1. Establece el color de texto `ul li` a rojo (`red`) (anula los conflictos siendo más específico). -1. Establece el color de texto **ul** a rojo (red) (anula los conflictos siendo más específico). -2. Establece el color de fondo (backgrounf-color) del segundo **li** del **ol** a verde (green) (no uses el selector #id). -3. Haz que las filas impares de las tablas tengan fondo amarillo usando **tr:nth-child**. +2. Establece el color de fondo (`background-color`) del segundo `li` del `ol` a verde (`green`) (no uses el selector #id ni el .class). +3. Haz que las filas impares de la tabla tengan fondo amarillo usando `tr:nth-child`. -![Example Image](https://github.com/4GeeksAcademy/css-tutorial-exercises-course/blob/master/.learn/assets/07-1.png?raw=true) +![Example Image](../../.learn/assets/07-1.png?raw=true) +>Importante: **NO** debes modificar el archivo index.html +## 💡 Pista: +1. El atributo `!important` ayuda a sobreescribir estilos. diff --git a/exercises/07-Very-Specific-Rules/README.md b/exercises/07-Very-Specific-Rules/README.md index 57bd680b..72f38d2c 100644 --- a/exercises/07-Very-Specific-Rules/README.md +++ b/exercises/07-Very-Specific-Rules/README.md @@ -4,19 +4,23 @@ tutorial: "https://www.youtube.com/watch?v=2YkLDRZFk40" # `07` Very Specific Rules -# **Important:** +## 🔎 Important: -In this exercise, you can add your code only above the **READ ONLY BLOCK** of the code, you can add as many lines as you want, but always above. +In this exercise, you can add your code only above the **READ-ONLY BLOCK** of the code, you can add as many lines as you want, but always above. ## 📝 Instructions: -1. Set the **ul** text color to red (override conflicts with specificity). -2. Set the background color of the second **li** of the **ol** to green (don't use the #id selector). -3. Make the odd rows of the tables with yellow background using **tr:nth-child**. +1. Set the `ul li` text color to `red` (override conflicts with specificity). +2. Set the `background-color` of the second `li` of the `ol` to `green` (don't use the #id selector or .class selector). -![Example Image](https://github.com/4GeeksAcademy/css-tutorial-exercises-course/blob/master/.learn/assets/07-1.png?raw=true) +3. Change the odd rows of the tables to a yellow background using `tr:nth-child`. +![Example Image](../../.learn/assets/07-1.png?raw=true) +>Important: You should **NOT** modify the index.html file. +## 💡 Hint: + +1. The `!important` attribute helps to override other attributes. diff --git a/exercises/07-Very-Specific-Rules/index.html b/exercises/07-Very-Specific-Rules/index.html index 9c691446..09fef243 100644 --- a/exercises/07-Very-Specific-Rules/index.html +++ b/exercises/07-Very-Specific-Rules/index.html @@ -10,22 +10,22 @@

    The learning essay

    3 reasons you know you are learning

    - 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. + We are going to explain in this paragraph the 3 most common signs that you should look into yourself to recognize if you are learning.

    1. You are able to complete the exercises by yourself.
    2. You understand what the teacher is talking about
    3. -
    4. Your are able to have conversations about the topic
    5. +
    6. You are able to have conversations about the topic

    3 reasons you know love what you are learning

    • Time passes fast.
    • -
    • You are anxious to finish this excercise and start the next one.
    • -
    • Is 12am and you don't want to go to sleep.
    • +
    • You are anxious to finish this exercise and start the next one.
    • +
    • It's 12am and you don't want to go to sleep.

    If you can't sleep, what better than watching videos of cats? - click here + click here

    @@ -34,47 +34,47 @@

    3 reasons you know love what you are learning

    - + - + - + - + - + - + - + - + - + - + - +
    Gender
    12 years12 Male
    22 years22 Female
    11 years11 Male
    21 years21 Male
    22 years22 Female
    10 years10 Male
    13 years13 Female
    13 years13 Male
    10 years10 Male
    11 years11 Male
    11 years11 Male
    diff --git a/exercises/07-Very-Specific-Rules/solution.hide.css b/exercises/07-Very-Specific-Rules/solution.hide.css new file mode 100644 index 00000000..232aa480 --- /dev/null +++ b/exercises/07-Very-Specific-Rules/solution.hide.css @@ -0,0 +1,27 @@ +/** Insert your code here **/ + +ul li { + color: red !important; +} + +ol li:nth-child(2) { + background-color: green; +} + +tr:nth-child(odd) { + background: yellow; +} + +/*********** READ-ONLY BLOCK ****** +You CANNOT UPDATE anything from here on, +only add lines of code on top of these lines +**/ + +body { + color: blue; +} + +ul li, +ol li { + color: green; +} diff --git a/exercises/07-Very-Specific-Rules/styles.css b/exercises/07-Very-Specific-Rules/styles.css index defdb77a..164b694b 100644 --- a/exercises/07-Very-Specific-Rules/styles.css +++ b/exercises/07-Very-Specific-Rules/styles.css @@ -1,8 +1,8 @@ /** Insert your code here **/ -/*********** READ ONLY BLOCK ****** -You CAN NOT UPDATE anything from here on, -only add lines of code on top of this lines +/********** READ-ONLY BLOCK ****** +You CANNOT UPDATE anything from here on, +only add lines of code on top of these lines **/ body { diff --git a/exercises/07-Very-Specific-Rules/tests.js b/exercises/07-Very-Specific-Rules/tests.js index 5f68ba04..f141c357 100644 --- a/exercises/07-Very-Specific-Rules/tests.js +++ b/exercises/07-Very-Specific-Rules/tests.js @@ -1,97 +1,98 @@ -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"); - -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(); - - //apply the styles from the stylesheet if needed - - }); - afterEach(() => { - jest.resetModules(); - }); - - - it("The ul li color has to be red", function () { +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'); + +describe("All the styles should be applied", ()=>{ + const meta = document.querySelector("meta") + const title = document.querySelector('title') + const link = document.querySelector('link') + + test("The ul li color has to be red using !important", ()=>{ document.querySelector( "head" - ).innerHTML=``; - let cssArray=document.styleSheets[0].cssRules; + ).innerHTML = ``; - let orangeHoverSelector=""; - for (let i=0; i< cssArray.length; i++) { + if (cssArray[i].selectorText === "ul li" || cssArray[i].selectorText === "ul > li") { + color = cssArray[i].cssText; } - expect(orangeHoverSelector).toBe("red"); } + let reg = new RegExp(/color:\s*red\s*!important\s*;/gm) - + expect(reg.test(color.toLowerCase())).toBeTruthy(); }); - it("The ul second element background should be green", function () { + + test("The ol second element background should be green", ()=>{ document.querySelector( "head" - ).innerHTML=``; - let cssArray=document.styleSheets[0].cssRules; + ).innerHTML = ``; + let cssArray = document.styleSheets[0].cssRules; + + let background = ""; + let backgroundColor=""; + for (let i = 0; i < cssArray.length; i++) { + if (cssArray[i].selectorText === "ol li:nth-child(2)" || cssArray[i].selectorText === "ol > li:nth-child(2)") { + background = cssArray[i].style['background']; + backgroundColor = cssArray[i].style['background-color']; - let orangeHoverSelector=""; - for (let i=0; i{ document.querySelector( "head" - ).innerHTML=``; - let cssArray=document.styleSheets[0].cssRules; - - let orangeHoverSelector=""; - for (let i=0; i${css.toString()}`; + let cssArray = document.styleSheets[0].cssRules; + + let background = ""; + let backgroundColor = ""; + for (let i = 0; i < cssArray.length; i++) { + if (cssArray[i].selectorText.includes( "tr:nth-child(odd)")) { + background = cssArray[i].style['background']; + backgroundColor = cssArray[i].style['background-color']; + } - }expect(orangeHoverSelector).toBe("yellow"); + } expect((background && background.toLowerCase() === "yellow") || (backgroundColor && backgroundColor.toLowerCase() === "yellow")).toBeTruthy(); }) - it("Write all your rules above the existing code", function () { + test("Write all your rules above the existing code", ()=>{ document.querySelector( "head" - ).innerHTML=``; - let cssBody=document.styleSheets[0].cssRules[3].selectorText; - let cssArray=document.styleSheets[0].cssRules[4].selectorText; + ).innerHTML = ``; + let cssBody = document.styleSheets[0].cssRules[3].selectorText; + let cssArray = document.styleSheets[0].cssRules[4].selectorText; expect(cssArray).toBe("ul li,\nol li"); expect(cssBody).toBe("body"); - } - ) - it("You should not change the head tag", function () { - - let meta1 = document.getElementsByTagName('head')[0].innerHTML.toString().indexOf("-1).toBeFalsy(); }) + test("You should not change the existing head tag elements", ()=>{ + let head = document.querySelector('head') + expect(head).toBeTruthy() + expect(meta).toBeTruthy() + let href = link.getAttribute('href') + expect(href).toBe('./styles.css') + expect(title).toBeTruthy() + }) -}); \ No newline at end of file +}); diff --git a/exercises/08-Rounded-Image/README.es.md b/exercises/08-Rounded-Image/README.es.md index 98d140a0..bd88ef5d 100644 --- a/exercises/08-Rounded-Image/README.es.md +++ b/exercises/08-Rounded-Image/README.es.md @@ -1,15 +1,25 @@ -# `08` Imagen Redondeada +# `08` Rounded Image -Muchos sitios web usan imágenes de perfil redondeadas ¡una técnica que realmente hace que un sitio web sea más hermoso! +Muchos sitios web usan imágenes de perfil redondeadas, ¡una técnica que realmente hace que un sitio web sea más hermoso! -La forma obvia de crear una imagen de perfil redondeada es crear una etiqueta de imagen y aplicar un border-radius: 100%. El problema con este enfoque es que solo funciona para imágenes cuadradas ... las imágenes de perfil con diferentes altura y ancho no se verán como un círculo, se verán como óvalos: +La forma obvia de crear una imagen de perfil redondeada es crear una etiqueta de imagen y aplicar un `border-radius: 100%`. -![Example Image](https://github.com/4GeeksAcademy/css-tutorial-exercises-course/blob/master/.learn/assets/08-1.png?raw=true) +El problema con este enfoque es que solo funciona para imágenes cuadradas... Las imágenes de perfil generalmente tienen diferente altura y ancho, no se verán como un círculo, se verán como óvalos: + +![Example Image](../../.learn/assets/08-1.png?raw=true) ## 📝 Instrucciones: -Adicionalmente a border-radius tenemos que tambien utilizar la propiedad `object-fit`, [aqui hay una explicación](https://www.loom.com/share/15186e456dfd4741887997af40325721). +1. Usa `border-radius`. + +2. Usa las propiedades `width` y `height` para hacer que la imagen sea cuadrada. + +3. Además de `border-radius`, tenemos que utilizar también la propiedad `object-fit`, [aquí hay una explicación](https://www.loom.com/share/15186e456dfd4741887997af40325721). + +## 💡 Pista: + ++ Si la imagen es más grande que su contenedor y quieres centrarla o enfocarte en una zona en particular, puedes utilizar `object-position`. -Si la es mas grande que el div y quieres centrarla o enfocarte en una zona en particular puedes utilizar `object-position`. ++ En este artículo puedes leer más [sobre la propiedad object fit](https://css-tricks.com/on-object-fit-and-object-position/). -En este articulo puedes leer más [sobre la propiedad object fit](https://css-tricks.com/on-object-fit-and-object-position/) ++ Adicionalmente, puedes [leer la documentación de object-position](https://developer.mozilla.org/en-US/docs/Web/CSS/object-position) y [la documentación de object-fit](https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit). diff --git a/exercises/08-Rounded-Image/README.md b/exercises/08-Rounded-Image/README.md index 22bf00c9..886e41f1 100644 --- a/exercises/08-Rounded-Image/README.md +++ b/exercises/08-Rounded-Image/README.md @@ -2,16 +2,25 @@ A lot of websites use rounded profile images, a technique that really makes a website more beautiful! -The obvious way create a rounded profile picture is to create an image tag and apply border-radius:100%. The problem with this approach, is that it only works for squared pictures... profile pictures with different height and width will not look like a circle, they will look like ovals: +The obvious way to create a rounded profile picture is to create an image tag and apply `border-radius:100%`. -![Example Image](https://github.com/4GeeksAcademy/css-tutorial-exercises-course/blob/master/.learn/assets/08-1.png?raw=true) +The problem with this approach is that it only works for squared pictures... Profile pictures with different height and width will not look like a circle, they will look like ovals: + +![Example Image](../../.learn/assets/08-1.png?raw=true) ## 📝 Instructions: +1. Use `border-radius`. + +2. Use the properties `width` and `height` to make the image a square shape. + +3. In this case, in addition to `border-radius`, you will have to use the `object-fit` CSS property, [here is an explanation](https://www.loom.com/share/15186e456dfd4741887997af40325721). + -In addition to the border-radius you have to use the `object-fit` css property, [here is an explanation](https://www.loom.com/share/15186e456dfd4741887997af40325721). +## 💡 Hint: -If the image ends up being bigger than the div (or with different proportions) we can adjust the object-position to choose what part of the image we want to display inside of the circle. ++ If the image ends up being bigger than its container (or with different proportions) you can adjust the `object-position` to choose what part of the image you want to display inside of the circle. -You can also read [this great article about object fit](https://css-tricks.com/on-object-fit-and-object-position/) ++ You can also read [this great article about object fit](https://css-tricks.com/on-object-fit-and-object-position/). ++ Additionally you can [read the documentation on object-position](https://developer.mozilla.org/en-US/docs/Web/CSS/object-position) and [the documentation on object-fit](https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit). diff --git a/exercises/08-Rounded-Image/solution.hide.css b/exercises/08-Rounded-Image/solution.hide.css new file mode 100644 index 00000000..86a38c22 --- /dev/null +++ b/exercises/08-Rounded-Image/solution.hide.css @@ -0,0 +1,10 @@ +body { + background: #bdbdbd; +} +.rounded { + object-fit: cover; + object-position: top; + width: 250px; + height: 250px; + border-radius: 100%; +} diff --git a/exercises/08-Rounded-Image/tests.js b/exercises/08-Rounded-Image/tests.js index d2c7c36f..13cd170e 100644 --- a/exercises/08-Rounded-Image/tests.js +++ b/exercises/08-Rounded-Image/tests.js @@ -1,98 +1,74 @@ -const fs = require("fs"); -const path = require("path"); -const html = fs.readFileSync(path.resolve(__dirname, "./index.html"), "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(); +describe("All the styles should be applied", () => { + const meta = document.querySelector("meta") + const title = document.querySelector('title') + const link = document.querySelector('link') - //apply the styles from the stylesheet if needed + const img = document.querySelector(".rounded") - }); - afterEach(() => { - jest.resetModules(); - }); + test("The tag should exist", () => { + expect(img).toBeTruthy(); + }) - it("The tag has to be removed", function() { - document.querySelector( - "head" - ).innerHTML = ``; - expect(document.querySelector("img")).toBeFalsy(); - }); - it("The
    tag should exists", function() { - document.querySelector( - "head" - ).innerHTML = ``; - expect(document.querySelector("div")).toBeTruthy(); - }); - it("the width in the div Tag should be '200px'", function() { - // get computed styles of any element you like + test("The width of the tag should be equal to its height and vice versa", () => { document.querySelector( "head" ).innerHTML = ``; - const divTag = document.querySelector("div"); - let idTagStyles = window.getComputedStyle(divTag); - expect(idTagStyles["width"]).toBe("200px"); - }); - it("the height in the div Tag should be '200px'", function() { - // get computed styles of any element you like - document.querySelector( - "head" - ).innerHTML = ``; - const divTag = document.querySelector("div"); - let idTagStyles = window.getComputedStyle(divTag); - expect(idTagStyles["height"]).toBe("200px"); - }); - it("the border radius in the div Tag should be '100%'", function() { - // get computed styles of any element you like - document.querySelector( - "head" - ).innerHTML = ``; - const divTag = document.querySelector("div"); - let idTagStyles = window.getComputedStyle(divTag); - expect(idTagStyles["border-radius"]).toBe("100%"); - }); - it("the background position x in the div Tag should be 'center'", function() { - // get computed styles of any element you like - document.querySelector( - "head" - ).innerHTML = ``; - const divTag = document.querySelector("div"); - let idTagStyles = window.getComputedStyle(divTag); - expect(idTagStyles["background-position-x"]).toBe("center"); + + let cssArray = document.styleSheets[0].cssRules; + + let width = ""; + let height = ""; + + for (let i = 0; i < cssArray.length; i++) { + if (cssArray[i].selectorText === ".rounded") { + width = cssArray[i].style["width"]; + height = cssArray[i].style["height"]; + } + } + + // checks if styles return empty string "" or undefined + expect(width).toBeTruthy(); + expect(height).toBeTruthy(); + + expect(width).toBe(height); + expect(height).toBe(width); }); - it("the background position y in the div Tag should be 'center'", function() { - // get computed styles of any element you like + + test("The object-fit value of the tag should be 'cover'", () => { document.querySelector( "head" ).innerHTML = ``; - const divTag = document.querySelector("div"); - let idTagStyles = window.getComputedStyle(divTag); - expect(idTagStyles["background-position-y"]).toBe("center"); + + let imgStyle = window.getComputedStyle(img); + expect(imgStyle["object-fit"]).toBe("cover"); }); - it("the background image in the div Tag should exists", function() { - // get computed styles of any element you like + + test("The object-position value of the tag should be 'top'", () => { document.querySelector( "head" ).innerHTML = ``; - const divTag = document.querySelector("div"); - let idTagStyles = window.getComputedStyle(divTag); - expect(idTagStyles["background-image"]).toBeTruthy(); + + let imgStyle = window.getComputedStyle(img); + expect(imgStyle["object-position"]).toBe("top"); }); - it("You should not change the head tag", function () { - - let meta1 = document.getElementsByTagName('head')[0].innerHTML.toString().indexOf("-1).toBeFalsy(); + + test("You should not change the existing tag elements", () => { + let head = document.querySelector('head') + expect(head).toBeTruthy() + + expect(meta).toBeTruthy() + + let href = link.getAttribute('href') + expect(href).toBe('./styles.css') + + expect(title).toBeTruthy() }) }); diff --git a/exercises/09-Anchor-Styles/README.es.md b/exercises/09-Anchor-Styles/README.es.md index 49e7507d..94e03e07 100644 --- a/exercises/09-Anchor-Styles/README.es.md +++ b/exercises/09-Anchor-Styles/README.es.md @@ -1,22 +1,20 @@ -# `09` Estilos de enlaces (anchor) 3D +# `09` 3D Anchor Styles -A las personas les gusta sentir que están haciendo clic en algo, un gran enfoque para lograrlo es fingir un efecto 3D. Para hacerlo, los diseñadores normalmente juegan con los bordes. Ejemplo: +A las personas les gusta sentir que están haciendo clic en algo, una manera de lograrlo es fingir un efecto 3D. Para hacerlo, los diseñadores normalmente juegan con los bordes, por ejemplo: -![Example Image](https://github.com/4GeeksAcademy/css-tutorial-exercises-course/blob/master/.learn/assets/09-1.png?raw=true) +![Example Image](../../.learn/assets/09-1.png?raw=true) -Puedes controlar qué reglas css se aplican a cada estado de un enlace utilizando los selectores: ":hover" (para el mouse) o "active" (para presionar el mouse), por ejemplo: +Puedes controlar qué reglas CSS se aplican a cada estado de un `anchor` utilizando los selectores: `:hover` (cuando pasas por encima con el mouse) o `active` (cuando haces clic), por ejemplo: ```css a:active { - /* aquí puedes especificar cualquier regla de css que aplique -   al anchor mientras se presiona' */ + /* aquí puedes especificar cualquier regla de CSS que aplique al anchor mientras se presiona' */ } ``` ## 📝 Instrucciones: - -1. Cambia los colores del borde del enlace (anchor), cuando la presionas, a lo siguiente: +1. Cambia los colores del borde del anchor, cuando le das clic, a lo siguiente: ```css border-color: #000 #aaa #aaa #000; diff --git a/exercises/09-Anchor-Styles/README.md b/exercises/09-Anchor-Styles/README.md index abf0bc33..a4b23419 100644 --- a/exercises/09-Anchor-Styles/README.md +++ b/exercises/09-Anchor-Styles/README.md @@ -1,21 +1,20 @@ # `09` 3D Anchor Styles -People like to feel that they are clicking on something, a great approach to accomplish that is by faking a 3D effect. To do so, designers normally play with the borders. Example: +People like to feel that they are clicking on something, a great approach to accomplish that is by faking a 3D effect. To do so, designers normally play with the borders, for example: -![Example Image](https://github.com/4GeeksAcademy/css-tutorial-exercises-course/blob/master/.learn/assets/09-1.png?raw=true) +![Example Image](../../.learn/assets/09-1.png?raw=true) -You can control what css rules apply to each state of an anchor by using the ":hover" (for mouse hover) or ":active" (for mouse pressing) selectors, example: +You can control what CSS rules apply to each state of an anchor by using the `:hover` (for mouse hover) or `:active` (for mouse pressing) selectors, example: ```css a:active { - /* here you can specify whatever css rule that applies + /* here you can specify whatever CSS rule that applies to the anchor while being 'pressed' */ } ``` ## 📝 Instructions: - 1. Change the border colors of the anchor, when being pressed, to the following: diff --git a/exercises/09-Anchor-Styles/index.html b/exercises/09-Anchor-Styles/index.html index 984ca01e..30e00691 100644 --- a/exercises/09-Anchor-Styles/index.html +++ b/exercises/09-Anchor-Styles/index.html @@ -6,7 +6,7 @@ 09 Anchor Styles - + Click me diff --git a/exercises/09-Anchor-Styles/solution.hide.css b/exercises/09-Anchor-Styles/solution.hide.css new file mode 100644 index 00000000..8c12ea5b --- /dev/null +++ b/exercises/09-Anchor-Styles/solution.hide.css @@ -0,0 +1,16 @@ +.threeDimension { + display: block; + border: 1px solid; + border-color: #aaa #000 #000 #aaa; + width: 8em; + background: #fc0; + text-decoration: none; + text-align: center; + color: black; + font-size: 22px; +} + +a.threeDimension:active { + /* your code here*/ + border-color: #000 #aaa #aaa #000; +} diff --git a/exercises/09-Anchor-Styles/styles.css b/exercises/09-Anchor-Styles/styles.css index 7eaa9bea..895dc3d6 100644 --- a/exercises/09-Anchor-Styles/styles.css +++ b/exercises/09-Anchor-Styles/styles.css @@ -8,9 +8,10 @@ text-decoration: none; text-align: center; color: black; + font-size: 22px; } a.threeDimension:active { /* your code here*/ -} \ No newline at end of file +} diff --git a/exercises/09-Anchor-Styles/tests.js b/exercises/09-Anchor-Styles/tests.js index 8e4baa92..1dea80c1 100644 --- a/exercises/09-Anchor-Styles/tests.js +++ b/exercises/09-Anchor-Styles/tests.js @@ -1,67 +1,86 @@ -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"); -let cssArray=null; -jest.dontMock("fs"); +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(); -describe("All the styles should be applied", function () { - beforeEach(() => { - //here I import the HTML into the document - document.documentElement.innerHTML=html.toString(); +jest.dontMock('fs'); - //apply the styles from the stylesheet if needed +let cssArray = null; - - }); - afterEach(() => { - jest.resetModules(); - }); - - it("You should not add your rules above the existing code", function () { +describe("All the styles should be applied", () => { + const meta = document.querySelector("meta") + const title = document.querySelector('title') + const link = document.querySelector('link') + test("You should not add your rules above the existing code", () => { document.querySelector( "head" - ).innerHTML=``; - let cssArray=document.styleSheets[0].cssRules[0].selectorText; + ).innerHTML = ``; + let cssArray = document.styleSheets[0].cssRules[0].selectorText; expect(cssArray).toBe(".threeDimension"); }) - it("the 'a' tag in the index.html should not be deleted", function () { + test("The tag in the index.html should not be deleted", () => { // we can read from the source code // console.log(html.toString()); - expect(html.toString().indexOf(`-1).toBeTruthy(); + expect(html.toString().indexOf(` -1).toBeTruthy(); }); - it("The border-color rule for the 'threeDimension active ' property should match the instruction color", function () { + test("The border-color rule for the 'a.threeDimension:active' selector should match the instruction color", () => { // get computed styles of any element you like // let cssArray=document.styleSheets[0].cssRules; document.querySelector( "head" - ).innerHTML=``; - let cssArray=document.styleSheets[0].cssRules; + ).innerHTML = ``; + let cssArray = document.styleSheets[0].cssRules; - let orangeHoverSelector=""; - for (let i=0; i< cssArray.length; i++) { + if (cssArray[i].selectorText === "a.threeDimension:active") { + orangeHoverSelector = cssArray[i].style['border-color']; } } - expect(orangeHoverSelector).toBe("#000 #aaa #aaa #000"); + + }); + test("You should not change the default styles", () => { + // get computed styles of any element you like + // let cssArray=document.styleSheets[0].cssRules; + document.querySelector( + "head" + ).innerHTML = ``; + let cssArray = document.styleSheets[0].cssRules; + + let borderColor = ""; + let color = ""; + let background = ""; + let width = ""; + for (let i = 0; i < cssArray.length; i++) { + if (cssArray[i].selectorText === ".threeDimension") { + borderColor = cssArray[i].style["border-color"]; + color = cssArray[i].style['color']; + background = cssArray[i].style['background']; + width = cssArray[i].style['width']; + expect(borderColor).toBe("#aaa #000 #000 #aaa"); + expect(color).toBe("black"); + expect(background).toBe("#fc0"); + expect(width).toBe("8em"); + } + } + }); - it("You should not change the head tag", function () { - - let meta1 = document.getElementsByTagName('head')[0].innerHTML.toString().indexOf("-1).toBeFalsy(); + test("You should not change the existing tag elements", () => { + let head = document.querySelector('head') + expect(head).toBeTruthy() + + expect(meta).toBeTruthy() + + let href = link.getAttribute('href') + expect(href).toBe('./styles.css') + + expect(title).toBeTruthy() }) }); diff --git a/exercises/10-Your-Own-Font/README.es.md b/exercises/10-Your-Own-Font/README.es.md index 978ca31c..dd58b215 100644 --- a/exercises/10-Your-Own-Font/README.es.md +++ b/exercises/10-Your-Own-Font/README.es.md @@ -1,18 +1,18 @@ -# `10` Tu Propia Fuente +# `10` Your Own Font -Las fuentes de Google se pueden encontrar aquí: https://fonts.google.com +Aquí puedes encontrar las fuentes de Google: https://fonts.google.com -Después de elegir su favorita, puedes usarla al vincular su sitio web con la URL en la que se almacena la fuente. Tienes que hacer eso en la etiqueta del documento HTML de esta manera: +Elige la que más te guste, y úsala vinculando tu sitio web con la URL en la que se almacena la fuente. Tienes que hacer eso en la etiqueta `` del documento HTML de esta manera: ```Plain/Text - + ``` -Después de vincular tu fuente, debes asignar la regla CSS "font-family" a lo que quieras aplicarle la fuente, por ejemplo, un

    . +Después de vincular tu fuente, debes asignar la regla CSS `font-family` a lo que quieras aplicarle la fuente, por ejemplo, un `

    `. ## 📝 Instrucciones: - 1. Enlaza cualquier fuente de google que desee en el sitio web. -2. Aplica esa familia de fuentes específica a #myTitle. + +2. Aplica esa `font-family` (familia de fuentes) específica a `.myTitle`. diff --git a/exercises/10-Your-Own-Font/README.md b/exercises/10-Your-Own-Font/README.md index a872e4be..e2632833 100644 --- a/exercises/10-Your-Own-Font/README.md +++ b/exercises/10-Your-Own-Font/README.md @@ -1,18 +1,18 @@ # `10` Your Own Font -Google Fonts can be found here: https://fonts.google.com +You can find Google Fonts here: https://fonts.google.com -After you pick your favorite one, you can use it by linking your website with the URL in which the font is stored. You have to do that in the tag of the HTML document like this: +Pick your favorite one, and then use it by linking your website with the URL in which the font is stored. You have to do that in the `` tag of the HTML document like this: ```Plain/Text - + ``` -After your font is linked you need to assign the "font-family" CSS rule to whatever you want to apply the font, for example an `

    `. +After your font is linked, you need to assign the `font-family` CSS rule to whatever you want to apply the font, for example an `

    `. ## 📝 Instructions: - 1. Link any google-font that you like into the website. -2. Apply that specific font-family to #myTitle. + +2. Apply that specific `font-family` to `.myTitle`. diff --git a/exercises/10-Your-Own-Font/index.html b/exercises/10-Your-Own-Font/index.html index a0e7f25a..b4005187 100644 --- a/exercises/10-Your-Own-Font/index.html +++ b/exercises/10-Your-Own-Font/index.html @@ -1,15 +1,14 @@ - - - - + + + + - - - 10 Your Own Font - - -

    My unique font

    - + + 10 Your Own Font + + +

    My unique font

    + diff --git a/exercises/10-Your-Own-Font/solution.hide.css b/exercises/10-Your-Own-Font/solution.hide.css new file mode 100644 index 00000000..85e3a7c3 --- /dev/null +++ b/exercises/10-Your-Own-Font/solution.hide.css @@ -0,0 +1,4 @@ +.myTitle { + /* Add your code below this line */ + font-family: "Montserrat"; /* Varies depending on the font you chose */ +} diff --git a/exercises/10-Your-Own-Font/solution.hide.html b/exercises/10-Your-Own-Font/solution.hide.html new file mode 100644 index 00000000..eeb1c059 --- /dev/null +++ b/exercises/10-Your-Own-Font/solution.hide.html @@ -0,0 +1,19 @@ + + + + + + + + + + + 10 Your Own Font + + +

    My unique font

    + + diff --git a/exercises/10-Your-Own-Font/styles.css b/exercises/10-Your-Own-Font/styles.css index de7160fd..0335a322 100644 --- a/exercises/10-Your-Own-Font/styles.css +++ b/exercises/10-Your-Own-Font/styles.css @@ -1,3 +1,3 @@ .myTitle { - /*your code here*/ + /* Add your code below this line */ } diff --git a/exercises/10-Your-Own-Font/tests.js b/exercises/10-Your-Own-Font/tests.js index 6109a451..f7c2460b 100644 --- a/exercises/10-Your-Own-Font/tests.js +++ b/exercises/10-Your-Own-Font/tests.js @@ -1,53 +1,44 @@ -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"); - -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(); - - //apply the styles from the stylesheet if needed - // document.querySelector( - // "head" - // ).innerHTML=``; - }); - afterEach(() => { - jest.resetModules(); - }); +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'); + +let cssArray = null; + +describe("All the styles should be applied", ()=>{ + const link = document.querySelectorAll("link") + test("the font-family in the .myTitle should exists", ()=>{ + document.querySelector( + "head" + ).innerHTML = ``; - it("the font-family in the #myTitle should exists", function () { // get computed styles of any element you like - let cssArray=document.styleSheets[0].cssRules; - // console.log("%%% ", cssArray) - let orangeHoverSelector=""; - for (let i=0; i< cssArray.length; i++) { + if (cssArray[i].selectorText === ".myTitle") { + orangeHoverSelector = cssArray[i].style['font-family']; } } expect(orangeHoverSelector).toBeTruthy(); }); - it('the h1 tag should have a class "myTitle"', function () { + test('The h1 tag should have a class "myTitle"', ()=>{ //or use query selector to compare hoy mane scriptags do we have - const h=document.querySelector("h1"); + const h = document.querySelector("h1"); expect(h.classList.contains("myTitle")).toBeTruthy(); }); - it("The link should be included in the head tag", function () { + test("The google-font link should be included in the head tag", ()=>{ // let headContent=document.getElementsByTagName("*") - // console.log("###", headContent[1].innerHTML) - console.log("###", document.head.childNodes) - expect(document.querySelectorAll("link").length).toBe(2); + expect(link.length).toBeGreaterThanOrEqual(2); }); - it("The Head tag should not includes a Style tag", function () { - expect(html.toString().indexOf(`-1).toBeFalsy(); + test("The head tag should not include a style tag", ()=>{ + expect(html.toString().indexOf(` -1).toBeFalsy(); }); }); diff --git a/exercises/11-Font-Awesome-Icons/README.es.md b/exercises/11-Font-Awesome-Icons/README.es.md index 8dedafe1..d02884e6 100644 --- a/exercises/11-Font-Awesome-Icons/README.es.md +++ b/exercises/11-Font-Awesome-Icons/README.es.md @@ -1,20 +1,22 @@ -# `11` Iconos Font Awesome +# `11` Font Awesome Icons -Como desarrollador / diseñador, desea utilizar ciertos iconos para que tu sitio web sea fácil de entender; Por ejemplo, sabemos que un icono de "papelera" significa "eliminar". +Como desarrollador, querrás utilizar ciertos iconos para que tu sitio web sea fácil de entender. Por ejemplo, sabemos que el icono de "papelera" significa "eliminar". -¡Pero usar iconos puede ser frustrante y llevar mucho tiempo! porque cada icono es una imagen y trabajar con imágenes ¡es horrible! +¡Pero usar iconos puede ser frustrante y llevar mucho tiempo! Porque cada icono es una imagen y trabajar con imágenes ¡es horrible! -Font-awesome resuelve el problema de la "imagen" creando una nueva fuente: cada letra es un ícono diferente y ahora puedes importar toda la fuente en su sitio web y usar el ícono que desees. +Font Awesome resuelve el problema de la "imagen" creando una nueva fuente en donde cada letra es un icono diferente y ahora puedes importar toda la fuente a tu sitio web y usar el icono que quieras. Después de vincular tu sitio web con font-awesome, puedes usar lo siguiente para codificar e insertar un icono específico: ```html - "camera-retro" será el nombre de tu icono, -puedes encontrar todos los nombres disponibles aquí: http://fontawesome.io/icons/ + + ``` -## 📝 Instrucciones: +> *Puedes encontrar todos los iconos disponibles aquí: https://fontawesome.com/search?o=r&m=free* + +## 📝 Instrucciones: -Agrega dos elementos más a tu lista y agregua un icono diferente al comienzo de cada elemento. +Agrega dos elementos (`li`) más a tu lista y agrega un icono diferente al comienzo de cada elemento. diff --git a/exercises/11-Font-Awesome-Icons/README.md b/exercises/11-Font-Awesome-Icons/README.md index 7a03a637..f9c7c09f 100644 --- a/exercises/11-Font-Awesome-Icons/README.md +++ b/exercises/11-Font-Awesome-Icons/README.md @@ -4,17 +4,18 @@ As a developer/designer, you want to use certain icons to make your website easy But using icons can be frustrating and time-consuming because each icon is an image and working with images is horrible! -Font-awesome solve the "image" problem by creating a new font- each letter is a different icon and you can now import the whole font into your website and use whatever icon you want. +Font Awesome solves the "image" problem by creating a new font where each letter is a different icon and you can now import the whole font into your website and use whatever icon you want. -After linking your website with font-awesome, you can use the following to code to insert a specific icon: +After linking your website with font-awesome, you can use the following code to insert a specific icon: ```html - "camera-retro" will be the name of the icon, -you can find all the available names here: http://fontawesome.io/icons/ + + ``` -## 📝 Instructions: +> *You can find all the available icons here: https://fontawesome.com/search?o=r&m=free* +## 📝 Instructions: -Add two more items into your list and add a different icon at the beginning of each item. +1. Add two more items (`li`) into your list and add a different icon at the beginning of each item. diff --git a/exercises/11-Font-Awesome-Icons/index.html b/exercises/11-Font-Awesome-Icons/index.html index a619ff63..1401d5da 100644 --- a/exercises/11-Font-Awesome-Icons/index.html +++ b/exercises/11-Font-Awesome-Icons/index.html @@ -1,14 +1,15 @@ - - - - - 11 Font Awesome - - -
      -
    • Hello
    • -
    - + + + + + + 11 Font Awesome + + +
      +
    • Hello
    • +
    + diff --git a/exercises/11-Font-Awesome-Icons/solution.hide.html b/exercises/11-Font-Awesome-Icons/solution.hide.html new file mode 100644 index 00000000..431e6b22 --- /dev/null +++ b/exercises/11-Font-Awesome-Icons/solution.hide.html @@ -0,0 +1,17 @@ + + + + + + + + 11 Font Awesome + + +
      +
    • Hello
    • +
    • Hello
    • +
    • Hello
    • +
    + + diff --git a/exercises/11-Font-Awesome-Icons/styles.css b/exercises/11-Font-Awesome-Icons/styles.css index b22aedca..52fe9b9c 100644 --- a/exercises/11-Font-Awesome-Icons/styles.css +++ b/exercises/11-Font-Awesome-Icons/styles.css @@ -1,3 +1,4 @@ li { + font-size: 2.5rem; list-style: none; } diff --git a/exercises/11-Font-Awesome-Icons/tests.js b/exercises/11-Font-Awesome-Icons/tests.js index 10afe9c1..b481bcfc 100644 --- a/exercises/11-Font-Awesome-Icons/tests.js +++ b/exercises/11-Font-Awesome-Icons/tests.js @@ -1,46 +1,38 @@ -const fs = require("fs"); -const path = require("path"); -const html = fs.readFileSync(path.resolve(__dirname, "./index.html"), "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(); +let cssArray = null; - //apply the styles from the stylesheet if needed - document.querySelector( - "head" - ).innerHTML = ``; - }); - afterEach(() => { - jest.resetModules(); - }); - - it("ul tag should exists", function() { +describe("All the styles should be applied", ()=>{ + const icons = document.querySelectorAll("i"); + test("The
      tag should exist", ()=>{ expect(document.querySelector("ul")).toBeTruthy(); }); - it("At least 3 li tags should exist", function() { + test("At least 3
    • tags should exist", ()=>{ expect(document.querySelectorAll("li").length).toBe(3); }); - it("At least 3 i tags should exist", function() { + test("At least 3 tags should exist", ()=>{ expect(document.querySelectorAll("i").length).toBe(3); }); - it(" LI innerHTML exist", function() { - const li = document.querySelectorAll("li"); + test("The tags should be inside the
    • tags", ()=>{ expect(document.querySelector("li")).toBeTruthy(); + const li = document.querySelectorAll("li"); for (let i = 0; i < li.length; i++) { expect(li[i].innerHTML).toBeTruthy(); } }); - it('the i tag should have a class "fa"', function() { + test('The tags should have any Font Awesome class starting with "fa" | ex. "fa-solid"', ()=>{ //or use query selector to compare hoy mane scriptags do we have - const icon = document.querySelectorAll("i"); - expect(document.querySelector("i")).toBeTruthy(); - for (let i = 0; i < icon.length; i++) { - expect(icon[i].classList.contains("fa")).toBeTruthy(); - } + expect(icons).toBeTruthy(); + + icons.forEach(icon=>{ + let hasFa = icon.classList.toString().includes("fa-") + expect(hasFa).toBeTruthy(); + }) }); }); diff --git a/exercises/12-Relative-Length-EM-REM/README.es.md b/exercises/12-Relative-Length-EM-REM/README.es.md index 48b13c26..a10a425d 100644 --- a/exercises/12-Relative-Length-EM-REM/README.es.md +++ b/exercises/12-Relative-Length-EM-REM/README.es.md @@ -1,24 +1,30 @@ -# `12` Longitud Relativa EM, REM +# `12` Relative Length em, rem -Hasta ahora, hemos trabajado con píxeles como unidad de medida, por ejemplo, diciendo que una caja tiene 100 px de ancho. +Hasta ahora, hemos trabajado con píxeles como unidad de medida, por ejemplo, diciendo que un contenedor o caja tiene `100px` de ancho. -Hay otros tipos de unidades que no son fijas, sino relativas. Las usamos cuando queremos que el tamaño del elemento esté relacionado con otro elemento o unidad de medida. +Hay otros tipos de unidades que no son absolutas, sino relativas. Las usamos cuando queremos que el tamaño del elemento esté relacionado con otro elemento o unidad de medida. -### Ejemplo usando EM: +## Ejemplo usando em: -En este ejercicio tenemos dos encabezados

      . Ambos son

      , pero uno es más grande que el otro porque los encabezados tienen font-size relativos por defecto. Dado que el primer div tiene un font-size más grande, el título cambia de tamaño en consecuencia y el heading se adapta. +En este ejercicio tenemos dos encabezados `

      `. Ambos son `

      `, pero uno es más grande que el otro porque los encabezados tienen `font-size` relativos por defecto. + +Dado que el segundo `div` tiene un `font-size` más grande, el título cambia de tamaño en consecuencia y el `heading` se adapta. + +## En resumen: + ++ em: Relativo al `font-size` actual del padre. + ++ rem: Relativo al `font-size` original de la página. -```Plain/Text -em: Relativo al font-size actual del padre. -rem: Relativo al font-size original de la página. -``` ## 📝 Instrucciones: -1. Proporciona un font-size de 0.8 em a ambos h2 -2. Ahora asigna un font-size de 0.8rem a ambos h3 +1. Proporciona un `font-size` de `0.8em` a ambos `h2` + +2. Ahora asigna un `font-size` de `0.8rem` a ambos `h3` + +## El resultado debería verse así: -El resultado debería verse así: -![Example Image](https://github.com/4GeeksAcademy/css-tutorial-exercises-course/raw/master/.learn/assets/12-1.png?raw=true) +![Example Image](../../.learn/assets/12-1.png?raw=true) diff --git a/exercises/12-Relative-Length-EM-REM/README.md b/exercises/12-Relative-Length-EM-REM/README.md index 009bfc87..51613b62 100644 --- a/exercises/12-Relative-Length-EM-REM/README.md +++ b/exercises/12-Relative-Length-EM-REM/README.md @@ -1,24 +1,31 @@ -# `12` Relative Length EM, REM +# `12` Relative Length em, rem -By now, we are used to working with pixels as measurement unit, for example, saying that a box has 100px of width. +By now, we are used to working with pixels as a measurement unit, for example, saying that a box has `100px` of width. There are other types of units that are not fixed, but relative. We use them when we want the element size to be related to another element or measurement unit. -### Example using em: -In this exercise we have two `

      ` headings. They are both `

      `, but one is bigger than the other because headings have relative font-sizes by default. Since the first div has a bigger based font-size, then the heading resizes accordingly. +## Example using em: + +In this exercise we have two `

      ` headings. They are both `

      `, but one is bigger than the other because headings have relative font-sizes by default. + +Since the second `div` has a bigger based `font-size`, then the heading resizes accordingly. + +## In short: + ++ em: Relative to the current `font-size` of the parent. + ++ rem: Relative to the original `font-size` of the page. -```Plain/Text -em: Relative to the current font-size of the parent. -rem: Relative to the original font-size of the page. -``` ## 📝 Instructions: -1. Give a font-size of 0.8em to both h2's -2. Now give a font-size of 0.8rem to both h3's +1. Give a `font-size` of `0.8em` to both `h2`'s + +2. Now give a `font-size` of `0.8rem` to both `h3`'s + +## The result should look like this: -The result should look like this: -![Example Image](https://github.com/4GeeksAcademy/css-tutorial-exercises-course/blob/master/.learn/assets/12-1.png?raw=true) +![Example Image](../../.learn/assets/12-1.png?raw=true) diff --git a/exercises/12-Relative-Length-EM-REM/index.html b/exercises/12-Relative-Length-EM-REM/index.html index 60a98594..f4d745fd 100644 --- a/exercises/12-Relative-Length-EM-REM/index.html +++ b/exercises/12-Relative-Length-EM-REM/index.html @@ -12,6 +12,7 @@

      First h2 heading

      First h3 heading

      Here is some nice fake content

    +

    Second h2 heading

    Second h3 heading

    diff --git a/exercises/12-Relative-Length-EM-REM/solution.hide.css b/exercises/12-Relative-Length-EM-REM/solution.hide.css new file mode 100644 index 00000000..eeb04334 --- /dev/null +++ b/exercises/12-Relative-Length-EM-REM/solution.hide.css @@ -0,0 +1,15 @@ +#my-first-div { + font-size: 15px; +} +#the-second-one { + font-size: 25px; +} + +/* YOUR CODE BELOW THIS LINE */ +h2{ + font-size: 0.8em; +} + +h3{ + font-size: 0.8rem; +} \ No newline at end of file diff --git a/exercises/12-Relative-Length-EM-REM/tests.js b/exercises/12-Relative-Length-EM-REM/tests.js index 33fd71a0..326eb9b0 100644 --- a/exercises/12-Relative-Length-EM-REM/tests.js +++ b/exercises/12-Relative-Length-EM-REM/tests.js @@ -1,68 +1,43 @@ -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"); - -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(); - - //apply the styles from the stylesheet if needed - - }); - afterEach(() => { - jest.resetModules(); - }); - - it("The H2 Tag should have a font-size: 0.8em", function () { +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'); + +describe("All the styles should be applied", ()=>{ + const meta = document.querySelector("meta") + const title = document.querySelector('title') + const link = document.querySelector('link') + test("The

    tag should have a font-size: 0.8em", ()=>{ // get computed styles of any element you like document.querySelector( "head" - ).innerHTML=``; - const h2Tag=document.querySelector("h2"); - var styles=window.getComputedStyle(h2Tag); + ).innerHTML = ``; + const h2Tag = document.querySelector("h2"); + var styles = window.getComputedStyle(h2Tag); expect(styles["font-size"]).toBe("0.8em"); }); - it("The H3 Tag should haave a font-size: 0.8rem", function () { + test("The

    tag should have a font-size: 0.8rem", ()=>{ // get computed styles of any element you like document.querySelector( "head" - ).innerHTML=``; - const h3Tag=document.querySelector("h3"); - var styles=window.getComputedStyle(h3Tag); + ).innerHTML = ``; + const h3Tag = document.querySelector("h3"); + var styles = window.getComputedStyle(h3Tag); expect(styles["font-size"]).toBe("0.8rem"); }); - it("You should add your rules below the existing code", function () { - document.querySelector( - "head" - ).innerHTML=``; - let cssArray=document.styleSheets[0].cssRules[0].selectorText; + test("You should not change the existing tag elements", ()=>{ + let head = document.querySelector('head') + expect(head).toBeTruthy() - expect(cssArray).toBe("#my-first-div"); - } - ) - it("You should add your rules below the existing code", function () { - document.querySelector( - "head" - ).innerHTML=``; - let cssArray=document.styleSheets[0].cssRules[1].selectorText; - expect(cssArray).toBe("#the-second-one"); - } - ) - it("You should not change the head tag", function () { + expect(meta).toBeTruthy() + + let href = link.getAttribute('href') + expect(href).toBe('./styles.css') - let meta1 = document.getElementsByTagName('head')[0].innerHTML.toString().indexOf("-1).toBeFalsy(); + expect(title).toBeTruthy() }) }); diff --git a/exercises/13-Anchor-Like-Button/README.es.md b/exercises/13-Anchor-Like-Button/README.es.md index d9291540..998e9ba7 100644 --- a/exercises/13-Anchor-Like-Button/README.es.md +++ b/exercises/13-Anchor-Like-Button/README.es.md @@ -1,21 +1,25 @@ -# `13` Enlace (anchor) como botón +# `13` Anchor Like Button -Los enlaces (anchors) no solo se usan dentro del texto: cuando va a usar enlaces (anchors) fuera del texto, es mejor hacer que se vean como botones para que sea experiencia más amigable. +Los enlaces (`anchors`) no solo se usan dentro del texto: cuando usas enlaces (`anchors`) fuera del texto, es mejor hacer que se vean como botones para que la experiencia del usuario sea más amigable. ## 📝 Instrucciones: -Siga estos pasos para que su enlace (anchor) se vea así +Sigue estos pasos para que tu enlace (`anchor`) se vea así: -1. Haz que se vea como una caja: establece el padding en 10px -2. Bordes redondeados: establece el border-radius en 4px -3. Encuentra y aplica el color: usa el selector de color para encontrar el color y aplicar el background de ese color. -4. Eliminar subrayado: establece text-decoration a none -5. Establecer el color del texto en blanco +1. Haz que se vea como una caja: establece el `padding` en `10px`. -![Example Image](https://github.com/4GeeksAcademy/css-tutorial-exercises-course/blob/master/.learn/assets/13-1.gif?raw=true) +2. Bordes redondeados: establece el `border-radius` en `4px`. -Para que el botón se vea diferente cuando el usuario pasa el mouse por encima, usamos el selector "hover":http://lmgtfy.com/?q=how+to+use+the+hover +3. El `background` debe ser de color `orange`, y cuando el ratón esté sobre el botón (`:hover`), el `background` debe ser `darkorange`. +4. Eliminar subrayado: establece `text-decoration` a `none`. -1. Dentro del selector de hover: cambie el fondo del botón a un color naranja más oscuro. +5. Establece el color del texto a blanco (`white`) ++ *Para que el botón se vea diferente cuando el usuario pasa el ratón por encima, usamos el selector `:hover`: https://www.w3schools.com/cssref/sel_hover.php* + +6. Dentro del selector `:hover` cambia el fondo del botón a `darkorange`. + +## 💻 Resultado esperado: + +![Example Image](../../.learn/assets/13-1.gif?raw=true) diff --git a/exercises/13-Anchor-Like-Button/README.md b/exercises/13-Anchor-Like-Button/README.md index 5ef9e812..b5002e2f 100644 --- a/exercises/13-Anchor-Like-Button/README.md +++ b/exercises/13-Anchor-Like-Button/README.md @@ -1,21 +1,23 @@ # `13` Anchor Like Button -Anchors are not only used within text- when you are going to use anchors outside text, it is better to make them look like buttons for a more user-friendly experience. +Anchors are not only used within text: when you are going to use anchors outside text, it is better to make them look like buttons for a more user-friendly experience. ## 📝 Instructions: +1. Make it look like a box: set `padding` to `10px`. -1. Make it look like a box: Set padding to 10px -2. Rounded borders: Set border-radius to 4px -3. Find and apply the color: Use the color picker to find the color and apply make the background to that color. -4. Remove underline: Set text-decoration to none -5. Set the color of the text to white +2. Rounded borders: set `border-radius` to `4px`. +3. The `background` should be `orange` when not hovered, and `darkorange` on hover (`:hover`). -![Example Image](https://github.com/4GeeksAcademy/css-tutorial-exercises-course/blob/master/.learn/assets/13-1.gif?raw=true) +4. Remove underline: set `text-decoration` to `none`. -To make the button look different when the user hovers over with the mouse, we use the "hover" selector: http://lmgtfy.com/?q=how+to+use+the+hover +5. Set the color of the text to `white`. ++ *To make the button look different when the user hovers over with the mouse, we use the `:hover` selector: https://www.w3schools.com/cssref/sel_hover.php* -1.Inside of the :hover selector change the background of the button to a darker orange. +6. Inside of the `:hover` selector change the background of the button to `darkorange`. +## 💻 Expected result: + +![Example Image](../../.learn/assets/13-1.gif?raw=true) diff --git a/exercises/13-Anchor-Like-Button/solution.hide.css b/exercises/13-Anchor-Like-Button/solution.hide.css new file mode 100644 index 00000000..3e80d404 --- /dev/null +++ b/exercises/13-Anchor-Like-Button/solution.hide.css @@ -0,0 +1,14 @@ +.orange-btn { + display: inline-block; + /* your code below */ + padding: 10px; + border-radius: 4px; + text-decoration: none; + color: white; + background: orange; +} + +.orange-btn:hover { + /* YOUR CODE HERE FOR THE HOVER STATE */ + background: darkorange; +} diff --git a/exercises/13-Anchor-Like-Button/styles.css b/exercises/13-Anchor-Like-Button/styles.css index 93996cbd..76fd5b9c 100644 --- a/exercises/13-Anchor-Like-Button/styles.css +++ b/exercises/13-Anchor-Like-Button/styles.css @@ -1,7 +1,10 @@ .orange-btn { - /*your code here*/ + display: inline-block; + /* your code below */ + } .orange-btn:hover { - /*YOUR CODE HERE FOR THE HOVER STATE*/ + /* YOUR CODE HERE FOR THE HOVER STATE */ + } diff --git a/exercises/13-Anchor-Like-Button/tests.js b/exercises/13-Anchor-Like-Button/tests.js index a3de631a..1006a565 100644 --- a/exercises/13-Anchor-Like-Button/tests.js +++ b/exercises/13-Anchor-Like-Button/tests.js @@ -1,111 +1,62 @@ -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"); - - -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("the padding should be '10px'", function () { +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'); + +describe("All the styles should be applied", ()=>{ + const meta = document.querySelector("meta") + const title = document.querySelector('title') + const link = document.querySelector('link') + test("The padding should be '10px'", ()=>{ document.querySelector( "head" - ).innerHTML=``; - let divTag=document.querySelector(".orange-btn"); - let classTagStyles=window.getComputedStyle(divTag); + ).innerHTML = ``; + let divTag = document.querySelector(".orange-btn"); + let classTagStyles = window.getComputedStyle(divTag); expect(classTagStyles["padding"]).toBe("10px"); }); - it("the border radius should be '4px'", function () { + test("The border-radius should be '4px'", ()=>{ document.querySelector( "head" - ).innerHTML=``; - let divTag=document.querySelector(".orange-btn"); - let classTagStyles=window.getComputedStyle(divTag); + ).innerHTML = ``; + let divTag = document.querySelector(".orange-btn"); + let classTagStyles = window.getComputedStyle(divTag); expect(classTagStyles["border-radius"]).toBe("4px"); }); - it("the border should be '1px solid #ffffff;'", function () { - document.querySelector( - "head" - - ).innerHTML=``; - let divTag=document.querySelector(".orange-btn"); - let classTagStyles=window.getComputedStyle(divTag); - expect(classTagStyles["border"]).toBe("1px solid #ffffff"); - }); - it("the background should be 'rgb(255, 153, 51)'", function () { + test("The underline should be removed", ()=>{ document.querySelector( "head" - ).innerHTML=``; - let divTag=document.querySelector(".orange-btn"); - let classTagStyles=window.getComputedStyle(divTag); - expect(classTagStyles["background"]).toBe("rgb(255, 153, 51)"); - }); - it("the underline should to be removed", function () { - document.querySelector( - "head" - - ).innerHTML=``; - let divTag=document.querySelector(".orange-btn"); - let classTagStyles=window.getComputedStyle(divTag); + ).innerHTML = ``; + let divTag = document.querySelector(".orange-btn"); + let classTagStyles = window.getComputedStyle(divTag); expect(classTagStyles["text-decoration"]).toBe("none"); }); - it("The mouse hover property should be #cc7a00", function () { - // get computed styles of any element you like - document.querySelector( - "head" - ).innerHTML=``; - let cssArray=document.styleSheets[0].cssRules; - let orangeHoverSelector=""; - for (let i=0; i{ document.querySelector( "head" - ).innerHTML=``; - let cssArray=document.styleSheets[0].cssRules[0].selectorText; + ).innerHTML = ``; + let cssArray = document.styleSheets[0].cssRules[0].selectorText; expect(cssArray).toBe(".orange-btn"); } ) -it("You should not change the head tag", function () { - - let meta1 = document.getElementsByTagName('head')[0].innerHTML.toString().indexOf("-1).toBeFalsy(); - - + test("You should not change the existing tag elements", ()=>{ + let head = document.querySelector('head') + expect(head).toBeTruthy() + expect(meta).toBeTruthy() + let href = link.getAttribute('href') + expect(href).toBe('./styles.css') + expect(title).toBeTruthy() }) }); diff --git a/learn.json b/learn.json index eb6139f0..c06fdf38 100644 --- a/learn.json +++ b/learn.json @@ -4,11 +4,24 @@ "skills": ["css-styling"], "preview": "https://github.com/4GeeksAcademy/css-tutorial-exercises-course/blob/master/preview.png?raw=true", "repository": "https://github.com/4GeeksAcademy/css-tutorial-exercises-course", - "title": "Learn CSS Interactively", + "title": { + "us": "Learn CSS Interactively", + "es": "Aprende CSS Interactivamente" + }, "intro": "https://www.youtube.com/watch?v=BDKdUPDez-U", - "description": "Learn CSS with an interactive and auto-graded tutorial with dozens of exercises.", + "description": { + "us": "Learn CSS with an interactive and auto-graded tutorial with dozens of exercises.", + "es": "Aprende CSS con una docena de ejercicios interactivos y auto-corregidos" + }, "duration": 8, "difficulty": "easy", - "video-solutions": true, - "graded": true -} \ No newline at end of file + "videoSolutions": true, + "bugsLink": "https://github.com/learnpack/learnpack/issues/new", + "projectType": "tutorial", + "graded": true, + "disabledActions": [], + "disableGrading": false, + "editor": { + "version": "1.0.73" + } +}