Start with dark and light themes

This commit is contained in:
erroneousboat 2016-10-10 21:45:31 +02:00 committed by JP Bruins Slot
parent 72eaefe23b
commit 7a9bfce4ed

View File

@ -3,16 +3,21 @@ package config
import (
"encoding/json"
"os"
"github.com/gizak/termui"
)
// Config is the definition of a Config struct
type Config struct {
SlackToken string `json:"slack_token"`
Theme string `json:"theme"`
}
// NewConfig loads the config file and returns a Config struct
func NewConfig(filepath string) (*Config, error) {
var cfg Config
cfg := Config{
Theme: "dark",
}
file, err := os.Open(filepath)
if err != nil {
@ -23,5 +28,16 @@ func NewConfig(filepath string) (*Config, error) {
return &cfg, err
}
if cfg.Theme == "light" {
termui.ColorMap = map[string]termui.Attribute{
"fg": termui.ColorBlack,
"bg": termui.ColorDefault,
"border.fg": termui.ColorBlack,
"label.fg": termui.ColorGreen,
"par.fg": termui.ColorYellow,
"par.label.bg": termui.ColorWhite,
}
}
return &cfg, nil
}