Creando objetos con la constructor integrando imágenes, template literals, enlaces, agregando el numero de estrellas de acuerdo a la calificación de la película.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
<script src="https://kit.fontawesome.com/e15999dd07.js" crossorigin="anonymous"></script>
<link rel="stylesheet" href="style.css">
<title>POO en JavaScript</title>
</head>
<body>
<div class="container">
<h1 class="text-center">POO en JavaScript</h1>
<section class="row mt-5 p-3 d-flex justify-content-between align-items-center" id="section">
</section>
</div>
<script src="main.js"></script>
</body>
</html>
*{
margin: 0;
padding: 0;
}
body{
}
.pelicula{
width: 23%;
height: 620px;
cursor: pointer;
background-image: linear-gradient(to top, #30cfd0 0%, #330867 100%);
border-radius: 10px;
position: relative;
}
.title{
font-size: 18px;
font-weight: 700;
}
.fa-star{
color: #fff;
}
.description{
font-size: 13px;
}
.pelicula a{
width: 90%;
position: absolute;
bottom: 2%;
left: 5%;
}
@media screen and (max-width: 900px){
.pelicula{
width: 30%;
height: 560px;
}
}
@media screen and (max-width: 780px){
.pelicula{
height: 580px;
}
}
@media screen and (max-width: 580px){
.pelicula{
width: 47%;
height: 615px;
}
}
@media screen and (max-width: 450px){
.pelicula{
width: 90%;
height: 715px;
}
}
@media screen and (max-width: 380px){
.pelicula{
width: 97%;
height: 700px;
}
}
const section = document.getElementById('section');
class Pelicula{
constructor(img, title, valor, info, url, id){
this.img = img;
this.title = title;
this.valor = valor;
this.info = info;
this.url = url;
this.id = id;
}
crear(){
section.innerHTML += `
<div class="p-2 mx-auto my-4 text-center pelicula">
<img class="img-fluid rounded" src="${this.img}" alt="">
<p class="text-center mt-3 mb-0 title">${this.title}</p>
<div class="calification d-flex justify-content-star align-items-center py-2" id="${this.id}">
</div>
<p class="description mb-0 mt-2 text-justify">
${this.info}
</p>
<a class="btn btn-info" href="${this.url}" target="_blank">
<i class="fas fa-play"></i>
</a>
</div>
`;
let estrellas = document.getElementById(this.id);
for (let index = 1; index <= this.valor; index++) {
estrellas.innerHTML += `
<i class="fas mx-1 fa-star"></i>
`;
}
}
};
class Serie extends Pelicula {
constructor(title, id, cap){
super(title, id);
this.cap = cap
}
reproducirCapitulo(){
return `Reproduciendo ${this.title} Capitulo: ${this.cap}`;
}
}
const avengers = new Pelicula('https://rb.gy/okjgrp', 'Avengers Endgame', 4, 'Después de la devastadora lucha contra Thanos, el universo queda en ruinas. Con la ayuda de los aliados restantes...', 'https://rb.gy/hocfmg', 'avengerEndG');
const spiderMan = new Pelicula('https://rb.gy/qadaeo', 'Spider-Man: Lejos de casa', 3, 'Luego de los eventos de Avengers Endgame, Peter Parker viaja con sus compañeros a Europa donde debe prepararse...', 'https://rb.gy/vz2opr', 'SpiderMHomeComing');
const banker = new Pelicula('https://rb.gy/3gzq1l', 'The Banker', 3, 'En los años 60 dos emprendedores afroamericanos contratan y preparan a un hombre blanco para que se haga pasar...', 'https://rb.gy/msl3t2', 'banker2020');
const starWars = new Pelicula('https://rb.gy/t4fmsj', 'Star Wars: El ascenso de Skywalker', 2, 'Los miembros sobrevivientes de la resistencia se enfrentan a la Primera Orden una vez más, y el legendario conflicto...', 'https://rb.gy/dpaym3', 'sWarsSkywalker');
avengers.crear();
spiderMan.crear();
banker.crear();
starWars.crear();
Curso Básico de JavaScript
COMPARTE ESTE ARTÍCULO Y MUESTRA LO QUE APRENDISTE
0 Comentarios
para escribir tu comentario


