JSFiddle - React, Tailwind, and code Playground
by Viktor L
HTML
<button class="button call" data-src="modal1">Дверной Континент Промо (Миланский орех)</button>
<button class="button call" data-src="modal2">Дверной Континент Классик (Орех темный)</button>
<div id="tag-id"></div>
CSS
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
input[type="text"],
input[type="tel"],
input[type="email"] {
display: block;
padding: 0 17px;
width: 100%;
height: 45px;
line-height: 45px;
font: 600 18px 'Roboto', sans-serif;
color: #000;
background: transparent;
border: 1px solid rgba(0,0,0,.11);
border-radius: 3px;
-webkit-transition: all .3s ease;
-o-transition: all .3s ease;
transition: all .3s ease;
}
::-webkit-input-placeholder {
opacity: 1;
font-weight: 300;
color: #393939;
}
::-moz-placeholder {
opacity: 1;
font-weight: 300;
color: #393939;
}
:-moz-placeholder {
opacity: 1;
font-weight: 300;
color: #393939;
}
:-ms-input-placeholder {
opacity: 1;
font-weight: 300;
color: #393939;
}
.some-form {
width: 30%;
margin: 36px auto;
}
.form {
padding: 30px;
background: #f7fafb;
color: #000;
border-radius: 3px;
-webkit-box-shadow: 0 39px 57px rgba(0,0,0,.19);
-moz-box-shadow: 0 39px 57px rgba(0,0,0,.19);
box-shadow: 0 39px 57px rgba(0,0,0,.19);
}
.some-form__header {
margin-bottom: 41px;
padding-top: 12px;
font-size: 26px;
line-height: 1;
letter-spacing: -0.2px;
text-align: center;
}
.some-form__line {
display: block;
position: relative;
margin-bottom: 15px;
}
.some-form__line-required input[type="text"],
.some-form__line-required input[type="tel"],
.some-form__line-required input[type="email"] {
border-color: #f45a57;
}
.some-form__line-required .some-form__hint {
opacity: 1;
z-index: auto;
}
.some-form__hint {
z-index: -1;
opacity: 0;
position: absolute;
top: 100%;
left: 0;
margin-top: -6px;
padding: 0 12px;
width: 100%;
background: #f45a57;
color: #fff;
font-size: 12px;
line-height: 1.333333;
-webkit-transition: all .3s ease;
-o-transition: all .3s ease;
transition: all .3s ease;
}
.title {
font-weight: bold;
}
.button {
display: inline-block;
padding: 14px 15px 16px;
text-align:...
JavaScript
const ref = {
"modal1" : {
"images" : [
"images/doors/1/vhodnaya-metallicheskaya-dver-dvernoi-kontinent-promo-milanskiy-oreh-750x750.jpg",
"images/doors/1/dk-certifikat-750x750.jpg",
"images/doors/1/frn-fal-cil-750x750.jpg",
"images/doors/1/glaz-750x750.jpg",
"images/doors/1/ptl-osevie-750x750.jpg"
],
"name" : "Входная металлическая дверь Дверной Континент Промо (Миланский орех)",
"price" : "8500 руб.",
"model" : "ASTRA"
},
"modal2" : {
"images" : [
"images/doors/sertifikat-750x750.jpg",
"images/doors/vhodnaya-metallicheskaya-dver-dvernoi-kontinent-delta-gamma.-750x750.png",
"images/doors/frn-fal-cil-750x750.jpg",
"images/doors/1/glaz-750x750.jpg",
"images/doors/zmk-kilit-osn-cil-750x750.jpg"
],
"name" : "Входная металлическая дверь Дверной Континент Классик (Орех темный)",
"price" : "8500 руб.",
"model" : "CLASSIK"
}
};
const actionForm = (action, text) => {
return `<div class="some-form">
<form action="${action}" method="POST" class="form js-form-validate">
<div class="some-form__header title">${text.name}</div>
<p>${text.model}</p>
<p>${text.price}</p>
<div class="some-form__line">
<input
type="tel"
name="phone"
id="phone"
placeholder="(555) 555-5555"
autocomplete="tel"
maxlength="14"
class="form-control"
pattern="[(][0-9]{3}[)] [0-9]{3}-[0-9]{4}" required />
</div>
<div class="some-form__submit">
<input type="submit" class="button button_submit button_wide"/>
</div>
</form></div>`
}
const callButton = [...document.querySelectorAll('.button.call')];
callButton.map(oneBut => {
oneBut.addEventListener("click", function() {
document.getElementById('tag-id').innerHTML = actionForm('/echo/json/', ref[this.dataset.src]);
...