const coupons = [
{ coupon: 'FEBRERO-2023', discount: 20 },
{ coupon: 'MARZO-2023', discount: 30 },
{ coupon: 'ABRIL-2023', discount: 40 },
{ coupon: 'MAYO-2023', discount: 50 },
{ coupon: 'JUNIO-2023', discount: 80 },
{ coupon: 'JULIO-2023', discount: 90 },
];
const price = document.querySelector('#price');
const discount = document.querySelector('#discount');
const resultDiscount = document.querySelector('#resultDiscount');
const emptyValue = document.querySelector('#emptyValue');
const Pprice = document.querySelector('#Pprice');
const Pdiscount = document.querySelector('#Pdiscount');
const couponId = document.querySelector('#couponId');
const calculateDiscount = () => {
const inputPrice = parseFloat(price.value);
const inputDiscount = parseFloat(discount.value);
if (inputPrice <= 0 || inputPrice == '') {
emptyValue.innerHTML =
'<p class="message">Ingrese el precio y el descuento(no mayor a 100%) en los campos correspondientes 😊</p>';
return;
}
if (inputDiscount > 100) {
emptyValue.innerHTML =
'<p class="message">Ingrese el precio y el descuento(no mayor a 100%) en los campos correspondientes 😊</p>';
return;
}
const calculate = (inputPrice * (100 - inputDiscount)) / 100;
Pprice.innerHTML = `
<div class="table--content">
<p>Precio</p>
<p>$${!inputPrice == '' ? inputPrice : '0'}</p>
</div>`;
Pdiscount.innerHTML = `
<div class="table--content">
<p>Descuento</p>
<p>${!inputDiscount == '' ? inputDiscount : '0'}%</p>
</div>`;
resultDiscount.innerHTML = `
<div class="table--content">
<p>Precio Total</p>
<p>$${!calculate == '' ? calculate : '0'}</p>
</div>`;
};
price.addEventListener('input', calculateDiscount);
discount.addEventListener('input', calculateDiscount);
body {
height: 100vh;
background-image: url('../../../assets/bgClr.jpg');
background-position: bottom;
background-repeat: no-repeat;
background-size: cover;
overflow-y: hidden;
}
main {
display: grid;
place-content: center;
height: 100vh;
}
.linkHome {
position: absolute;
top: 5vh;
left: 5vw;
color: #fff;
font-size: 25px;
}
.card__container {
position: relative;
display: flex;
align-items: center;
justify-content: space-evenly;
flex-direction: column;
width: 740px;
/* max-width: 360px; */
height: 590px;
background: linear-gradient(
109.56deg,
rgba(255, 255, 255, 0.5) 0%,
rgba(255, 255, 255, 0) 126.32%
);
border-radius: 30px;
color: #fff;
font-size: 18px;
box-shadow: 0 20px 100px rgba(255, 255, 255, 0.19),
0 20px 100px rgba(255, 255, 255, 0.23);
backdrop-filter: blur(30px);
}
input[type='number']::-webkit-inner-spin-button,
input[type='number']::-webkit-outer-spin-button {
-webkit-appearance: none;
margin: 0;
}
.main--title {
position: absolute;
top: 0;
font-size: 30px;
font-weight: 600;
font-family: Arial, sans-serif;
text-transform: uppercase;
letter-spacing: 25px;
}
form {
position: relative;
width: 80%;
margin-top: 80px;
}
textarea {
resize: none;
}
input,
textarea {
width: 100%;
margin: 15px 0;
padding: 8px;
background: transparent;
border: 0;
box-sizing: border-box;
color: inherit;
}
input:focus,
textarea:focus {
outline: 0;
}
label {
position: absolute;
left: 0;
width: 100%;
}
label::before,
label::after {
content: ' ';
position: absolute;
height: 2.25em;
width: 5%;
border-width: 1px;
border-style: solid;
pointer-events: none;
transition: 0.75s;
z-index: 1;
}
label::before {
border-right: 0;
}
label::after {
right: 0;
border-left: 0;
}
.label-text {
position: absolute;
right: 0;
display: block;
padding: 0.5em 1em;
background: linear-gradient(
109.56deg,
rgba(255, 255, 255, 0.5) 0%,
rgba(255, 255, 255, 0) 126.32%
);
transition: 0.5s;
}
.label-text::after {
content: ' ';
display: block;
border-top: 1px solid;
transition: 0.5s;
}
input:focus + label::before,
input:focus + label::after {
width: 50%;
}
input:focus + label .label-text {
transform: translate3d(100%, 0, 0);
}
input:focus + label .label-text::after {
width: 1em;
transform: translate3d(-100%, -0.75em, 0);
}
#price {
color: #dbcdd9;
}
#discount {
color: #bcafd1;
}
#couponId:focus + label::before,
#couponId:focus + label::after,
#discount:focus + label::before,
#discount:focus + label::after,
#price:focus + label::before,
#price:focus + label::after {
border-color: #fff;
}
.price {
color: #fff;
top: 0.5em;
}
.coupon::before,
.coupon::after,
.discount::before,
.discount::after,
.price::before,
.price::after {
border-color: rgba(219, 205, 217, 0.3);
top: 0;
}
.discount {
color: #fff;
top: 3.85em;
}
.coupon {
top: 7.18em;
}
.couponSection input {
padding: 5px;
}
.table {
display: flex;
align-items: flex-end;
flex-direction: column;
justify-content: flex-end;
/* height: 100%; */
}
.table--container {
display: flex;
flex-direction: column;
}
.table--content {
display: flex;
flex-direction: row;
justify-content: space-between;
gap: 10px;
}
.message {
position: absolute;
}
#toggleButton {
position: relative;
width: 100%;
margin: 15px 0;
padding: 8px 0;
background: transparent;
color: #dfa6b9;
border: 1px solid;
font-size: bold;
font-size: 18px;
transition: 0.3s;
}
#toggleButton:hover {
background: rgba(233, 22, 93, 0.2);
}
@media (min-width: 660px) and (max-width: 856px) {
body {
max-width: calc(100% - 12em);
}
}