|
1 | 1 | package model |
2 | 2 |
|
3 | | -import "github.com/charmbracelet/lipgloss" |
4 | | - |
5 | | -// TODO: configurable colors via config file |
6 | | -var ( |
7 | | - base = lipgloss.Color("#39A02E") |
8 | | - green = lipgloss.Color("#39A02E") |
9 | | - yellow = lipgloss.Color("#DB9F1F") |
10 | | - red = lipgloss.Color("#f10000") |
11 | | - grey = lipgloss.Color("#424242") |
12 | | - black = lipgloss.Color("#000000") |
13 | | - white = lipgloss.Color("#ffffff") |
| 3 | +import ( |
| 4 | + "github.com/charmbracelet/lipgloss" |
| 5 | + "github.com/tjblackheart/andcli/v2/internal/config" |
14 | 6 | ) |
15 | 7 |
|
16 | | -type defaultStyle struct { |
| 8 | +type appStyle struct { |
17 | 9 | title, listItem, activeItem lipgloss.Style |
18 | 10 | username, filterCursor lipgloss.Style |
19 | 11 | filterPrompt, token, until lipgloss.Style |
20 | 12 | } |
21 | 13 |
|
22 | | -var ns = lipgloss.NewStyle |
| 14 | +var ( |
| 15 | + base = lipgloss.Color(config.DefaultTheme.Base) |
| 16 | + green = lipgloss.Color(config.DefaultTheme.Green) |
| 17 | + yellow = lipgloss.Color(config.DefaultTheme.Yellow) |
| 18 | + red = lipgloss.Color(config.DefaultTheme.Red) |
| 19 | + grey = lipgloss.Color(config.DefaultTheme.Grey) |
| 20 | + black = lipgloss.Color(config.DefaultTheme.Black) |
| 21 | + white = lipgloss.Color(config.DefaultTheme.White) |
| 22 | +) |
23 | 23 |
|
24 | | -func newDefaultStyle() *defaultStyle { |
25 | | - return &defaultStyle{ |
26 | | - title: ns().Background(base).Padding(0, 1), |
27 | | - listItem: ns().PaddingLeft(2).Faint(true), |
28 | | - username: ns().Background(grey), |
29 | | - filterPrompt: ns().Foreground(base), |
30 | | - filterCursor: ns().Background(base), |
31 | | - token: ns().Bold(true).Padding(0, 1, 0, 1), |
32 | | - until: ns().Bold(true), |
33 | | - activeItem: ns(). |
| 24 | +func newStyle() *appStyle { |
| 25 | + return &appStyle{ |
| 26 | + title: lipgloss.NewStyle().Background(base).Padding(0, 1), |
| 27 | + listItem: lipgloss.NewStyle().PaddingLeft(2).Faint(true), |
| 28 | + username: lipgloss.NewStyle().Background(grey), |
| 29 | + filterPrompt: lipgloss.NewStyle().Foreground(base), |
| 30 | + filterCursor: lipgloss.NewStyle().Background(base), |
| 31 | + token: lipgloss.NewStyle().Bold(true).Padding(0, 1, 0, 1), |
| 32 | + until: lipgloss.NewStyle().Bold(true), |
| 33 | + activeItem: lipgloss.NewStyle(). |
34 | 34 | Padding(0, 1). |
35 | 35 | Bold(true). |
36 | 36 | Background(grey). |
37 | 37 | Border(lipgloss.ThickBorder(), false, false, false, true). |
38 | 38 | Faint(false), |
39 | 39 | } |
40 | 40 | } |
| 41 | + |
| 42 | +func newThemedStyle(theme *config.Theme) *appStyle { |
| 43 | + base = lipgloss.Color(theme.Base) |
| 44 | + green = lipgloss.Color(theme.Green) |
| 45 | + yellow = lipgloss.Color(theme.Yellow) |
| 46 | + red = lipgloss.Color(theme.Red) |
| 47 | + grey = lipgloss.Color(theme.Grey) |
| 48 | + black = lipgloss.Color(theme.Black) |
| 49 | + white = lipgloss.Color(theme.White) |
| 50 | + |
| 51 | + return newStyle() |
| 52 | +} |
0 commit comments