From a6ab7fd62695a43fcaadecd59ca88691acdcfb74 Mon Sep 17 00:00:00 2001 From: Rish Date: Wed, 8 Jul 2020 20:54:10 +0530 Subject: [PATCH] Fixed null checks for accent color no issue - Fixes null checks for accent color --- ghost/portal/src/App.js | 2 +- ghost/portal/src/utils/contrast-color.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ghost/portal/src/App.js b/ghost/portal/src/App.js index cc8bb9efdc..25a232cf25 100644 --- a/ghost/portal/src/App.js +++ b/ghost/portal/src/App.js @@ -254,7 +254,7 @@ export default class App extends React.Component { getAccentColor() { const {accent_color: accentColor = '#3db0ef'} = this.state.site || {}; - return accentColor; + return accentColor || '#3db0ef'; } async onAction(action, data) { diff --git a/ghost/portal/src/utils/contrast-color.js b/ghost/portal/src/utils/contrast-color.js index 4db06b15ae..d8a1fd0000 100644 --- a/ghost/portal/src/utils/contrast-color.js +++ b/ghost/portal/src/utils/contrast-color.js @@ -4,8 +4,8 @@ function padZero(str, len) { return (zeros + str).slice(-len); } -function invertColor(hex, bw = true) { - if (!hex.match(/#[0-9A-Fa-f]{6}$/)) { +function invertColor(hex = '', bw = true) { + if (!hex || !hex.match(/#[0-9A-Fa-f]{6}$/)) { // Return white in case not a valid hex return '#000000'; }