Skip to content

Commit

Permalink
Fix logo not rendering correctly in dark mode
Browse files Browse the repository at this point in the history
  • Loading branch information
gjermundgaraba committed Sep 10, 2024
1 parent 9d355e5 commit 291bf66
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
10 changes: 0 additions & 10 deletions docs/src/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@
--ifm-code-font-size: 95%;
}

.hero--primary {
--ifm-hero-background-color: #8ecce7;
color: #1a2c5b;
}

/* For readability concerns, you should choose a lighter palette in dark mode. */
[data-theme='dark'] {
--ifm-color-primary: #8ecce7;
Expand All @@ -42,9 +37,4 @@
--ifm-breadcrumb-item-background-active: #1a2c5b;
--ifm-breadcrumb-color-active: #8ecce7;
--docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.3);

.hero--primary {
--ifm-hero-background-color: #1a2c5b;
color: #8ecce7;
}
}
17 changes: 14 additions & 3 deletions docs/src/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React, { useEffect, useState } from 'react';
import clsx from 'clsx';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import Layout from '@theme/Layout';
Expand All @@ -9,13 +10,23 @@ import styles from './index.module.css';

function HomepageHeader() {
const { colorMode } = useColorMode();
const [isMounted, setIsMounted] = useState(false);

const LogoSvg = colorMode === 'dark'
? require('@site/static/img/logo-with-name-and-tagline-dark.svg').default
: require('@site/static/img/logo-with-name-and-tagline.svg').default;
? require('@site/static/img/logo-with-name-and-tagline-dark.svg').default
: require('@site/static/img/logo-with-name-and-tagline.svg').default;

useEffect(() => {
setIsMounted(true); // Set mounted flag to true after the initial render
}, []);

if (!isMounted) {
return null; // Return null until colorMode is loaded
}
return (
<header className={clsx('hero hero--primary', styles.heroBanner)}>
<div className="container">
<LogoSvg className={styles.logoSvg} role="img"></LogoSvg>
<LogoSvg id={colorMode} className={styles.logoSvg} role="img"></LogoSvg>
</div>
</header>
);
Expand Down
1 change: 1 addition & 0 deletions docs/src/pages/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
text-align: center;
position: relative;
overflow: hidden;
background-color: var(--ifm-color-primary-light);
}

@media screen and (max-width: 996px) {
Expand Down

0 comments on commit 291bf66

Please sign in to comment.