Spaces:
Running
Running
File size: 3,340 Bytes
0b1db27 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
class CookieBannerComponent extends HTMLElement {
connectedCallback() {
this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = `
<style>
:host {
display: block;
position: fixed;
bottom: 0;
left: 0;
width: 100%;
background: rgba(15, 23, 42, 0.95);
backdrop-filter: blur(10px);
border-top: 1px solid rgba(212, 175, 55, 0.2);
padding: 1.5rem 5%;
z-index: 10000;
transform: translateY(100%);
transition: transform 0.5s ease;
}
:host(.visible) {
transform: translateY(0);
}
.cookie-content {
max-width: 1200px;
margin: 0 auto;
display: flex;
flex-direction: column;
gap: 1rem;
}
.cookie-text {
color: #CBD5E1;
line-height: 1.6;
}
.cookie-actions {
display: flex;
gap: 1rem;
flex-wrap: wrap;
}
.btn {
padding: 0.75rem 1.5rem;
border-radius: 30px;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
border: none;
}
.btn-accept {
background: linear-gradient(45deg, #D4AF37, #F8FAFC);
color: #0F172A;
}
.btn-reject {
background: transparent;
color: #CBD5E1;
border: 1px solid #475569;
}
.btn-customize {
background: transparent;
color: #CBD5E1;
border: 1px solid #475569;
}
.btn:hover {
transform: translateY(-2px);
}
.btn-accept:hover {
box-shadow: 0 10px 20px rgba(212, 175, 55, 0.3);
}
@media (min-width: 768px) {
.cookie-content {
flex-direction: row;
justify-content: space-between;
align-items: center;
}
.cookie-actions {
flex-shrink: 0;
}
}
</style>
<div class="cookie-content">
<p class="cookie-text">
We use cookies to enhance your browsing experience, serve personalised ads or content,
and analyse our traffic. By clicking "Accept All", you consent to our use of cookies.
</p>
<div class="cookie-actions">
<button class="btn btn-customize">Customize</button>
<button class="btn btn-reject">Reject All</button>
<button class="btn btn-accept">Accept All</button>
</div>
</div>
`;
// Show cookie banner after a delay
setTimeout(() => {
this.classList.add('visible');
}, 1000);
// Add event listeners
this.shadowRoot.querySelector('.btn-accept').addEventListener('click', () => {
this.classList.remove('visible');
// In a real implementation, you would set cookies here
});
this.shadowRoot.querySelector('.btn-reject').addEventListener('click', () => {
this.classList.remove('visible');
// In a real implementation, you would set cookies here
});
}
}
customElements.define('cookie-banner-component', CookieBannerComponent); |