-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Challenge js/personas detalles #12
Open
stom83
wants to merge
4
commits into
main
Choose a base branch
from
challenge_js/personas-detalles
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<link | ||
rel="stylesheet" | ||
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" | ||
integrity="sha512-KfkfwYDsLkIlwQp6LFnl8zNdLGxu9YAA1QvwINks4PhcElQSvqcyVLLD9aMhXd13uQjoXtEKNosOWaZqXgel0g==" | ||
crossorigin="anonymous" | ||
referrerpolicy="no-referrer" | ||
/> | ||
<title>Document</title> | ||
<link rel="stylesheet" href="./style.css" /> | ||
<script defer src="./main.js"></script> | ||
</head> | ||
|
||
<body> | ||
<main class="main"> | ||
<div class="card"></div> | ||
</main> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
class App { | ||
/** | ||
* @typedef User | ||
* @property {String} name | ||
* @property {String} picture | ||
* @property {String} email | ||
*/ | ||
|
||
#skills = [ | ||
['<i class="fa-brands fa-js btn__icon"></i>', "Js"], | ||
['<i class="fa-brands fa-css3 btn__icon"></i>', "Css"], | ||
['<i class="fa-brands fa-html5 btn__icon"></i>', "Html"], | ||
['<i class="fa-brands fa-python btn__icon"></i>', "Python"], | ||
['<i class="fa-solid fa-server btn__icon"></i>', "Backend"], | ||
['<i class="fa-solid fa-database btn__icon"></i>', "Mongodb"], | ||
['<i class="fa-solid fa-laptop-code btn__icon"></i>', "Hacking"], | ||
['<i class="fa-brands fa-react btn__icon"></i>', "React"], | ||
['<i class="fa-brands fa-java btn__icon"></i>', "Java"], | ||
['<i class="fa-solid fa-function btn__icon"></i>', "D. Science"], | ||
['<i class="fa-solid fa-robot btn__icon"></i>', "M. learning"], | ||
['<i class="fa-brands fa-figma btn__icon"></i>', "UI-UX"], | ||
]; | ||
|
||
constructor() { | ||
this.#fetchUser() | ||
} | ||
|
||
/** | ||
* | ||
* @param {Array} arr | ||
*/ | ||
#randomNumbers(arr) { | ||
return Math.floor(Math.random() * arr.length); | ||
} | ||
|
||
/** | ||
* | ||
* @param {User} user | ||
*/ | ||
#createUser(user) { | ||
const card = document.querySelector(".card"); | ||
const mySet = new Set(); | ||
|
||
for (let i = 0; i < 5; i++) { | ||
const number = this.#randomNumbers(this.#skills); | ||
mySet.add(number); | ||
} | ||
|
||
const buttons = () => { | ||
const randomSkills = Array.from(mySet); | ||
|
||
return randomSkills | ||
.map((skill) => { | ||
return ` | ||
<button class="btn" type="button"> | ||
${this.#skills[skill][0]} | ||
${this.#skills[skill][1]} | ||
</button> | ||
`; | ||
}) | ||
.join(""); | ||
}; | ||
|
||
const userHtml = ` | ||
<div class="card__head"> | ||
<figure class="avatar-container"> | ||
<img | ||
class="avatar" | ||
src="${user.picture}" | ||
alt="image" | ||
/> | ||
</figure> | ||
<h1 class="heading"> | ||
<span> | ||
Name <span class="heading--main"> ${user.name} </span> | ||
</span> | ||
<span> | ||
Email <span class="heading--subtitle"> ${user.email} </span> | ||
</span> | ||
</h1> | ||
</div> | ||
|
||
<article> | ||
<h4>Hobbies</h4> | ||
<p> | ||
Lorem ipsum dolor sit amet, consectetur adipisicing elit. | ||
Reiciendis, et pariatur deleniti cupiditate harum odio voluptate | ||
magnam ab modi sunt inventore numquam vitae quod necessitatibus | ||
</p> | ||
</article> | ||
|
||
<div class="buttons-box"> | ||
<h4>Skills</h4> | ||
<div class="skills-container"> | ||
${buttons()} | ||
</div> | ||
</div> | ||
`; | ||
|
||
card?.insertAdjacentHTML("afterbegin", userHtml); | ||
} | ||
|
||
#fetchUser() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @stomdj no usar # para declarar funciones |
||
fetch("https://randomuser.me/api/") | ||
.then((res) => { | ||
return res.json(); | ||
}) | ||
.then((res) => { | ||
const payload = res?.results[0]; | ||
const { first, last } = payload.name; | ||
|
||
let { email } = payload; | ||
email = email.slice(0, -4); | ||
const { large, medium, thumbnail } = payload.picture; | ||
|
||
this.#createUser({ | ||
name: `${first} ${last}`, | ||
email: email, | ||
picture: large || medium || thumbnail || "", | ||
}); | ||
}); | ||
} | ||
} | ||
|
||
const app = new App(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
@import url("https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap"); | ||
|
||
:root { | ||
font-family: "Montserrat", sans-serif; | ||
font-size: 62.5%; | ||
box-sizing: border-box; | ||
|
||
--white-100: rgb(252, 252, 252); | ||
--white-150: rgb(242, 242, 247); | ||
--primary: rgb(109, 40, 217); | ||
--base-content: rgb(46, 44, 82); | ||
} | ||
|
||
*, | ||
*::after, | ||
*::before { | ||
margin: 0; | ||
padding: 0; | ||
outline: none; | ||
scroll-behavior: smooth; | ||
} | ||
|
||
body { | ||
font-size: 1.5rem; /* 1.6px */ | ||
color: var(--base-content); | ||
height: 100vh; | ||
font-weight: 400; | ||
background-color: var(--white-150); | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
|
||
.card { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: space-between; | ||
background-color: var(--white-100); | ||
border-radius: 2rem; | ||
padding: 4rem; | ||
width: 48rem; | ||
min-height: 30rem; | ||
box-shadow: 0px 0px 12px 2px rgba(46, 44, 82, 0.15); | ||
} | ||
|
||
.avatar-container { | ||
width: 12rem; | ||
height: 12rem; | ||
} | ||
|
||
.avatar { | ||
object-fit: cover; | ||
border-radius: 50%; | ||
width: 100%; | ||
height: 100%; | ||
} | ||
|
||
.card__head { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
gap: 2rem; | ||
} | ||
|
||
.heading { | ||
letter-spacing: -0.4px; | ||
font-size: 1.3rem; | ||
} | ||
|
||
.heading > * { | ||
display: block; | ||
} | ||
|
||
.heading--main { | ||
font-weight: 400; | ||
font-size: 2.6rem; | ||
} | ||
|
||
.heading--subtitle { | ||
font-weight: 400; | ||
font-size: 1.5rem; | ||
} | ||
|
||
.skills-container { | ||
width: 28rem; | ||
display: flex; | ||
gap: 0.6rem; | ||
flex-wrap: wrap; | ||
} | ||
|
||
article p { | ||
font-size: 1.4rem; | ||
} | ||
|
||
h4 { | ||
font-size: 2rem; | ||
} | ||
|
||
.btn { | ||
font-weight: 600; | ||
cursor: pointer; | ||
border: none; | ||
color: var(--white-150); | ||
padding: 0.5rem 1.2rem; | ||
border-radius: 25rem; | ||
box-shadow: 0px 0px 8px 1px rgba(46, 44, 82, 0.35); | ||
background-color: var(--primary); | ||
transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); | ||
} | ||
|
||
.btn:hover { | ||
transform: scale(1.08) translateY(-2px); | ||
box-shadow: 0px 0px 16px 1px rgba(46, 44, 82, 0.35); | ||
} | ||
|
||
.btn:active { | ||
transform: scale(1) translateY(1px); | ||
box-shadow: 0px 0px 4px 1px rgba(46, 44, 82, 0.35); | ||
} | ||
|
||
.btn__icon { | ||
font-size: 1.8rem; | ||
} | ||
|
||
.buttons-box { | ||
gap: 2rem; | ||
display: flex; | ||
justify-content: flex-end; | ||
align-items: center; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stomdj borrar # de todos los metodos/variables