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