mirror of
https://github.com/charmbracelet/glow
synced 2025-03-04 23:07:12 +00:00
Mop up styling big time
This commit is contained in:
parent
7b7a398c74
commit
4b121593d4
4 changed files with 77 additions and 70 deletions
46
ui/pager.go
46
ui/pager.go
|
@ -21,11 +21,6 @@ import (
|
||||||
|
|
||||||
const (
|
const (
|
||||||
statusBarHeight = 1
|
statusBarHeight = 1
|
||||||
gray = "#333333"
|
|
||||||
yellowGreen = "#ECFD65"
|
|
||||||
fuschia = "#EE6FF8"
|
|
||||||
mintGreen = "#89F0CB"
|
|
||||||
darkGreen = "#1C8760"
|
|
||||||
noteHeadingText = " Set Memo "
|
noteHeadingText = " Set Memo "
|
||||||
notePromptText = " > "
|
notePromptText = " > "
|
||||||
)
|
)
|
||||||
|
@ -33,35 +28,29 @@ const (
|
||||||
var (
|
var (
|
||||||
pagerHelpHeight int
|
pagerHelpHeight int
|
||||||
|
|
||||||
|
mintGreen = common.NewColorPair("#89F0CB", "#89F0CB")
|
||||||
|
darkGreen = common.NewColorPair("#1C8760", "#1C8760")
|
||||||
|
|
||||||
noteHeading = te.String(noteHeadingText).
|
noteHeading = te.String(noteHeadingText).
|
||||||
Foreground(common.Cream.Color()).
|
Foreground(common.Cream.Color()).
|
||||||
Background(common.Green.Color()).
|
Background(common.Green.Color()).
|
||||||
String()
|
String()
|
||||||
|
|
||||||
statusBarBg = common.NewColorPair("#242424", "#E6E6E6")
|
|
||||||
statusBarNoteFg = common.NewColorPair("#7D7D7D", "#656565")
|
statusBarNoteFg = common.NewColorPair("#7D7D7D", "#656565")
|
||||||
|
statusBarBg = common.NewColorPair("#242424", "#E6E6E6")
|
||||||
|
|
||||||
// Styling functions.
|
// Styling funcs
|
||||||
statusBarScrollPosStyle = newStyle(common.NewColorPair("#5A5A5A", "#949494").String(), statusBarBg.String())
|
statusBarScrollPosStyle = newStyle(common.NewColorPair("#5A5A5A", "#949494"), statusBarBg)
|
||||||
statusBarNoteStyle = newStyle(statusBarNoteFg.String(), statusBarBg.String())
|
statusBarNoteStyle = newStyle(statusBarNoteFg, statusBarBg)
|
||||||
statusBarHelpStyle = newStyle(statusBarNoteFg.String(), common.NewColorPair("#323232", "#DCDCDC").String())
|
statusBarHelpStyle = newStyle(statusBarNoteFg, common.NewColorPair("#323232", "#DCDCDC"))
|
||||||
statusBarStashDotStyle = newStyle(common.Green.String(), statusBarBg.String())
|
statusBarStashDotStyle = newStyle(common.Green, statusBarBg)
|
||||||
statusBarMessageStyle = newStyle(mintGreen, darkGreen)
|
statusBarMessageStyle = newStyle(mintGreen, darkGreen)
|
||||||
statusBarMessageStashIconStyle = newStyle(mintGreen, darkGreen)
|
statusBarMessageStashIconStyle = newStyle(mintGreen, darkGreen)
|
||||||
statusBarMessageScrollPosStyle = newStyle(mintGreen, darkGreen)
|
statusBarMessageScrollPosStyle = newStyle(mintGreen, darkGreen)
|
||||||
statusBarMessageHelpStyle = newStyle("#B6FFE4", common.Green.String())
|
statusBarMessageHelpStyle = newStyle(common.NewColorPair("#B6FFE4", "#B6FFE4"), common.Green)
|
||||||
|
helpViewStyle = newStyle(statusBarNoteFg, common.NewColorPair("#1B1B1B", "#f2f2f2"))
|
||||||
helpViewStyle = newStyle(statusBarNoteFg.String(), common.NewColorPair("#1B1B1B", "#f2f2f2").String())
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// 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 contentRenderedMsg string
|
||||||
type noteSavedMsg *charm.Markdown
|
type noteSavedMsg *charm.Markdown
|
||||||
type stashSuccessMsg markdown
|
type stashSuccessMsg markdown
|
||||||
|
@ -109,18 +98,19 @@ func newPagerModel(cfg *Config, as authStatus) pagerModel {
|
||||||
vp.YPosition = 0
|
vp.YPosition = 0
|
||||||
vp.HighPerformanceRendering = config.HighPerformancePager
|
vp.HighPerformanceRendering = config.HighPerformancePager
|
||||||
|
|
||||||
// Init text input UI for notes/memos
|
// Text input for notes/memos
|
||||||
ti := textinput.NewModel()
|
ti := textinput.NewModel()
|
||||||
ti.Prompt = te.String(notePromptText).
|
ti.Prompt = te.String(notePromptText).
|
||||||
Foreground(te.ColorProfile().Color(gray)).
|
Foreground(common.Color(darkGray)).
|
||||||
Background(te.ColorProfile().Color(yellowGreen)).
|
Background(common.YellowGreen.Color()).
|
||||||
String()
|
String()
|
||||||
ti.TextColor = gray
|
ti.TextColor = darkGray
|
||||||
ti.BackgroundColor = yellowGreen
|
ti.BackgroundColor = common.YellowGreen.String()
|
||||||
ti.CursorColor = fuschia
|
ti.CursorColor = common.Fuschia.String()
|
||||||
ti.CharLimit = noteCharacterLimit
|
ti.CharLimit = noteCharacterLimit
|
||||||
ti.Focus()
|
ti.Focus()
|
||||||
|
|
||||||
|
// Text input for search
|
||||||
sp := spinner.NewModel()
|
sp := spinner.NewModel()
|
||||||
sp.ForegroundColor = statusBarNoteFg.String()
|
sp.ForegroundColor = statusBarNoteFg.String()
|
||||||
sp.BackgroundColor = statusBarBg.String()
|
sp.BackgroundColor = statusBarBg.String()
|
||||||
|
|
11
ui/stash.go
11
ui/stash.go
|
@ -34,9 +34,10 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
stashHelpItemStyle func(string) string = te.Style{}.Foreground(common.NewColorPair("#5C5C5C", "#9B9B9B").Color()).Styled
|
stashHelpItemStyle styleFunc = newFgStyle(common.NewColorPair("#5C5C5C", "#9B9B9B"))
|
||||||
dividerDot string = te.String(" • ").Foreground(common.NewColorPair("#3C3C3C", "#DDDADA").Color()).String()
|
stashTextInputPromptStyle styleFunc = newFgStyle(common.YellowGreen)
|
||||||
offlineHeaderNote string = te.String("(Offline)").Foreground(common.NewColorPair("#3C3C3C", "#DDDADA").Color()).String()
|
dividerDot string = te.String(" • ").Foreground(common.NewColorPair("#3C3C3C", "#DDDADA").Color()).String()
|
||||||
|
offlineHeaderNote string = te.String("(Offline)").Foreground(common.NewColorPair("#3C3C3C", "#DDDADA").Color()).String()
|
||||||
)
|
)
|
||||||
|
|
||||||
// MSG
|
// MSG
|
||||||
|
@ -318,13 +319,13 @@ func newStashModel(cfg *Config, as authStatus) stashModel {
|
||||||
p.InactiveDot = common.Subtle("•")
|
p.InactiveDot = common.Subtle("•")
|
||||||
|
|
||||||
ni := textinput.NewModel()
|
ni := textinput.NewModel()
|
||||||
ni.Prompt = te.String(setNotePromptText).Foreground(common.YellowGreen.Color()).String()
|
ni.Prompt = stashTextInputPromptStyle(setNotePromptText)
|
||||||
ni.CursorColor = common.Fuschia.String()
|
ni.CursorColor = common.Fuschia.String()
|
||||||
ni.CharLimit = noteCharacterLimit
|
ni.CharLimit = noteCharacterLimit
|
||||||
ni.Focus()
|
ni.Focus()
|
||||||
|
|
||||||
si := textinput.NewModel()
|
si := textinput.NewModel()
|
||||||
si.Prompt = te.String(searchNotePromptText).Foreground(common.YellowGreen.Color()).String()
|
si.Prompt = stashTextInputPromptStyle(searchNotePromptText)
|
||||||
si.CursorColor = common.Fuschia.String()
|
si.CursorColor = common.Fuschia.String()
|
||||||
si.CharLimit = noteCharacterLimit
|
si.CharLimit = noteCharacterLimit
|
||||||
si.Focus()
|
si.Focus()
|
||||||
|
|
|
@ -5,9 +5,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/charmbracelet/bubbles/textinput"
|
"github.com/charmbracelet/bubbles/textinput"
|
||||||
"github.com/charmbracelet/charm/ui/common"
|
|
||||||
rw "github.com/mattn/go-runewidth"
|
rw "github.com/mattn/go-runewidth"
|
||||||
te "github.com/muesli/termenv"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -17,41 +15,6 @@ const (
|
||||||
fileListingStashIcon = "• "
|
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) {
|
func stashItemView(b *strings.Builder, m stashModel, index int, md *markdown) {
|
||||||
var (
|
var (
|
||||||
truncateTo = m.terminalWidth - stashViewHorizontalPadding*2
|
truncateTo = m.terminalWidth - stashViewHorizontalPadding*2
|
||||||
|
|
53
ui/styles.go
Normal file
53
ui/styles.go
Normal 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
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue