2017-11-19 21:10:04 -08:00
|
|
|
// Copyright 2017 Frédéric Guillot. All rights reserved.
|
|
|
|
// Use of this source code is governed by the Apache 2.0
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2018-08-24 21:51:50 -07:00
|
|
|
package model // import "miniflux.app/model"
|
2017-11-19 21:10:04 -08:00
|
|
|
|
2018-08-24 21:51:50 -07:00
|
|
|
import "miniflux.app/errors"
|
2017-11-25 12:44:32 -08:00
|
|
|
|
2017-11-27 21:30:04 -08:00
|
|
|
// Themes returns the list of available themes.
|
|
|
|
func Themes() map[string]string {
|
2017-11-19 21:10:04 -08:00
|
|
|
return map[string]string{
|
2019-09-21 19:10:08 -07:00
|
|
|
"light_serif": "Light - Serif",
|
|
|
|
"light_sans_serif": "Light - Sans Serif",
|
|
|
|
"dark_serif": "Dark - Serif",
|
|
|
|
"dark_sans_serif": "Dark - Sans Serif",
|
|
|
|
"system_serif": "System - Serif",
|
|
|
|
"system_sans_serif": "System - Sans Serif",
|
2017-11-19 21:10:04 -08:00
|
|
|
}
|
|
|
|
}
|
2017-11-25 12:44:32 -08:00
|
|
|
|
2018-07-18 22:30:05 -07:00
|
|
|
// ThemeColor returns the color for the address bar or/and the browser color.
|
|
|
|
// https://developer.mozilla.org/en-US/docs/Web/Manifest#theme_color
|
|
|
|
// https://developers.google.com/web/tools/lighthouse/audits/address-bar
|
|
|
|
func ThemeColor(theme string) string {
|
|
|
|
switch theme {
|
2019-09-21 19:10:08 -07:00
|
|
|
case "dark_serif", "dark_sans_serif":
|
2018-07-18 22:30:05 -07:00
|
|
|
return "#222"
|
|
|
|
default:
|
|
|
|
return "#fff"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-25 12:44:32 -08:00
|
|
|
// ValidateTheme validates theme value.
|
|
|
|
func ValidateTheme(theme string) error {
|
2017-11-27 21:30:04 -08:00
|
|
|
for key := range Themes() {
|
2017-11-25 12:44:32 -08:00
|
|
|
if key == theme {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-24 18:04:34 -08:00
|
|
|
return errors.NewLocalizedError("Invalid theme")
|
2017-11-25 12:44:32 -08:00
|
|
|
}
|