aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2023-07-03 10:45:42 -0700
committerAnton Tananaev <anton@traccar.org>2023-07-03 10:45:42 -0700
commit5f0fb3d0346acca3796b129e304251d8060bff42 (patch)
tree38cee149e9c176a37c1531803ede378372de179a
parente97b6771910d3e6809810561a0deb76caaf7e0d5 (diff)
downloadtrackermap-web-5f0fb3d0346acca3796b129e304251d8060bff42.tar.gz
trackermap-web-5f0fb3d0346acca3796b129e304251d8060bff42.tar.bz2
trackermap-web-5f0fb3d0346acca3796b129e304251d8060bff42.zip
Validate theme colors
-rw-r--r--modern/src/common/theme/palette.js6
1 files changed, 4 insertions, 2 deletions
diff --git a/modern/src/common/theme/palette.js b/modern/src/common/theme/palette.js
index dfc8b9dd..51a01c69 100644
--- a/modern/src/common/theme/palette.js
+++ b/modern/src/common/theme/palette.js
@@ -2,12 +2,14 @@ import {
amber, grey, green, indigo, red, common,
} from '@mui/material/colors';
+const validatedColor = (color) => (/^#([0-9A-Fa-f]{3}){1,2}$/.test(color) ? color : null);
+
export default (server) => {
const colors = {
white: common.white,
background: grey[50],
- primary: server?.attributes?.colorPrimary || indigo[900],
- secondary: server?.attributes?.colorSecondary || green[800],
+ primary: validatedColor(server?.attributes?.colorPrimary) || indigo[900],
+ secondary: validatedColor(server?.attributes?.colorSecondary) || green[800],
positive: green[500],
medium: amber[700],
negative: red[500],