Spaces:
Running
Running
Download components/script-card.js from Arcturus917/scripthub-central: direct link, hf CLI and curl.
- Browser
- Download file 3.25 kB
-
https://huggingface.co/spaces/Arcturus917/scripthub-central/resolve/main/components/script-card.js
- Command line
-
hf download hf://spaces/Arcturus917/scripthub-central/components/script-card.js
-
curl -L -o script-card.js https://huggingface.co/spaces/Arcturus917/scripthub-central/resolve/main/components/script-card.js
3.25 kB
| class ScriptCard extends HTMLElement { | |
| static get observedAttributes() { | |
| return ['title', 'category', 'description', 'icon', 'downloads', 'rating']; | |
| } | |
| constructor() { | |
| super(); | |
| this.attachShadow({ mode: 'open' }); | |
| } | |
| connectedCallback() { | |
| this.render(); | |
| } | |
| attributeChangedCallback(name, oldValue, newValue) { | |
| if (oldValue !== newValue) { | |
| this.render(); | |
| } | |
| } | |
| render() { | |
| const title = this.getAttribute('title') || 'Untitled Script'; | |
| const category = this.getAttribute('category') || 'Miscellaneous'; | |
| const description = this.getAttribute('description') || 'No description provided'; | |
| const icon = this.getAttribute('icon') || 'code'; | |
| const downloads = this.getAttribute('downloads') || '0'; | |
| const rating = this.getAttribute('rating') || '0'; | |
| this.shadowRoot.innerHTML = ` | |
| <style> | |
| .card { | |
| transition: all 0.3s ease; | |
| transform: translateY(0); | |
| } | |
| .card:hover { | |
| transform: translateY(-5px); | |
| box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04); | |
| } | |
| .icon-container { | |
| background: linear-gradient(135deg, rgba(139, 92, 246, 0.1) 0%, rgba(236, 72, 153, 0.1) 100%); | |
| } | |
| .category-badge { | |
| background: linear-gradient(135deg, rgba(139, 92, 246, 0.2) 0%, rgba(236, 72, 153, 0.2) 100%); | |
| } | |
| </style> | |
| <div class="card bg-gray-800 rounded-xl p-6 h-full flex flex-col"> | |
| <div class="flex items-start justify-between mb-6"> | |
| <div class="icon-container w-12 h-12 rounded-lg flex items-center justify-center"> | |
| <i data-feather="${icon}" class="text-purple-400"></i> | |
| </div> | |
| <span class="category-badge text-xs font-medium px-3 py-1 rounded-full text-purple-300"> | |
| ${category} | |
| </span> | |
| </div> | |
| <h3 class="text-xl font-semibold mb-2">${title}</h3> | |
| <p class="text-gray-400 mb-6 flex-grow">${description}</p> | |
| <div class="flex items-center justify-between mt-auto"> | |
| <div class="flex items-center text-sm text-gray-400"> | |
| <i data-feather="download" class="w-4 h-4 mr-1"></i> | |
| ${downloads} | |
| </div> | |
| <div class="flex items-center text-sm text-yellow-400"> | |
| <i data-feather="star" class="w-4 h-4 mr-1"></i> | |
| ${rating} | |
| </div> | |
| <button class="text-sm font-medium text-purple-400 hover:text-purple-300 transition-colors flex items-center"> | |
| View Details <i data-feather="chevron-right" class="w-4 h-4 ml-1"></i> | |
| </button> | |
| </div> | |
| </div> | |
| `; | |
| } | |
| } | |
| customElements.define('script-card', ScriptCard); |