Spaces:
Running
Running
Download components/rainbow-button.js from michaelcboyer/chromadream-ui: direct link, hf CLI and curl.
- Browser
- Download file 1.52 kB
-
https://huggingface.co/spaces/michaelcboyer/chromadream-ui/resolve/main/components/rainbow-button.js
- Command line
-
hf download hf://spaces/michaelcboyer/chromadream-ui/components/rainbow-button.js
-
curl -L -o rainbow-button.js https://huggingface.co/spaces/michaelcboyer/chromadream-ui/resolve/main/components/rainbow-button.js
1.52 kB
| class RainbowButton extends HTMLElement { | |
| connectedCallback() { | |
| this.attachShadow({ mode: 'open' }); | |
| this.shadowRoot.innerHTML = ` | |
| <style> | |
| button { | |
| position: relative; | |
| padding: 0.75rem 1.5rem; | |
| font-size: 1rem; | |
| font-weight: 600; | |
| border: none; | |
| border-radius: 0.5rem; | |
| color: white; | |
| background: linear-gradient(90deg, #ff9a9e, #fad0c4, #fbc2eb, #a6c1ee, #84fab0, #8fd3f4); | |
| background-size: 300% 100%; | |
| transition: all 0.3s ease; | |
| cursor: pointer; | |
| overflow: hidden; | |
| z-index: 1; | |
| } | |
| button::before { | |
| content: ''; | |
| position: absolute; | |
| top: 0; | |
| left: 0; | |
| width: 100%; | |
| height: 100%; | |
| background: inherit; | |
| filter: brightness(0.8); | |
| z-index: -1; | |
| transform: scaleX(0); | |
| transform-origin: right; | |
| transition: transform 0.5s ease; | |
| } | |
| button:hover { | |
| transform: translateY(-2px); | |
| box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2); | |
| background-position: 100% 0; | |
| } | |
| button:hover::before { | |
| transform: scaleX(1); | |
| transform-origin: left; | |
| } | |
| button:active { | |
| transform: translateY(0); | |
| } | |
| </style> | |
| <button> | |
| <slot></slot> | |
| </button> | |
| `; | |
| } | |
| } | |
| customElements.define('rainbow-button', RainbowButton); |