Skip to content

Commit

Permalink
fix theme mode detect
Browse files Browse the repository at this point in the history
  • Loading branch information
Ledchig committed Jan 14, 2024
1 parent 3829710 commit a1eeace
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 40 deletions.
7 changes: 3 additions & 4 deletions frontend/src/landing/Faq.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ function CustomToggle({ children, eventKey }) {

const isCurrentEventKey = activeEventKey === eventKey;

const IsThemeModeLight = window.matchMedia(
'(prefers-color-scheme: light)',
).matches;
const colorForEl = IsThemeModeLight ? 'black' : 'white';
const theme = document.documentElement.getAttribute('data-bs-theme');

const colorForEl = theme === 'light' ? 'black' : 'white';

return (
<div
Expand Down
44 changes: 12 additions & 32 deletions frontend/src/landing/Footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ import RunItLogoDark from './assets/LogoFooterDark.svg';

function Footer() {
const { t } = useTranslation();
const IsThemeModeLight = window.matchMedia(
'(prefers-color-scheme: light)',
).matches;
const logo = IsThemeModeLight ? RunItLogoLight : RunItLogoDark;

const theme = document.documentElement.getAttribute('data-bs-theme');

const logo = theme === 'light' ? RunItLogoLight : RunItLogoDark;

return (
<footer className="footer">
Expand All @@ -59,10 +59,7 @@ function Footer() {
rel="noopener noreferrer nofollow"
target="_blank"
>
<Image
fluid
src={IsThemeModeLight ? VKLightMobile : VKDarkMobile}
/>
<Image fluid src={theme ? VKLightMobile : VKDarkMobile} />
</NavbarBrand>
</li>
<li>
Expand All @@ -75,11 +72,7 @@ function Footer() {
>
<Image
fluid
src={
IsThemeModeLight
? TelegramLightMobile
: TelegramDarkMobile
}
src={theme ? TelegramLightMobile : TelegramDarkMobile}
/>
</NavbarBrand>
</li>
Expand All @@ -93,9 +86,7 @@ function Footer() {
>
<Image
fluid
src={
IsThemeModeLight ? YouTubeLightMobile : YouTubeDarkMobile
}
src={theme ? YouTubeLightMobile : YouTubeDarkMobile}
/>
</NavbarBrand>
</li>
Expand All @@ -109,9 +100,7 @@ function Footer() {
>
<Image
fluid
src={
IsThemeModeLight ? TwitterLightMobile : TwitterDarkMobile
}
src={theme ? TwitterLightMobile : TwitterDarkMobile}
/>
</NavbarBrand>
</li>
Expand Down Expand Up @@ -231,7 +220,7 @@ function Footer() {
rel="noopener noreferrer nofollow"
target="_blank"
>
<Image fluid src={IsThemeModeLight ? VKLight : VKDark} />
<Image fluid src={theme ? VKLight : VKDark} />
</NavbarBrand>
</li>
<li>
Expand All @@ -241,10 +230,7 @@ function Footer() {
rel="noopener noreferrer nofollow"
target="_blank"
>
<Image
fluid
src={IsThemeModeLight ? TelegramLight : TelegramDark}
/>
<Image fluid src={theme ? TelegramLight : TelegramDark} />
</NavbarBrand>
</li>
<li>
Expand All @@ -254,10 +240,7 @@ function Footer() {
rel="noopener noreferrer nofollow"
target="_blank"
>
<Image
fluid
src={IsThemeModeLight ? YouTubeLight : YouTubeDark}
/>
<Image fluid src={theme ? YouTubeLight : YouTubeDark} />
</NavbarBrand>
</li>
<li>
Expand All @@ -267,10 +250,7 @@ function Footer() {
rel="noopener noreferrer nofollow"
target="_blank"
>
<Image
fluid
src={IsThemeModeLight ? TwitterLight : TwitterDark}
/>
<Image fluid src={theme ? TwitterLight : TwitterDark} />
</NavbarBrand>
</li>
</Nav>
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/landing/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import './custom-colors.scss';

function Header() {
const { t } = useTranslation();
const IsThemeModeLight = window.matchMedia(
'(prefers-color-scheme: light)',
).matches;
const logo = IsThemeModeLight ? RunItLogoLight : RunItLogoDark;

const theme = document.documentElement.getAttribute('data-bs-theme');

const logo = theme === 'light' ? RunItLogoLight : RunItLogoDark;

return (
<header>
Expand Down

0 comments on commit a1eeace

Please sign in to comment.