1
0
mirror of https://github.com/kognise/water.css.git synced 2025-08-10 15:14:34 +02:00

fix: allow overriding product hunt theme

This commit is contained in:
Jonas Kuske
2020-05-30 05:16:45 +02:00
parent 30cbcfa492
commit 827691d551

View File

@@ -24,8 +24,8 @@ const table = {
const prefersColorScheme = window.matchMedia('(prefers-color-scheme: light)') const prefersColorScheme = window.matchMedia('(prefers-color-scheme: light)')
const updateProductHunt = () => { const updateProductHunt = (theme) => {
const theme = prefersColorScheme.matches ? 'light' : 'dark' theme = theme || (prefersColorScheme.matches ? 'light' : 'dark')
productHunt.src = `https://api.producthunt.com/widgets/embed-image/v1/top-post-badge.svg?post_id=150490&theme=${theme}&period=daily` productHunt.src = `https://api.producthunt.com/widgets/embed-image/v1/top-post-badge.svg?post_id=150490&theme=${theme}&period=daily`
} }
@@ -44,14 +44,14 @@ const updateTheme = () => {
table.fileName.innerText = fileName table.fileName.innerText = fileName
table.fileSize.innerText = `${fileSizes[theme].toFixed(2)} kb` table.fileSize.innerText = `${fileSizes[theme].toFixed(2)} kb`
updateProductHunt()
if (theme === 'auto') { if (theme === 'auto') {
updateProductHunt()
table.theme.innerHTML = ` table.theme.innerHTML = `
Respects user-defined theme settings using <a style="--links: var(--code)" href="https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme" target="_blank" rel="noopener"><code>prefers-color-scheme</code></a>.<br> Respects user-defined theme settings using <a style="--links: var(--code)" href="https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme" target="_blank" rel="noopener"><code>prefers-color-scheme</code></a>.<br>
Light in browsers where the theme settings can't be detected. Light in browsers where the theme settings can't be detected.
` `
} else { } else {
updateProductHunt(theme)
table.theme.innerText = `Theme is forced to ${theme}.` table.theme.innerText = `Theme is forced to ${theme}.`
} }
} }