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