Spaces:
Running
Running
Build a modern, minimalistic website that acts as a directory for AI-generated image prompt components and their corresponding output images.
c00d809 verified | class CustomSearchBar extends HTMLElement { | |
| connectedCallback() { | |
| this.attachShadow({ mode: 'open' }); | |
| this.shadowRoot.innerHTML = ` | |
| <style> | |
| :host { | |
| display: block; | |
| } | |
| .search-container { | |
| position: relative; | |
| max-width: 600px; | |
| margin: 0 auto; | |
| } | |
| .search-input { | |
| width: 100%; | |
| padding: 1rem 1rem 1rem 3rem; | |
| border-radius: 50px; | |
| border: 1px solid #e5e7eb; | |
| background: #fff; | |
| font-size: 1rem; | |
| transition: all 0.3s; | |
| box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05); | |
| } | |
| .dark .search-input { | |
| background: #1f2937; | |
| border: 1px solid #374151; | |
| color: #f9fafb; | |
| } | |
| .search-input:focus { | |
| outline: none; | |
| border-color: #6366f1; | |
| box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1); | |
| } | |
| .search-icon { | |
| position: absolute; | |
| left: 1rem; | |
| top: 50%; | |
| transform: translateY(-50%); | |
| color: #9ca3af; | |
| } | |
| .dark .search-icon { | |
| color: #6b7280; | |
| } | |
| </style> | |
| <div class="search-container"> | |
| <i data-feather="search" class="search-icon w-5 h-5"></i> | |
| <input type="text" class="search-input" placeholder="Search prompts or tags..." id="searchInput"> | |
| </div> | |
| `; | |
| // Add event listener after rendering | |
| setTimeout(() => { | |
| const searchInput = this.shadowRoot.getElementById('searchInput'); | |
| searchInput.addEventListener('input', (e) => { | |
| // Access the global search function | |
| if (typeof searchPrompts === 'function') { | |
| searchPrompts(e.target.value); | |
| } | |
| }); | |
| // Initialize feather icons | |
| feather.replace(); | |
| }, 0); | |
| } | |
| } | |
| customElements.define('custom-search-bar', CustomSearchBar); |