theme.go 964 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright 2017 Frédéric Guillot. All rights reserved.
  2. // Use of this source code is governed by the Apache 2.0
  3. // license that can be found in the LICENSE file.
  4. package model
  5. import "github.com/miniflux/miniflux/errors"
  6. // Themes returns the list of available themes.
  7. func Themes() map[string]string {
  8. return map[string]string{
  9. "default": "Default",
  10. "black": "Black",
  11. "sansserif": "Sans-Serif",
  12. }
  13. }
  14. // ThemeColor returns the color for the address bar or/and the browser color.
  15. // https://developer.mozilla.org/en-US/docs/Web/Manifest#theme_color
  16. // https://developers.google.com/web/tools/lighthouse/audits/address-bar
  17. func ThemeColor(theme string) string {
  18. switch theme {
  19. case "black":
  20. return "#222"
  21. default:
  22. return "#fff"
  23. }
  24. }
  25. // ValidateTheme validates theme value.
  26. func ValidateTheme(theme string) error {
  27. for key := range Themes() {
  28. if key == theme {
  29. return nil
  30. }
  31. }
  32. return errors.NewLocalizedError("Invalid theme")
  33. }