]> Untitled Git - lemmy-ui.git/commitdiff
PR feedback
authorOrvar Segerström <orvarsegerstrom@gmail.com>
Mon, 26 Oct 2020 18:42:07 +0000 (19:42 +0100)
committerOrvar Segerström <orvarsegerstrom@gmail.com>
Mon, 26 Oct 2020 18:42:07 +0000 (19:42 +0100)
src/shared/components/theme.tsx
src/shared/initialize.ts

index 558f9a8b29e119f1c6158247ce8b5f4f78f6ebd6..a1e0a01ff2e9a35ea14c2023d0a7d4e4c6822474 100644 (file)
@@ -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>
+    );
+  }
+}
index 555da5e3a031f009b540a801d368b5dce463576e..de5762dbb8ab60fb23a84e045779442b8fab7a01 100644 (file)
@@ -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());
-};
+}