Toggle light and dark modes + header color
This commit is contained in:
parent
d40bc51101
commit
b7f0d6f8b2
6 changed files with 118 additions and 10 deletions
31
controllers/misc.go
Normal file
31
controllers/misc.go
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
package controllers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.readonly.ch/bouzoure/pop-camarades/helpers"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
func SetColorMode(c *fiber.Ctx) error {
|
||||
colorMode := "light"
|
||||
if c.FormValue("color_mode") == "dark" {
|
||||
colorMode = "dark"
|
||||
}
|
||||
|
||||
sess, err := helpers.GetSessionStore(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
sess.Set("color-mode", colorMode)
|
||||
err = sess.Save()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return c.SendString(fmt.Sprintf(
|
||||
"New color mode: %s",
|
||||
colorMode,
|
||||
))
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue