Spaces:
Running
Running
| 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); |