Mop up styling big time

This commit is contained in:
Christian Rocha 2020-11-11 16:28:48 -05:00 committed by Christian Rocha
parent 7b7a398c74
commit 4b121593d4
4 changed files with 77 additions and 70 deletions

View file

@ -21,11 +21,6 @@ import (
const (
statusBarHeight = 1
gray = "#333333"
yellowGreen = "#ECFD65"
fuschia = "#EE6FF8"
mintGreen = "#89F0CB"
darkGreen = "#1C8760"
noteHeadingText = " Set Memo "
notePromptText = " > "
)
@ -33,35 +28,29 @@ const (
var (
pagerHelpHeight int
mintGreen = common.NewColorPair("#89F0CB", "#89F0CB")
darkGreen = common.NewColorPair("#1C8760", "#1C8760")
noteHeading = te.String(noteHeadingText).
Foreground(common.Cream.Color()).
Background(common.Green.Color()).
String()
statusBarBg = common.NewColorPair("#242424", "#E6E6E6")
statusBarNoteFg = common.NewColorPair("#7D7D7D", "#656565")
statusBarBg = common.NewColorPair("#242424", "#E6E6E6")
// Styling functions.
statusBarScrollPosStyle = newStyle(common.NewColorPair("#5A5A5A", "#949494").String(), statusBarBg.String())
statusBarNoteStyle = newStyle(statusBarNoteFg.String(), statusBarBg.String())
statusBarHelpStyle = newStyle(statusBarNoteFg.String(), common.NewColorPair("#323232", "#DCDCDC").String())
statusBarStashDotStyle = newStyle(common.Green.String(), statusBarBg.String())
// Styling funcs
statusBarScrollPosStyle = newStyle(common.NewColorPair("#5A5A5A", "#949494"), statusBarBg)
statusBarNoteStyle = newStyle(statusBarNoteFg, statusBarBg)
statusBarHelpStyle = newStyle(statusBarNoteFg, common.NewColorPair("#323232", "#DCDCDC"))
statusBarStashDotStyle = newStyle(common.Green, statusBarBg)
statusBarMessageStyle = newStyle(mintGreen, darkGreen)
statusBarMessageStashIconStyle = newStyle(mintGreen, darkGreen)
statusBarMessageScrollPosStyle = newStyle(mintGreen, darkGreen)
statusBarMessageHelpStyle = newStyle("#B6FFE4", common.Green.String())
helpViewStyle = newStyle(statusBarNoteFg.String(), common.NewColorPair("#1B1B1B", "#f2f2f2").String())
statusBarMessageHelpStyle = newStyle(common.NewColorPair("#B6FFE4", "#B6FFE4"), common.Green)
helpViewStyle = newStyle(statusBarNoteFg, common.NewColorPair("#1B1B1B", "#f2f2f2"))
)
// Returns a termenv style.
func newStyle(fg, bg string) func(string) string {
return te.Style{}.
Foreground(te.ColorProfile().Color(fg)).
Background(te.ColorProfile().Color(bg)).
Styled
}
type contentRenderedMsg string
type noteSavedMsg *charm.Markdown
type stashSuccessMsg markdown
@ -109,18 +98,19 @@ func newPagerModel(cfg *Config, as authStatus) pagerModel {
vp.YPosition = 0
vp.HighPerformanceRendering = config.HighPerformancePager
// Init text input UI for notes/memos
// Text input for notes/memos
ti := textinput.NewModel()
ti.Prompt = te.String(notePromptText).
Foreground(te.ColorProfile().Color(gray)).
Background(te.ColorProfile().Color(yellowGreen)).
Foreground(common.Color(darkGray)).
Background(common.YellowGreen.Color()).
String()
ti.TextColor = gray
ti.BackgroundColor = yellowGreen
ti.CursorColor = fuschia
ti.TextColor = darkGray
ti.BackgroundColor = common.YellowGreen.String()
ti.CursorColor = common.Fuschia.String()
ti.CharLimit = noteCharacterLimit
ti.Focus()
// Text input for search
sp := spinner.NewModel()
sp.ForegroundColor = statusBarNoteFg.String()
sp.BackgroundColor = statusBarBg.String()

View file

@ -34,9 +34,10 @@ const (
)
var (
stashHelpItemStyle func(string) string = te.Style{}.Foreground(common.NewColorPair("#5C5C5C", "#9B9B9B").Color()).Styled
dividerDot string = te.String(" • ").Foreground(common.NewColorPair("#3C3C3C", "#DDDADA").Color()).String()
offlineHeaderNote string = te.String("(Offline)").Foreground(common.NewColorPair("#3C3C3C", "#DDDADA").Color()).String()
stashHelpItemStyle styleFunc = newFgStyle(common.NewColorPair("#5C5C5C", "#9B9B9B"))
stashTextInputPromptStyle styleFunc = newFgStyle(common.YellowGreen)
dividerDot string = te.String(" • ").Foreground(common.NewColorPair("#3C3C3C", "#DDDADA").Color()).String()
offlineHeaderNote string = te.String("(Offline)").Foreground(common.NewColorPair("#3C3C3C", "#DDDADA").Color()).String()
)
// MSG
@ -318,13 +319,13 @@ func newStashModel(cfg *Config, as authStatus) stashModel {
p.InactiveDot = common.Subtle("•")
ni := textinput.NewModel()
ni.Prompt = te.String(setNotePromptText).Foreground(common.YellowGreen.Color()).String()
ni.Prompt = stashTextInputPromptStyle(setNotePromptText)
ni.CursorColor = common.Fuschia.String()
ni.CharLimit = noteCharacterLimit
ni.Focus()
si := textinput.NewModel()
si.Prompt = te.String(searchNotePromptText).Foreground(common.YellowGreen.Color()).String()
si.Prompt = stashTextInputPromptStyle(searchNotePromptText)
si.CursorColor = common.Fuschia.String()
si.CharLimit = noteCharacterLimit
si.Focus()

View file

@ -5,9 +5,7 @@ import (
"strings"
"github.com/charmbracelet/bubbles/textinput"
"github.com/charmbracelet/charm/ui/common"
rw "github.com/mattn/go-runewidth"
te "github.com/muesli/termenv"
)
const (
@ -17,41 +15,6 @@ const (
fileListingStashIcon = "• "
)
var (
normalFg = makeFgStyle(common.NewColorPair("#dddddd", "#1a1a1a"))
dimNormalFg = makeFgStyle(common.NewColorPair("#777777", "#A49FA5"))
warmGrayFg = makeFgStyle(common.NewColorPair("#979797", "#847A85"))
dimWarmGrayFg = makeFgStyle(common.NewColorPair("#4D4D4D", "#C2B8C2"))
grayFg = makeFgStyle(common.NewColorPair("#626262", "#000"))
dimGrayFg = makeFgStyle(common.NewColorPair("#3F3F3F", "#000"))
greenFg = makeFgStyle(common.NewColorPair("#04B575", "#04B575"))
dimGreenFg = makeFgStyle(common.NewColorPair("#0B5137", "#82E1BF"))
fuchsiaFg = makeFgStyle(common.Fuschia)
dimFuchsiaFg = makeFgStyle(common.NewColorPair("#99519E", "#F1A8FF"))
dullFuchsiaFg = makeFgStyle(common.NewColorPair("#AD58B4", "#F793FF"))
dimDullFuchsiaFg = makeFgStyle(common.NewColorPair("#6B3A6F", "#F6C9FF"))
indigoFg = makeFgStyle(common.Indigo)
dimIndigoFg = makeFgStyle(common.NewColorPair("#494690", "#9498FF"))
subtleIndigoFg = makeFgStyle(common.NewColorPair("#514DC1", "#7D79F6"))
dimSubtleIndigoFg = makeFgStyle(common.NewColorPair("#383584", "#BBBDFF"))
yellowFg = makeFgStyle(common.YellowGreen) // renders light green on light backgrounds
dullYellowFg = makeFgStyle(common.NewColorPair("#9BA92F", "#6BCB94")) // renders light green on light backgrounds
redFg = makeFgStyle(common.Red)
faintRedFg = makeFgStyle(common.FaintRed)
)
func makeFgStyle(c common.ColorPair) func(string) string {
return te.Style{}.Foreground(c.Color()).Styled
}
func stashItemView(b *strings.Builder, m stashModel, index int, md *markdown) {
var (
truncateTo = m.terminalWidth - stashViewHorizontalPadding*2

53
ui/styles.go Normal file
View file

@ -0,0 +1,53 @@
package ui
import (
"github.com/charmbracelet/charm/ui/common"
te "github.com/muesli/termenv"
)
type styleFunc func(string) string
const (
darkGray = "#333333"
)
var (
normalFg = newFgStyle(common.NewColorPair("#dddddd", "#1a1a1a"))
dimNormalFg = newFgStyle(common.NewColorPair("#777777", "#A49FA5"))
warmGrayFg = newFgStyle(common.NewColorPair("#979797", "#847A85"))
dimWarmGrayFg = newFgStyle(common.NewColorPair("#4D4D4D", "#C2B8C2"))
grayFg = newFgStyle(common.NewColorPair("#626262", "#000"))
dimGrayFg = newFgStyle(common.NewColorPair("#3F3F3F", "#000"))
greenFg = newFgStyle(common.NewColorPair("#04B575", "#04B575"))
dimGreenFg = newFgStyle(common.NewColorPair("#0B5137", "#82E1BF"))
fuchsiaFg = newFgStyle(common.Fuschia)
dimFuchsiaFg = newFgStyle(common.NewColorPair("#99519E", "#F1A8FF"))
dullFuchsiaFg = newFgStyle(common.NewColorPair("#AD58B4", "#F793FF"))
dimDullFuchsiaFg = newFgStyle(common.NewColorPair("#6B3A6F", "#F6C9FF"))
indigoFg = newFgStyle(common.Indigo)
dimIndigoFg = newFgStyle(common.NewColorPair("#494690", "#9498FF"))
subtleIndigoFg = newFgStyle(common.NewColorPair("#514DC1", "#7D79F6"))
dimSubtleIndigoFg = newFgStyle(common.NewColorPair("#383584", "#BBBDFF"))
yellowFg = newFgStyle(common.YellowGreen) // renders light green on light backgrounds
dullYellowFg = newFgStyle(common.NewColorPair("#9BA92F", "#6BCB94")) // renders light green on light backgrounds
redFg = newFgStyle(common.Red)
faintRedFg = newFgStyle(common.FaintRed)
)
// Returns a termenv style with foreground and background options.
func newStyle(fg, bg common.ColorPair) func(string) string {
return te.Style{}.Foreground(fg.Color()).Background(bg.Color()).Styled
}
// Returns a new termenv style with background options only.
func newFgStyle(c common.ColorPair) styleFunc {
return te.Style{}.Foreground(c.Color()).Styled
}