diff --git a/js/admin/src/components/AppearancePage.js b/js/admin/src/components/AppearancePage.js
index 448d9abba..18d080c5f 100644
--- a/js/admin/src/components/AppearancePage.js
+++ b/js/admin/src/components/AppearancePage.js
@@ -1,9 +1,81 @@
import Component from 'flarum/Component';
+import Button from 'flarum/components/Button';
+import Switch from 'flarum/components/Switch';
+import EditCustomCssModal from 'flarum/components/EditCustomCssModal';
+import saveConfig from 'flarum/utils/saveConfig';
export default class AppearancePage extends Component {
+ constructor(...args) {
+ super(...args);
+
+ this.primaryColor = m.prop(app.config.theme_primary_color);
+ this.secondaryColor = m.prop(app.config.theme_secondary_color);
+ this.darkMode = m.prop(app.config.theme_dark_mode === '1');
+ this.coloredHeader = m.prop(app.config.theme_colored_header === '1');
+ }
+
view() {
return (
-
+
+
+
+
+
+ Custom Styles
+
+ Customize your forum's appearance by adding your own LESS/CSS code to be applied on top of Flarum's default styles.
+
+ {Button.component({
+ className: 'Button',
+ children: 'Edit Custom CSS',
+ onclick: () => app.modal.show(new EditCustomCssModal())
+ })}
+
+
+
);
}
+
+ onsubmit(e) {
+ e.preventDefault();
+
+ this.loading = true;
+
+ saveConfig({
+ theme_primary_color: this.primaryColor(),
+ theme_secondary_color: this.secondaryColor(),
+ theme_dark_mode: this.darkMode(),
+ theme_colored_header: this.coloredHeader()
+ }).then(() => window.location.reload());
+ }
}
diff --git a/js/admin/src/components/EditCustomCssModal.js b/js/admin/src/components/EditCustomCssModal.js
new file mode 100644
index 000000000..1619a66ec
--- /dev/null
+++ b/js/admin/src/components/EditCustomCssModal.js
@@ -0,0 +1,51 @@
+import Modal from 'flarum/components/Modal';
+import Button from 'flarum/components/Button';
+import saveConfig from 'flarum/utils/saveConfig';
+
+export default class EditCustomCssModal extends Modal {
+ constructor(...args) {
+ super(...args);
+
+ this.customLess = m.prop(app.config.custom_less || '');
+ }
+
+ className() {
+ return 'EditCustomCssModal Modal--large';
+ }
+
+ title() {
+ return 'Edit Custom CSS';
+ }
+
+ content() {
+ return (
+
+
Customize your forum's appearance by adding your own LESS/CSS code to be applied on top of Flarum's default styles. Read the documentation for more information.
+
+
+
+
+
+
+
+ {Button.component({
+ className: 'Button Button--primary',
+ children: 'Save Changes',
+ loading: this.loading
+ })}
+
+
+
+ );
+ }
+
+ onsubmit(e) {
+ e.preventDefault();
+
+ this.loading = true;
+
+ saveConfig({
+ custom_less: this.customLess()
+ }).then(() => window.location.reload());
+ }
+}
diff --git a/less/admin/AppearancePage.less b/less/admin/AppearancePage.less
new file mode 100644
index 000000000..01a1d1466
--- /dev/null
+++ b/less/admin/AppearancePage.less
@@ -0,0 +1,34 @@
+.AppearancePage {
+ @media @desktop-up {
+ .container {
+ max-width: 600px;
+ padding: 30px;
+ margin: 0;
+ }
+ }
+
+ fieldset {
+ margin-bottom: 40px;
+ }
+}
+.AppearancePage-colors-input {
+ overflow: hidden;
+
+ input {
+ width: 49%;
+ float: left;
+
+ &:first-child {
+ margin-right: 2%;
+ }
+ }
+}
+.AppearancePage-colors-input,
+.AppearancePage-colors .Checkbox {
+ margin-bottom: 15px;
+}
+
+.EditCustomCssModal textarea {
+ font-family: monospace;
+ line-height: 1;
+}
diff --git a/less/admin/app.less b/less/admin/app.less
index e7144b161..021cb346d 100644
--- a/less/admin/app.less
+++ b/less/admin/app.less
@@ -6,3 +6,4 @@
@import "PermissionsPage.less";
@import "EditGroupModal.less";
@import "ExtensionsPage.less";
+@import "AppearancePage.less";
diff --git a/less/lib/Modal.less b/less/lib/Modal.less
index 7271eb80e..5e2d9e8de 100755
--- a/less/lib/Modal.less
+++ b/less/lib/Modal.less
@@ -55,10 +55,6 @@
width: auto;
margin: 10px;
max-width: 600px;
-
- .Modal--small & {
- max-width: 400px;
- }
}
// Actual modal
@@ -194,7 +190,10 @@
.box-shadow(0 7px 15px @shadow-color);
}
.Modal--small {
- width: 375px;
+ max-width: 375px;
+ }
+ .Modal--large {
+ max-width: 800px;
}
.Modal-header {
text-align: center;
diff --git a/src/Admin/Actions/UpdateConfigAction.php b/src/Admin/Actions/UpdateConfigAction.php
index 31cb62d06..aedede1dc 100644
--- a/src/Admin/Actions/UpdateConfigAction.php
+++ b/src/Admin/Actions/UpdateConfigAction.php
@@ -37,6 +37,14 @@ class UpdateConfigAction extends Action
$this->settings->set($k, $v);
}
+ $assetPath = public_path('assets');
+ $manifest = file_get_contents($assetPath . '/rev-manifest.json');
+ $revisions = json_decode($manifest, true);
+
+ foreach ($revisions as $file => $revision) {
+ @unlink($assetPath . '/' . substr_replace($file, '-' . $revision, strrpos($file, '.'), 0));
+ }
+
return $this->success();
}
}
diff --git a/src/Support/ClientAction.php b/src/Support/ClientAction.php
index 17c08f22f..a1302a901 100644
--- a/src/Support/ClientAction.php
+++ b/src/Support/ClientAction.php
@@ -183,8 +183,8 @@ abstract class ClientAction extends HtmlAction
protected function getLessVariables()
{
return [
- 'config-primary-color' => $this->settings->get('theme_primary_color', '#000'),
- 'config-secondary-color' => $this->settings->get('theme_secondary_color', '#000'),
+ 'config-primary-color' => $this->settings->get('theme_primary_color') ?: '#000',
+ 'config-secondary-color' => $this->settings->get('theme_secondary_color') ?: '#000',
'config-dark-mode' => $this->settings->get('theme_dark_mode') ? 'true' : 'false',
'config-colored-header' => $this->settings->get('theme_colored_header') ? 'true' : 'false'
];