style.go

  1package diffview
  2
  3import (
  4	"github.com/charmbracelet/lipgloss/v2"
  5	"github.com/charmbracelet/x/exp/charmtone"
  6)
  7
  8type LineStyle struct {
  9	LineNumber lipgloss.Style
 10	Symbol     lipgloss.Style
 11	Code       lipgloss.Style
 12}
 13
 14type Style struct {
 15	DividerLine LineStyle
 16	MissingLine LineStyle
 17	EqualLine   LineStyle
 18	InsertLine  LineStyle
 19	DeleteLine  LineStyle
 20}
 21
 22var DefaultLightStyle = Style{
 23	DividerLine: LineStyle{
 24		LineNumber: lipgloss.NewStyle().
 25			Foreground(charmtone.Iron).
 26			Background(charmtone.Thunder),
 27		Code: lipgloss.NewStyle().
 28			Foreground(charmtone.Oyster).
 29			Background(charmtone.Anchovy),
 30	},
 31	MissingLine: LineStyle{
 32		LineNumber: lipgloss.NewStyle().
 33			Background(charmtone.Ash),
 34		Code: lipgloss.NewStyle().
 35			Background(charmtone.Ash),
 36	},
 37	EqualLine: LineStyle{
 38		LineNumber: lipgloss.NewStyle().
 39			Foreground(charmtone.Charcoal).
 40			Background(charmtone.Ash),
 41		Code: lipgloss.NewStyle().
 42			Foreground(charmtone.Pepper).
 43			Background(charmtone.Salt),
 44	},
 45	InsertLine: LineStyle{
 46		LineNumber: lipgloss.NewStyle().
 47			Foreground(charmtone.Turtle).
 48			Background(lipgloss.Color("#c8e6c9")),
 49		Symbol: lipgloss.NewStyle().
 50			Foreground(charmtone.Turtle).
 51			Background(lipgloss.Color("#e8f5e9")),
 52		Code: lipgloss.NewStyle().
 53			Foreground(charmtone.Pepper).
 54			Background(lipgloss.Color("#e8f5e9")),
 55	},
 56	DeleteLine: LineStyle{
 57		LineNumber: lipgloss.NewStyle().
 58			Foreground(charmtone.Cherry).
 59			Background(lipgloss.Color("#ffcdd2")),
 60		Symbol: lipgloss.NewStyle().
 61			Foreground(charmtone.Cherry).
 62			Background(lipgloss.Color("#ffebee")),
 63		Code: lipgloss.NewStyle().
 64			Foreground(charmtone.Pepper).
 65			Background(lipgloss.Color("#ffebee")),
 66	},
 67}
 68
 69var DefaultDarkStyle = Style{
 70	DividerLine: LineStyle{
 71		LineNumber: lipgloss.NewStyle().
 72			Foreground(charmtone.Smoke).
 73			Background(charmtone.Sapphire),
 74		Code: lipgloss.NewStyle().
 75			Foreground(charmtone.Smoke).
 76			Background(charmtone.Ox),
 77	},
 78	MissingLine: LineStyle{
 79		LineNumber: lipgloss.NewStyle().
 80			Background(charmtone.Charcoal),
 81		Code: lipgloss.NewStyle().
 82			Background(charmtone.Charcoal),
 83	},
 84	EqualLine: LineStyle{
 85		LineNumber: lipgloss.NewStyle().
 86			Foreground(charmtone.Ash).
 87			Background(charmtone.Charcoal),
 88		Code: lipgloss.NewStyle().
 89			Foreground(charmtone.Salt).
 90			Background(charmtone.Pepper),
 91	},
 92	InsertLine: LineStyle{
 93		LineNumber: lipgloss.NewStyle().
 94			Foreground(charmtone.Turtle).
 95			Background(lipgloss.Color("#293229")),
 96		Symbol: lipgloss.NewStyle().
 97			Foreground(charmtone.Turtle).
 98			Background(lipgloss.Color("#303a30")),
 99		Code: lipgloss.NewStyle().
100			Foreground(charmtone.Salt).
101			Background(lipgloss.Color("#303a30")),
102	},
103	DeleteLine: LineStyle{
104		LineNumber: lipgloss.NewStyle().
105			Foreground(charmtone.Cherry).
106			Background(lipgloss.Color("#332929")),
107		Symbol: lipgloss.NewStyle().
108			Foreground(charmtone.Cherry).
109			Background(lipgloss.Color("#3a3030")),
110		Code: lipgloss.NewStyle().
111			Foreground(charmtone.Salt).
112			Background(lipgloss.Color("#3a3030")),
113	},
114}