From 0ab1777046164d69eab1ec1ec0198ece2383a828 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Fri, 25 Feb 2022 14:35:17 +0100 Subject: [PATCH] Add option to set site default theme (fixes #559) --- package.json | 2 +- src/shared/components/app/app.tsx | 2 +- src/shared/components/app/theme.tsx | 24 +++++---------- src/shared/components/home/site-form.tsx | 37 ++++++++++++++++++++++-- yarn.lock | 8 ++--- 5 files changed, 48 insertions(+), 25 deletions(-) diff --git a/package.json b/package.json index 1134d48..01d23c7 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,7 @@ "eslint-plugin-prettier": "^4.0.0", "husky": "^7.0.4", "import-sort-style-module": "^6.0.0", - "lemmy-js-client": "0.15.1-rc.1", + "lemmy-js-client": "0.15.4-rc.2", "lint-staged": "^12.1.2", "mini-css-extract-plugin": "^2.4.5", "node-fetch": "^2.6.1", diff --git a/src/shared/components/app/app.tsx b/src/shared/components/app/app.tsx index bac634e..52e47a1 100644 --- a/src/shared/components/app/app.tsx +++ b/src/shared/components/app/app.tsx @@ -26,7 +26,7 @@ export class App extends Component { <>
- + {siteRes && siteRes.site_view && this.props.siteRes.site_view.site.icon && ( diff --git a/src/shared/components/app/theme.tsx b/src/shared/components/app/theme.tsx index bf5289b..e048046 100644 --- a/src/shared/components/app/theme.tsx +++ b/src/shared/components/app/theme.tsx @@ -1,9 +1,10 @@ import { Component } from "inferno"; import { Helmet } from "inferno-helmet"; -import { MyUserInfo } from "lemmy-js-client"; +import { MyUserInfo, Site } from "lemmy-js-client"; interface Props { myUserInfo: MyUserInfo | undefined; + site: Site; } export class Theme extends Component { @@ -20,22 +21,11 @@ export class Theme extends Component { href={`/static/assets/css/themes/${user.local_user_view.local_user.theme}.min.css`} /> ) : ( - [ - , - , - ] + )} ); diff --git a/src/shared/components/home/site-form.tsx b/src/shared/components/home/site-form.tsx index ba1ce38..d37d712 100644 --- a/src/shared/components/home/site-form.tsx +++ b/src/shared/components/home/site-form.tsx @@ -3,7 +3,12 @@ import { Prompt } from "inferno-router"; import { CreateSite, EditSite, Site } from "lemmy-js-client"; import { i18n } from "../../i18next"; import { WebSocketService } from "../../services"; -import { authField, capitalizeFirstLetter, wsClient } from "../../utils"; +import { + authField, + capitalizeFirstLetter, + themes, + wsClient, +} from "../../utils"; import { Spinner } from "../common/icon"; import { ImageUploadForm } from "../common/image-upload-form"; import { MarkdownTextArea } from "../common/markdown-textarea"; @@ -31,6 +36,7 @@ export class SiteForm extends Component { require_application: null, application_question: null, private_instance: null, + default_theme: null, auth: authField(), }, loading: false, @@ -66,6 +72,7 @@ export class SiteForm extends Component { require_application: site.require_application, application_question: site.application_question, private_instance: site.private_instance, + default_theme: site.default_theme, auth: authField(), }; } @@ -314,6 +321,27 @@ export class SiteForm extends Component {
+
+
+ + +
+
@@ -321,7 +349,7 @@ export class SiteForm extends Component { class="form-check-input" id="create-site-private-instance" type="checkbox" - checked={this.state.siteForm.private_instance} + value={this.state.siteForm.default_theme} onChange={linkEvent(this, this.handleSitePrivateInstance)} />