Download components/dropdown-menu.js from Pavelm777/test: direct link, hf CLI and curl.
- Browser
- Download file 2.58 kB
-
https://huggingface.co/spaces/Pavelm777/test/resolve/main/components/dropdown-menu.js
- Command line
-
hf download hf://spaces/Pavelm777/test/components/dropdown-menu.js
-
curl -L -o dropdown-menu.js https://huggingface.co/spaces/Pavelm777/test/resolve/main/components/dropdown-menu.js
2.58 kB
| class DropdownMenu extends HTMLElement { | |
| connectedCallback() { | |
| this.attachShadow({ mode: 'open' }); | |
| this.shadowRoot.innerHTML = ` | |
| <style> | |
| .dropdown-container { | |
| position: relative; | |
| display: inline-block; | |
| margin: 1rem 0; | |
| } | |
| .dropdown-btn { | |
| background: #0d9488; | |
| color: white; | |
| padding: 0.75rem 1.5rem; | |
| font-size: 1.1rem; | |
| border: none; | |
| border-radius: 0.5rem; | |
| cursor: pointer; | |
| transition: all 0.3s ease; | |
| } | |
| .dropdown-btn:hover { | |
| background: #115e59; | |
| } | |
| .dropdown-content { | |
| display: none; | |
| position: absolute; | |
| background: white; | |
| min-width: 300px; | |
| box-shadow: 0 8px 16px rgba(0,0,0,0.2); | |
| border-radius: 0.5rem; | |
| padding: 1rem; | |
| z-index: 100; | |
| right: 0; | |
| } | |
| .dropdown-content.show { | |
| display: flex; | |
| flex-direction: column; | |
| gap: 1rem; | |
| } | |
| .clinic-image { | |
| width: 100%; | |
| height: 200px; | |
| object-fit: cover; | |
| border-radius: 0.5rem; | |
| } | |
| .clinic-info { | |
| font-size: 0.95rem; | |
| color: #374151; | |
| } | |
| </style> | |
| <div class="dropdown-container"> | |
| <button class="dropdown-btn">Эстетическая стоматология</button> | |
| <div class="dropdown-content"> | |
| <img src="http://static.photos/medical/640x360/42" alt="Наша клиника" class="clinic-image"> | |
| <div class="clinic-info"> | |
| <p>Наши услуги включают:</p> | |
| <ul> | |
| <li>Виниры</li> | |
| <li>Отбеливание</li> | |
| <li>Реставрация улыбки</li> | |
| <li>Художественная реставрация</li> | |
| </ul> | |
| <p>Используем только современные материалы и технологии</p> | |
| </div> | |
| </div> | |
| </div> | |
| `; | |
| const btn = this.shadowRoot.querySelector('.dropdown-btn'); | |
| const content = this.shadowRoot.querySelector('.dropdown-content'); | |
| btn.addEventListener('click', () => { | |
| content.classList.toggle('show'); | |
| }); | |
| // Close when clicking outside | |
| document.addEventListener('click', (e) => { | |
| if (!this.contains(e.target)) { | |
| content.classList.remove('show'); | |
| } | |
| }); | |
| } | |
| } | |
| customElements.define('dropdown-menu', DropdownMenu); |