Add dark mode to UIs

This commit is contained in:
Melon 2023-12-17 22:46:58 +00:00
parent 03df1556e7
commit 78e144891a
Signed by: melon
GPG Key ID: 6C9D970C50D26A25
6 changed files with 18 additions and 0 deletions

View File

@ -2,6 +2,7 @@
<html lang="en"> <html lang="en">
<head> <head>
<title>{{.ServiceName}}</title> <title>{{.ServiceName}}</title>
<link rel="stylesheet" href="/theme/style.css">
<script> <script>
let loginData = { let loginData = {
target:{{.TargetOrigin}}, target:{{.TargetOrigin}},

View File

@ -2,6 +2,7 @@
<html lang="en"> <html lang="en">
<head> <head>
<title>{{.ServiceName}}</title> <title>{{.ServiceName}}</title>
<link rel="stylesheet" href="/theme/style.css">
</head> </head>
<body> <body>
<header> <header>

View File

@ -2,6 +2,7 @@
<html lang="en"> <html lang="en">
<head> <head>
<title>{{.ServiceName}}</title> <title>{{.ServiceName}}</title>
<link rel="stylesheet" href="/theme/style.css">
</head> </head>
<body> <body>
<header> <header>

View File

@ -1,9 +1,11 @@
package server package server
import ( import (
"bytes"
"fmt" "fmt"
"github.com/1f349/cache" "github.com/1f349/cache"
"github.com/1f349/lavender/issuer" "github.com/1f349/lavender/issuer"
"github.com/1f349/lavender/theme"
"github.com/1f349/mjwt" "github.com/1f349/mjwt"
"github.com/julienschmidt/httprouter" "github.com/julienschmidt/httprouter"
"github.com/rs/cors" "github.com/rs/cors"
@ -68,6 +70,10 @@ func NewHttpServer(conf Conf, signer mjwt.Signer) *HttpServer {
r.POST("/popup", hs.flowPopupPost) r.POST("/popup", hs.flowPopupPost)
r.GET("/callback", hs.flowCallback) r.GET("/callback", hs.flowCallback)
r.GET("/theme/style.css", func(rw http.ResponseWriter, req *http.Request, params httprouter.Params) {
http.ServeContent(rw, req, "style.css", time.Now(), bytes.NewReader(theme.DefaultThemeCss))
})
// setup CORS options for `/verify` and `/refresh` endpoints // setup CORS options for `/verify` and `/refresh` endpoints
var corsAccessControl = cors.New(cors.Options{ var corsAccessControl = cors.New(cors.Options{
AllowOriginFunc: func(origin string) bool { AllowOriginFunc: func(origin string) bool {

3
theme/style.css Normal file
View File

@ -0,0 +1,3 @@
html, body {
color-scheme: light dark;
}

6
theme/theme.go Normal file
View File

@ -0,0 +1,6 @@
package theme
import _ "embed"
//go:embed style.css
var DefaultThemeCss []byte