From 0459475ed42db118c6c1ca34c0a4d8611f511bec Mon Sep 17 00:00:00 2001 From: kilo Date: Wed, 11 Oct 2017 17:31:54 +0200 Subject: [PATCH] Make golang theme toggler behave exactly like JS one (#1648) * Make golang theme toggler behave exactly like JS one * fix red buttons with same red text color on sukebei --- controllers/themeToggle/themeToggle.go | 20 +++++++++----------- public/css/themes/tomorrow.css | 3 +++ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/controllers/themeToggle/themeToggle.go b/controllers/themeToggle/themeToggle.go index 5079d833..a0e9c639 100644 --- a/controllers/themeToggle/themeToggle.go +++ b/controllers/themeToggle/themeToggle.go @@ -15,22 +15,20 @@ func toggleThemeHandler(c *gin.Context) { theme, err := c.Cookie("theme") if err != nil { - theme = "g" + theme = config.DefaultTheme(false) } theme2, err := c.Cookie("theme2") if err != nil { - theme2 = "tomorrow" + theme2 = config.DefaultTheme(true) } - if theme == theme2 { - if theme == "tomorrow" { - theme2 = "g" - } - if theme != "tomorrow" { - theme2 = "tomorrow" - } + if theme != config.DefaultTheme(true) && theme2 != config.DefaultTheme(true) { + //None of the themes are dark ones, force the second one as the dark one + theme2 = config.DefaultTheme(true) + } else if theme == theme2 { + //Both theme are dark ones, force the second one as the default (light) theme + theme2 = config.DefaultTheme(false) } - //Get theme1 & theme2 value, set g.css & tomorrow.css by default - //Also check if both theme are identical which can happen at time + //Get theme1 & theme2 value // If logged in, update user theme (will not work otherwise) user := router.GetUser(c) diff --git a/public/css/themes/tomorrow.css b/public/css/themes/tomorrow.css index 45fac0bc..b4cfa891 100644 --- a/public/css/themes/tomorrow.css +++ b/public/css/themes/tomorrow.css @@ -96,6 +96,9 @@ td.tr-le, .error-text { .btn-red { background-color: #cc6666; } +.sukebei .btn-red { + color: #c5c8c6; +} .alt-colors tr:nth-child(even) { background: hsla(244, 11%, 21%, 0.2);