Skip to content
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

Generador de excusas #104

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,36 @@ import "./style.css";
import "./assets/img/rigo-baby.jpg";
import "./assets/img/4geeks.ico";

import Excusa from "./excusa.js";
import gr from "./getRandom";

window.onload = function() {
//write your code here
console.log("Hello Rigo from the console!");

let quien = [
"Darwin Nuñez",
"Mi perro Toto",
"El vecino",
"Joaquito de Piedras Blancas"
];
let accion = ["le erró a", "meó", "me robó", "me pegó con"];
let que = ["la pelota", "el sillón", "mi gato", "la alpargata"];
let cuando = [
"durante la clase",
"otra vez",
"mientras cargaba el codespace💤"
];

let botonGenerarExcusa = document.querySelector("#botonGenerar");
let contenedorExcusa = document.querySelector("code");
let botonCopiar = document.querySelector("#botonCopiar");

botonGenerarExcusa.addEventListener("click", function(e) {
let excusa = new Excusa(gr(quien), gr(accion), gr(que), gr(cuando));
contenedorExcusa.innerHTML = excusa.getExcusa();
});

botonCopiar.addEventListener("click", function(e) {
navigator.clipboard.writeText(contenedorExcusa.innerText);
});
};
12 changes: 12 additions & 0 deletions src/excusa.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export default class Excusa {
constructor(quien, accion, que, cuando) {
this.quien = quien;
this.accion = accion;
this.que = que;
this.cuando = cuando;
}

getExcusa() {
return `${this.quien} ${this.accion} ${this.que} ${this.cuando}`;
}
}
3 changes: 3 additions & 0 deletions src/getRandom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function getRandom(array) {
return array[Math.floor(Math.random() * array.length)];
}
41 changes: 30 additions & 11 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Hello Rigo with Vanilla.js</title>
<title>Generador de excusas</title>
<link
rel="stylesheet"
href="https://use.fontawesome.com/releases/v5.2.0/css/all.css"
Expand All @@ -13,16 +13,35 @@
<link rel="shortcut icon" href="./4geeks.ico" />
</head>
<body>
<div class="container-fluid text-center">
<h1 class="mt-5">Hello Rigo!</h1>
<img src="./rigo-baby.jpg" />
<p class="alert alert-warning mt-4">
If this text is <b>not</b> centered and <b>yellow</b>, you probably have
an error
</p>
<div class="fixed-bottom p-4">
Made with ❤️ by
<a href="https://www.4geeksacademy.com">4Geeks Academy</a>
<div class="card text-center">
<div class="card-header">
🤥
</div>
<div class="card-body">
<h5 class="card-title">Generador de excusas</h5>
<div id="copyAlert" class="p-0"></div>
<code class="card-text d-block p-4 m-3 border rounded">
Mentir está mal pero si querés podés cliquear el dado
</code>
<button
type="button"
class="btn btn-primary p-1 m-1"
style="width: 40px;"
id="botonGenerar"
>
🎲
</button>
<button
type="button"
class="btn btn-secondary p-1 m-1"
style="width: 40px;"
id="botonCopiar"
>
📎
</button>
</div>
<div class="card-footer text-muted">
Desarrollado por <a href="http://github.com/j04quin">j04quin</a>
</div>
</div>
</body>
Expand Down