JSFiddle - React, Tailwind, and code Playground
by m4xout
HTML
<p><span id="myBtn" class="label">Shipping to Europe? <span style="text-decoration:underline;">Read this first!</span></span></p>
<!-- The Modal -->
<div id="myModal" class="modal">
<!-- Modal content -->
<div class="modal-content">
<span class="close">×</span>
<div class="eu-shipping">
<h2>mini guide to Europe orders</h2>
{{ 'EU_shipping_mini_guide_notice_web.png' | asset_url | img_tag }}
<p>VAT is removed at the checkout so you only pay it once to the courier.</p>
<p>When your locker has arrived in your country, look out for an email/text message from the courier.</p>
<p>This will include an invoice for: <br>
● VAT (around 20% depending on your country)<br>
● Customs processing fee (around 15-20€)</p>
<p>This invoice must be paid by you to have your goods released from customs for delivery.</p>
<a href="https://uk.mustardmade.com/pages/european-orders" target="_blank" style="font-size:28px" >more info</a>
</div>
</div>
</div>
CSS
.eu-shipping h2 {
color:#fff;
margin-bottom: 16px;
}
.eu-shipping {
font-weight: 500;
}
#shopify-section-footer:before,
.site-control {
z-index: 4;
}
#myBtn {
font-weight: 700;
font-size: 1.25rem;
cursor: pointer;
}
/* The Modal (background) */
.modal {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
left: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: rgb(255,255,255); /* Fallback color */
background-color: rgba(255,255,255,0.8); /* Black w/ opacity */
}
/* Modal Content/Box */
.modal-content {
background-color: #ebd1ce;
margin: 15% auto; /* 15% from the top and centered */
padding: 30px 30px;
border: 0 none;
width: 90%; /* Could be more or less, depending on screen size */
max-width: 560px;
}
/* The Close Button */
.close {
color: #fff;
float: right;
font-size: 28px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: #CF6F77;
text-decoration: none;
cursor: pointer;
}
.eu-shipping {
text-align: center;
color: #fff;
}
.eu-shipping img {
width: 100%;
margin: 0 auto;
}
.eu-shipping label {
font-weight: 700;
font-size: 1.25rem;
}
JavaScript
console.log('EU link script loaded 1');
window.onload = function(){
console.log('EU link script loaded 2');
// Get the modal
var modal = document.getElementById("myModal");
// Get the button that opens the modal
var btnEu = document.getElementById("myBtn");
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];
// When the user clicks on the button, open the modal
btnEu.onclick = function() {
modal.style.display = "block";
console.log('EU link clicked');
}
// When the user clicks on <span> (x), close the modal
span.onclick = function() {
modal.style.display = "none";
}
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
};