Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrong admonition color on initial render #2779

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions docs/src/theme/Admonition/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import clsx from 'clsx';
import { ThemeClassNames, useColorMode } from '@docusaurus/theme-common';
import { ThemeClassNames } from '@docusaurus/theme-common';
import Translate from '@docusaurus/Translate';
import styles from './styles.module.css';

Expand Down Expand Up @@ -68,7 +68,6 @@ const aliases = {
};

export default function Admonition(props) {
const { colorMode } = useColorMode();
const {
children,
type,
Expand All @@ -89,7 +88,9 @@ export default function Admonition(props) {
)}>
<div className={styles.admonitionHeading}>
<div className={styles.admonitionIcon}>
{colorMode === 'light' ? <Danger /> : <DangerDark />}
{/* one of the icons is always hidden in css */}
<Danger />
<DangerDark />
</div>

{titleLabel}
Expand Down
12 changes: 8 additions & 4 deletions docs/src/theme/Admonition/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
margin-bottom: 1.5em;
}

[data-theme='dark'] .admonition {
color: var(--swm-off-white);
}

.admonitionHeading {
display: flex;
font-family: var(--swm-admonition-heading-font-family);
Expand All @@ -31,6 +27,14 @@
height: 27px;
}

[data-theme='dark'] .admonitionIcon svg:first-child {
display: none;
}

[data-theme='light'] .admonitionIcon svg:nth-child(2) {
display: none;
}

.admonitionIcon svg {
display: inline-block;
height: 100%;
Expand Down
Loading