mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-22 20:31:13 +00:00
Make code blocks use correct theme when in dark mode (#2367)
Co-authored-by: SleeplessOne1917 <insomnia-void@protonmail.com>
This commit is contained in:
parent
40ade7df88
commit
5eb97edf09
2 changed files with 29 additions and 16 deletions
|
@ -51,7 +51,7 @@ export class App extends Component<any, any> {
|
||||||
{siteView && (
|
{siteView && (
|
||||||
<>
|
<>
|
||||||
<Theme defaultTheme={siteView.local_site.default_theme} />
|
<Theme defaultTheme={siteView.local_site.default_theme} />
|
||||||
<CodeTheme />
|
<CodeTheme defaultTheme={siteView.local_site.default_theme} />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<Navbar siteRes={siteRes} />
|
<Navbar siteRes={siteRes} />
|
||||||
|
|
|
@ -1,22 +1,35 @@
|
||||||
|
import { dataBsTheme } from "@utils/browser";
|
||||||
import { Component } from "inferno";
|
import { Component } from "inferno";
|
||||||
|
import { Helmet } from "inferno-helmet";
|
||||||
|
import { UserService } from "../../services";
|
||||||
|
|
||||||
export class CodeTheme extends Component {
|
interface CodeThemeProps {
|
||||||
|
defaultTheme: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class CodeTheme extends Component<CodeThemeProps, any> {
|
||||||
render() {
|
render() {
|
||||||
|
const user = UserService.Instance.myUserInfo;
|
||||||
|
const userTheme = user?.local_user_view.local_user.theme;
|
||||||
|
const theme =
|
||||||
|
user && userTheme !== "browser" ? userTheme : this.props.defaultTheme;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<Helmet>
|
||||||
<link
|
{dataBsTheme(theme) === "dark" ? (
|
||||||
rel="stylesheet"
|
|
||||||
type="text/css"
|
|
||||||
href={`/css/code-themes/atom-one-light.css`}
|
|
||||||
media="(prefers-color-scheme: light)"
|
|
||||||
/>
|
|
||||||
<link
|
<link
|
||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
type="text/css"
|
type="text/css"
|
||||||
href={`/css/code-themes/atom-one-dark.css`}
|
href={`/css/code-themes/atom-one-dark.css`}
|
||||||
media="(prefers-color-scheme: no-preference), (prefers-color-scheme: dark)"
|
|
||||||
/>
|
/>
|
||||||
</>
|
) : (
|
||||||
|
<link
|
||||||
|
rel="stylesheet"
|
||||||
|
type="text/css"
|
||||||
|
href={`/css/code-themes/atom-one-light.css`}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</Helmet>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue