Skip to content

Commit 61aea5a

Browse files
authored
Merge pull request #116 from AnggieAlava/bug/1503-jumbotron
[Bug-1503] Componente Jumbotron actualizado con clases de Bosstrap 5.2
2 parents ac52822 + 55d082d commit 61aea5a

File tree

10 files changed

+196
-190
lines changed

10 files changed

+196
-190
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# `03.4` Hero Component
2+
3+
Usando todo lo que has aprendido...
4+
5+
## 📝 Instrucciones:
6+
7+
1. Construye un componente `Hero` que reciba las siguientes propiedades:
8+
9+
```jsx
10+
<Hero
11+
title="Welcome to react"
12+
description="React is the most popular rendering library in the world"
13+
buttonLabel="Go to the official website"
14+
buttonURL="https://reactjs.org/"
15+
/>
16+
```
17+
18+
## 💻 Resultado Esperado:
19+
20+
![Hero](../../.learn/assets/03.4-1.png?raw=true)
21+
22+
## 💡 Pistas:
23+
24+
- Recuerda usar los prop-types para validar las propiedades de tu componente.
25+
26+
- Tu componente debería generar un HTML similar a este:
27+
28+
```html
29+
<div class="container m-5">
30+
<h1 class="display-4">Welcome to react</h1>
31+
<p class="lead">React is the most popular rendering library in the world</p>
32+
<a class="btn btn-primary btn-lg" href="https://reactjs.org/" role="button"
33+
>Go to the official website</a
34+
>
35+
</div>
36+
```
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
tutorial: 'https://www.youtube.com/watch?v=zv6HPveyz6g'
3+
---
4+
5+
# `03.4` Hero Component
6+
7+
Using everything you have learned so far...
8+
9+
## 📝 Instructions:
10+
11+
1. Build a `Hero` component that receives the following properties:
12+
13+
```jsx
14+
<Hero
15+
title="Welcome to react"
16+
description="React is the most popular rendering library in the world"
17+
buttonLabel="Go to the official website"
18+
buttonURL="https://reactjs.org/"
19+
/>
20+
```
21+
22+
## 💻 Expected result:
23+
24+
![Hero](../../.learn/assets/03.4-1.png?raw=true)
25+
26+
## 💡 Hints:
27+
28+
- Remember to use prop-types to validate your component properties.
29+
30+
- Your HTML's component should be something like this:
31+
32+
```html
33+
<div class="container m-5">
34+
<h1 class="display-4">Welcome to react</h1>
35+
<p class="lead">React is the most popular rendering library in the world</p>
36+
<a class="btn btn-primary btn-lg" href="https://reactjs.org/" role="button"
37+
>Go to the official website</a
38+
>
39+
</div>
40+
```
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import React from 'react';
2+
import ReactDOM from 'react-dom';
3+
import PropTypes from 'prop-types';
4+
5+
const Hero = (props) => {
6+
// Here you have to return expected html using the properties being passed to the component
7+
};
8+
9+
Hero.propTypes = {
10+
// PropTypes here
11+
title: PropTypes.string,
12+
};
13+
14+
ReactDOM.render(
15+
<Hero
16+
title="Welcome to react"
17+
description="React is the most popular rendering library in the world"
18+
buttonLabel="Go to the official website"
19+
buttonURL="https://reactjs.org/"
20+
/>,
21+
22+
document.querySelector('#myDiv')
23+
);
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import React from 'react';
2+
import ReactDOM from 'react-dom';
3+
import PropTypes from 'prop-types';
4+
5+
const Hero = (props) => {
6+
// Here you have to return expected html using the properties being passed to the component
7+
return (
8+
<div className="container m-5">
9+
<h1 className="display-4">{props.title}</h1>
10+
<p className="lead">{props.description}</p>
11+
<a
12+
className="btn btn-primary btn-lg"
13+
href={props.buttonURL}
14+
role="button">
15+
{props.buttonLabel}
16+
</a>
17+
</div>
18+
);
19+
};
20+
21+
Hero.propTypes = {
22+
// PropTypes here
23+
title: PropTypes.string,
24+
description: PropTypes.string,
25+
buttonLabel: PropTypes.string,
26+
buttonURL: PropTypes.string,
27+
};
28+
29+
ReactDOM.render(
30+
<Hero
31+
title="Welcome to react"
32+
description="React is the most popular rendering library in the world"
33+
buttonLabel="Go to the official website"
34+
buttonURL="https://reactjs.org/"
35+
/>,
36+
37+
document.querySelector('#myDiv')
38+
);
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import ReactDOM from 'react-dom';
2+
import { WhatToRender } from './app.jsx';
3+
import jsxToString from 'jsx-to-string';
4+
import renderer from 'react-test-renderer';
5+
6+
jest.mock('react-dom', () => ({ render: jest.fn() }));
7+
8+
test('ReactDOM needs to be called once', () => {
9+
expect(ReactDOM.render.mock.calls.length).toBe(1);
10+
});
11+
12+
test('Component title has to be passed properly', () => {
13+
const component = ReactDOM.render.mock.calls[0][0];
14+
expect(component.props.title).toBe('Welcome to react');
15+
});
16+
17+
test('Component description has to be passed properly', () => {
18+
const component = ReactDOM.render.mock.calls[0][0];
19+
expect(component.props.description).toBe(
20+
'React is the most popular rendering library in the world'
21+
);
22+
});
23+
24+
test('Component buttonLabel has to be passed properly', () => {
25+
const component = ReactDOM.render.mock.calls[0][0];
26+
expect(component.props.buttonLabel).toBe('Go to the official website');
27+
});
28+
29+
test('Component buttonURL has to be passed properly', () => {
30+
const component = ReactDOM.render.mock.calls[0][0];
31+
expect(component.props.buttonURL).toBe('https://reactjs.org/');
32+
});
33+
34+
test('The component should return the exact HTML', () => {
35+
const tree = renderer.create(ReactDOM.render.mock.calls[0][0]).toJSON();
36+
expect(tree).toMatchInlineSnapshot(`
37+
<div
38+
className="container m-5"
39+
>
40+
<h1
41+
className="display-4"
42+
>
43+
Welcome to react
44+
</h1>
45+
<p
46+
className="lead"
47+
>
48+
React is the most popular rendering library in the world
49+
</p>
50+
<a
51+
className="btn btn-primary btn-lg"
52+
href="https://reactjs.org/"
53+
role="button"
54+
>
55+
Go to the official website
56+
</a>
57+
</div>
58+
`);
59+
});

exercises/03.4-jumbotron/README.es.md

Lines changed: 0 additions & 34 deletions
This file was deleted.

exercises/03.4-jumbotron/README.md

Lines changed: 0 additions & 38 deletions
This file was deleted.

exercises/03.4-jumbotron/app.jsx

Lines changed: 0 additions & 24 deletions
This file was deleted.

exercises/03.4-jumbotron/solution.hide.jsx

Lines changed: 0 additions & 35 deletions
This file was deleted.

exercises/03.4-jumbotron/tests.js

Lines changed: 0 additions & 59 deletions
This file was deleted.

0 commit comments

Comments
 (0)