JSFiddle - React, Tailwind, and code Playground
by luka kupunia
HTML
<div class="container">
<div class="mobile-smart-box">
<div class="smart-box-item">
<div class="button">
<span class="noto-bold font-16">ყიდვა</span>
<svg xmlns="http://www.w3.org/2000/svg" width="6" height="8" viewBox="0 0 6 8">
<path id="Polygon_11" data-name="Polygon 11" d="M4,0,8,6H0Z" transform="translate(6) rotate(90)" fill="#292562" />
</svg>
</div>
<div class="smart-box-body">
<div class="items">
<div class="item" data-item="1">
<img src="https://i.picsum.photos/id/807/60/60.jpg?hmac=Tl-CqKsrjn1Dt5LF_vlNydyTSm3A6WOUgZPYzlrV2gc" alt="">
<span class="noto-semibold font-16">ჯანმრთელობა</span>
</div>
<div class="item" data-item="2">
<img src="https://i.picsum.photos/id/807/60/60.jpg?hmac=Tl-CqKsrjn1Dt5LF_vlNydyTSm3A6WOUgZPYzlrV2gc" alt="">
<span class="noto-semibold font-16">ავტო</span>
</div>
<div class="item" data-item="3">
<img src="https://i.picsum.photos/id/807/60/60.jpg?hmac=Tl-CqKsrjn1Dt5LF_vlNydyTSm3A6WOUgZPYzlrV2gc" alt="">
<span class="noto-semibold font-16">მოგზაურობა</span>
</div>
<div class="item" data-item="4">
<img src="https://i.picsum.photos/id/807/60/60.jpg?hmac=Tl-CqKsrjn1Dt5LF_vlNydyTSm3A6WOUgZPYzlrV2gc" alt="">
<span class="noto-semibold font-16">სახლი</span>
</div>
</div>
<div class="inner-items">
<div class="item" data-item="1">
<div class="heading">
<img src="https://i.picsum.photos/id/807/60/60.jpg?hmac=Tl-CqKsrjn1Dt5LF_vlNydyTSm3A6WOUgZPYzlrV2gc" alt="">
<span class="noto-semibold font-16">ავტო</span>
<div class="close-btn">
<svg xmlns="http://www.w3.org/2000/svg"...
CSS
body {
margin: 0;
}
* {
box-sizing: border-box;
}
a {
text-decoration: none;
}
.container {
width: 100%;
padding: 0 17px;
}
.mobile-smart-box {
width: 100%;
position: relative;
}
.mobile-smart-box .button {
width: 100%;
height: 60px;
display: flex;
align-items: center;
justify-content: space-between;
cursor: pointer;
transition: .6s;
user-select: none;
}
.mobile-smart-box .button svg {
transition: .6s;
}
.mobile-smart-box .button svg path {
transition: .6s;
}
.mobile-smart-box .smart-box-item {
border: 1px solid #9199B4;
border-radius: 8px;
-webkit-box-shadow: 0px 0px 20px 0px rgba(0,153,255,0.05);
-moz-box-shadow: 0px 0px 20px 0px rgba(0,153,255,0.05);
box-shadow: 0px 0px 20px 0px rgba(0,153,255,0.05);
margin-bottom: 10px;
padding-left: 27px;
padding-right: 30px;
}
.mobile-smart-box .smart-box-body {
/* display: none; */
border-top: 1px solid #9199B4;
}
.mobile-smart-box .smart-box-body .items {
padding-top: 28px;
/* display: none; */
}
.mobile-smart-box .smart-box-body .items .item {
display: flex;
align-items: center;
margin-bottom: 35px;
cursor: pointer;
}
.mobile-smart-box .smart-box-body .items .item img {
max-width: 45px;
height: auto;
margin-right: 45px;
}
.mobile-smart-box .smart-box-body .inner-items {
margin-top: 30px;
margin-bottom: 17px;
}
.mobile-smart-box .smart-box-body .inner-items .item {
display: none;
}
.mobile-smart-box .smart-box-body .inner-items .item .heading {
display: flex;
align-items: center;
position: relative;
padding-right: 25px;
margin-bottom: 27px;
}
.mobile-smart-box .smart-box-body .inner-items .item .heading img {
max-width: 45px;
margin-right: 35px;
}
.mobile-smart-box .smart-box-body .inner-items .item .heading .close-btn {
cursor: pointer;
position: absolute;
right: 0;
}
.mobile-smart-box .smart-box-body .inner-items .item...
JavaScript
var mobileSmartBox = {
init : function(){
this.slideItemToggle()
this.itemClick()
this.closeClick()
this.mobilePopup()
},
mobilePopup : function(){
document.querySelector('#mobile-smart-box-popup').addEventListener('click',function(e){
document.body.classList.remove('active-mobile-popup')
})
document.querySelector('#mobile-smart-box-popup #close-mob-popup').addEventListener('click',function(e){
document.body.classList.remove('active-mobile-popup')
})
document.querySelector('#mobile-smart-box-popup .content').addEventListener('click',function(e){
e.stopPropagation()
})
$('.mobile-smart-box .smart-box-body .inner-items .item .button').on('click',function(){
document.body.classList.add('active-mobile-popup')
$('#mobile-smart-box-popup .content a.buy').attr('href',$(this).attr('data-buy-href'))
$('#mobile-smart-box-popup .content a.info').attr('href',$(this).attr('data-info-href'))
console.log($(this).attr('data-buy-href'),$(this).attr('data-info-href'))
})
},
slideItemToggle : function(){
$('.mobile-smart-box .button').on('click',function(){
var self = this
$(this).parent().addClass('active')
$(this).parent().find('.smart-box-body').slideToggle()
})
},
itemClick : function(){
$('.mobile-smart-box .smart-box-body .items .item').on('click',function(){
var index = $(this).attr('data-item');
$('.mobile-smart-box .smart-box-body .items').css({ animation : 'fadeeOut 0.5s both' })
setTimeout(function(){
$('.mobile-smart-box .smart-box-body .inner-items .item[data-item="' + index + '"]').show()
$('.mobile-smart-box .smart-box-body .inner-items .item[data-item="' + index + '"]').css({ animation : 'fadee 0.5s both' })
$('.mobile-smart-box .smart-box-body .items').hide()
...