Spaces:
Running
Running
ุนุงูุฒู ุชุถูู ููู ุงูุตูุญู ุฒุฑุงุฑ ูุชุณุฌูู ุงูุฏุฎูู ูุฌูุงู ูุจูู ูู ุตูุญุชูู ูุงุญุฏู ูู ููุง ู
ุนุงู ุญุณุงุจ ูุงูุซุงููุฉ ูู ููุณุฌู ุฌุฏูุฏ ููููู ููู ุชุณุฌูู ุจุญุณุงุจ ุฌูุฌู ููููู ููู ุฒุฑุงุฑ ูููู ููู ุงูุตูุญู ุบุงู
ู ุงู ูุงุชุญ ูุชุดูู ุงูููุจ ุงูู ู
ุนุงูู
ููู ู
ุด ุนุงูุฒู
c0face1 verified Download components/theme-toggle.js from seifshehata/loginflow-pro: direct link, hf CLI and curl.
- Browser
- Download file 1.87 kB
-
https://huggingface.co/spaces/seifshehata/loginflow-pro/resolve/main/components/theme-toggle.js
- Command line
-
hf download hf://spaces/seifshehata/loginflow-pro/components/theme-toggle.js
-
curl -L -o theme-toggle.js https://huggingface.co/spaces/seifshehata/loginflow-pro/resolve/main/components/theme-toggle.js
1.87 kB
| class ThemeToggle extends HTMLElement { | |
| connectedCallback() { | |
| this.attachShadow({ mode: 'open' }); | |
| this.render(); | |
| this.setupEventListeners(); | |
| } | |
| render() { | |
| this.shadowRoot.innerHTML = ` | |
| <style> | |
| button { | |
| display: flex; | |
| align-items: center; | |
| justify-content: center; | |
| width: 40px; | |
| height: 40px; | |
| border-radius: 50%; | |
| background-color: transparent; | |
| border: none; | |
| cursor: pointer; | |
| color: inherit; | |
| } | |
| button:hover { | |
| background-color: rgba(0, 0, 0, 0.05); | |
| } | |
| .dark button:hover { | |
| background-color: rgba(255, 255, 255, 0.05); | |
| } | |
| </style> | |
| <button aria-label="ุชุจุฏูู ุงููุถุน ุงููููู"> | |
| <i data-feather="moon"></i> | |
| </button> | |
| `; | |
| } | |
| setupEventListeners() { | |
| const button = this.shadowRoot.querySelector('button'); | |
| button.addEventListener('click', this.toggleTheme.bind(this)); | |
| } | |
| toggleTheme() { | |
| const html = document.documentElement; | |
| if (html.classList.contains('dark')) { | |
| html.classList.remove('dark'); | |
| localStorage.setItem('theme', 'light'); | |
| this.shadowRoot.querySelector('i').setAttribute('data-feather', 'moon'); | |
| } else { | |
| html.classList.add('dark'); | |
| localStorage.setItem('theme', 'dark'); | |
| this.shadowRoot.querySelector('i').setAttribute('data-feather', 'sun'); | |
| } | |
| feather.replace(); | |
| } | |
| } | |
| customElements.define('theme-toggle', ThemeToggle); |