mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-12-22 19:01:26 +00:00
PR feedback
This commit is contained in:
parent
b8a47be3df
commit
397db2f1db
2 changed files with 41 additions and 34 deletions
|
@ -1,36 +1,43 @@
|
|||
import { User } from 'lemmy-js-client';
|
||||
import { Helmet } from 'inferno-helmet';
|
||||
import { Component } from 'inferno';
|
||||
|
||||
export const Theme = (props: { user: User | undefined }) => {
|
||||
const user = props.user;
|
||||
const userTheme = user && user.theme && (
|
||||
<link
|
||||
rel="stylesheet"
|
||||
type="text/css"
|
||||
href={`/static/assets/css/themes/${user.theme}.min.css`}
|
||||
/>
|
||||
);
|
||||
interface Props {
|
||||
user: User | undefined;
|
||||
}
|
||||
|
||||
return (
|
||||
<Helmet>
|
||||
{userTheme ?? (
|
||||
<>
|
||||
<link
|
||||
rel="stylesheet"
|
||||
type="text/css"
|
||||
href="/static/assets/css/themes/litely.min.css"
|
||||
id="default-light"
|
||||
media="(prefers-color-scheme: light)"
|
||||
/>
|
||||
<link
|
||||
rel="stylesheet"
|
||||
type="text/css"
|
||||
href="/static/assets/css/themes/darkly.min.css"
|
||||
id="default-dark"
|
||||
media="(prefers-color-scheme: no-preference), (prefers-color-scheme: dark)"
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</Helmet>
|
||||
);
|
||||
};
|
||||
export class Theme extends Component<Props> {
|
||||
render() {
|
||||
const { user } = this.props;
|
||||
const userTheme = user && user.theme && (
|
||||
<link
|
||||
rel="stylesheet"
|
||||
type="text/css"
|
||||
href={`/static/assets/css/themes/${user.theme}.min.css`}
|
||||
/>
|
||||
);
|
||||
|
||||
return (
|
||||
<Helmet>
|
||||
{userTheme ?? (
|
||||
<>
|
||||
<link
|
||||
rel="stylesheet"
|
||||
type="text/css"
|
||||
href="/static/assets/css/themes/litely.min.css"
|
||||
id="default-light"
|
||||
media="(prefers-color-scheme: light)"
|
||||
/>
|
||||
<link
|
||||
rel="stylesheet"
|
||||
type="text/css"
|
||||
href="/static/assets/css/themes/darkly.min.css"
|
||||
id="default-dark"
|
||||
media="(prefers-color-scheme: no-preference), (prefers-color-scheme: dark)"
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</Helmet>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ import { UserService } from './services';
|
|||
import { i18n } from './i18next';
|
||||
import { getLanguage } from './utils';
|
||||
|
||||
export const initializeSite = (site: GetSiteResponse) => {
|
||||
export function initializeSite(site: GetSiteResponse) {
|
||||
UserService.Instance.user = site.my_user;
|
||||
i18n.changeLanguage(getLanguage());
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue