From 827691d5513ea52dfbc5cfc403ee28597a6ee548 Mon Sep 17 00:00:00 2001 From: Jonas Kuske <30421456+jonaskuske@users.noreply.github.com> Date: Sat, 30 May 2020 05:16:45 +0200 Subject: [PATCH] fix: allow overriding product hunt theme --- docs/script.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/script.js b/docs/script.js index 314b194..4e9f01f 100644 --- a/docs/script.js +++ b/docs/script.js @@ -24,8 +24,8 @@ const table = { const prefersColorScheme = window.matchMedia('(prefers-color-scheme: light)') -const updateProductHunt = () => { - const theme = prefersColorScheme.matches ? 'light' : 'dark' +const updateProductHunt = (theme) => { + 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` } @@ -44,14 +44,14 @@ const updateTheme = () => { table.fileName.innerText = fileName table.fileSize.innerText = `${fileSizes[theme].toFixed(2)} kb` - updateProductHunt() - if (theme === 'auto') { + updateProductHunt() table.theme.innerHTML = ` Respects user-defined theme settings using prefers-color-scheme.
Light in browsers where the theme settings can't be detected. ` } else { + updateProductHunt(theme) table.theme.innerText = `Theme is forced to ${theme}.` } }