Skip to content

Commit

Permalink
Fix custom theme color setting in config panel (CTFd#1268)
Browse files Browse the repository at this point in the history
* Properly update the theme header with custom theme color values 
* Closes CTFd#1263
  • Loading branch information
ColdHeat authored Feb 29, 2020
1 parent 2f46f61 commit e764bb1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions CTFd/themes/admin/assets/js/pages/configs.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,18 +245,20 @@ $(() => {
$(".nav-pills a").click(showTab);
$("#config-color-update").click(function() {
const hex_code = $("#config-color-picker").val();
const user_css = $("#css-editor").val();
const user_css = $("#theme-header").val();
let new_css;
if (user_css.lenth) {
if (user_css.length) {
let css_vars = `theme-color: ${hex_code};`;
new_css = user_css.replace(/theme-color: (.*);/, css_vars);
} else {
new_css =
`<style id="theme-color">\n` +
`:root {--theme-color: ${hex_code};}\n` +
`.navbar{background-color: var(--theme-color) !important;}\n` +
`.jumbotron{background-color: var(--theme-color) !important;}\n`;
`.jumbotron{background-color: var(--theme-color) !important;}\n` +
`</style>\n`;
}
$("#css-editor").val(new_css);
$("#theme-header").val(new_css);
});

$(".start-date").change(function() {
Expand Down
Loading

0 comments on commit e764bb1

Please sign in to comment.