text stringlengths 0 3.02k |
|---|
border-radius: 4px; |
background-color: rgba(255, 255, 255, 0.8); |
border: none; |
color: #333; |
font-size: 16px; |
cursor: pointer; |
transition: background-color 0.3s ease; |
} |
#theme-toggle:hover { |
background-color: rgba(255, 255, 255, 1); |
} |
`; |
document.head.appendChild(style); |
function updateTheme() { |
if (localStorage.theme === 'light' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: light)').matches)) { |
document.documentElement.classList.add('light'); |
} else if (localStorage.theme) { |
document.documentElement.classList.add(localStorage.theme.split(' ')); |
} else { |
document.documentElement.classList.add('dark'); |
} |
} |
if (localStorage.theme) { |
document.documentElement.classList.add(localStorage.theme.split(' ')); |
} else { |
updateTheme(); |
} |
``` |
[3/7/2024 12:35 AM] g30 |
This code can be injected into the page of WebUI and adds a Toggle Theme bar at the bottom right. It works. Code generated in one shot by Mixtral 8x7b. |
[3/7/2024 12:37 AM] wildtang3nt |
screenshot? |
[3/7/2024 12:37 AM] g30 |
{Attachments} |
[3/7/2024 12:38 AM] g30 |
{Attachments} |
[3/7/2024 12:38 AM] wildtang3nt |
hmmm, needs some refinement.. and obviously, packaging into the actual codebase |
[3/7/2024 12:38 AM] wildtang3nt |
but nice work |
[3/7/2024 12:38 AM] g30 |
Yes, but it seems fairly simple at least for Firefox and I am glad the AI spit out code that worked on first shot prompting |
[3/7/2024 12:39 AM] wildtang3nt |
looks like nice pure vanilla JS 👌 |
[3/7/2024 12:39 AM] wildtang3nt |
**_chef's kiss_** |
[3/7/2024 12:40 AM] g30 |
It does adjust here as well as expected, which is nice. Doesn't seem there needs to be extra code for that. |
{Attachments} |
[3/7/2024 12:40 AM] wildtang3nt |
the button state follows the actual state |
[3/7/2024 12:43 AM] wildtang3nt |
refinements I'd suggest: |
- use the same icon the settings one does |
- doesn't need to be a text label I think |
- move it up to the top right corner with the same margin as the help button down in the bottom corner |
[3/7/2024 12:43 AM] wildtang3nt |
For pasting big snippets, or logs: |
https://pastebin.com |
{Embed} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.