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	EqualLine   LineStyle
 17	InsertLine  LineStyle
 18	DeleteLine  LineStyle
 19}
 20
 21var DefaultLightStyle = Style{
 22	DividerLine: LineStyle{
 23		LineNumber: lipgloss.NewStyle().
 24			Foreground(charmtone.Iron).
 25			Background(charmtone.Thunder).
 26			Align(lipgloss.Right).
 27			Padding(0, 1),
 28		Code: lipgloss.NewStyle().
 29			Foreground(charmtone.Oyster).
 30			Background(charmtone.Anchovy),
 31	},
 32	EqualLine: LineStyle{
 33		LineNumber: lipgloss.NewStyle().
 34			Foreground(charmtone.Charcoal).
 35			Background(charmtone.Ash).
 36			Align(lipgloss.Right).
 37			Padding(0, 1),
 38		Code: lipgloss.NewStyle().
 39			Foreground(charmtone.Pepper).
 40			Background(charmtone.Salt),
 41	},
 42	InsertLine: LineStyle{
 43		LineNumber: lipgloss.NewStyle().
 44			Foreground(charmtone.Turtle).
 45			Background(lipgloss.Color("#c8e6c9")).
 46			Align(lipgloss.Right).
 47			Padding(0, 1),
 48		Symbol: lipgloss.NewStyle().
 49			Foreground(charmtone.Turtle).
 50			Background(lipgloss.Color("#e8f5e9")),
 51		Code: lipgloss.NewStyle().
 52			Foreground(charmtone.Pepper).
 53			Background(lipgloss.Color("#e8f5e9")),
 54	},
 55	DeleteLine: LineStyle{
 56		LineNumber: lipgloss.NewStyle().
 57			Foreground(charmtone.Cherry).
 58			Background(lipgloss.Color("#ffcdd2")).
 59			Align(lipgloss.Left).
 60			Padding(0, 1),
 61		Symbol: lipgloss.NewStyle().
 62			Foreground(charmtone.Cherry).
 63			Background(lipgloss.Color("#ffebee")),
 64		Code: lipgloss.NewStyle().
 65			Foreground(charmtone.Pepper).
 66			Background(lipgloss.Color("#ffebee")),
 67	},
 68}
 69
 70var DefaultDarkStyle = Style{
 71	DividerLine: LineStyle{
 72		LineNumber: lipgloss.NewStyle().
 73			Foreground(charmtone.Smoke).
 74			Background(charmtone.Sapphire).
 75			Align(lipgloss.Right).
 76			Padding(0, 1),
 77		Code: lipgloss.NewStyle().
 78			Foreground(charmtone.Smoke).
 79			Background(charmtone.Ox),
 80	},
 81	EqualLine: LineStyle{
 82		LineNumber: lipgloss.NewStyle().
 83			Foreground(charmtone.Ash).
 84			Background(charmtone.Charcoal).
 85			Align(lipgloss.Right).
 86			Padding(0, 1),
 87		Code: lipgloss.NewStyle().
 88			Foreground(charmtone.Salt).
 89			Background(charmtone.Pepper),
 90	},
 91	InsertLine: LineStyle{
 92		LineNumber: lipgloss.NewStyle().
 93			Foreground(charmtone.Turtle).
 94			Background(lipgloss.Color("#293229")).
 95			Align(lipgloss.Right).
 96			Padding(0, 1),
 97		Symbol: lipgloss.NewStyle().
 98			Foreground(charmtone.Turtle).
 99			Background(lipgloss.Color("#303a30")),
100		Code: lipgloss.NewStyle().
101			Foreground(charmtone.Salt).
102			Background(lipgloss.Color("#303a30")),
103	},
104	DeleteLine: LineStyle{
105		LineNumber: lipgloss.NewStyle().
106			Foreground(charmtone.Cherry).
107			Background(lipgloss.Color("#332929")).
108			Align(lipgloss.Left).
109			Padding(0, 1),
110		Symbol: lipgloss.NewStyle().
111			Foreground(charmtone.Cherry).
112			Background(lipgloss.Color("#3a3030")),
113		Code: lipgloss.NewStyle().
114			Foreground(charmtone.Salt).
115			Background(lipgloss.Color("#3a3030")),
116	},
117}