1package diffview
2
3import (
4 "charm.land/lipgloss/v2"
5 "github.com/charmbracelet/x/exp/charmtone"
6)
7
8// LineStyle defines the styles for a given line type in the diff view.
9type LineStyle struct {
10 LineNumber lipgloss.Style
11 Symbol lipgloss.Style
12 Code lipgloss.Style
13}
14
15// Style defines the overall style for the diff view, including styles for
16// different line types such as divider, missing, equal, insert, and delete
17// lines.
18type Style struct {
19 DividerLine LineStyle
20 MissingLine LineStyle
21 EqualLine LineStyle
22 InsertLine LineStyle
23 DeleteLine LineStyle
24 Filename LineStyle
25}
26
27// DefaultLightStyle provides a default light theme style for the diff view.
28func DefaultLightStyle() Style {
29 return Style{
30 DividerLine: LineStyle{
31 LineNumber: lipgloss.NewStyle().
32 Foreground(charmtone.Iron).
33 Background(charmtone.Thunder),
34 Code: lipgloss.NewStyle().
35 Foreground(charmtone.Oyster).
36 Background(charmtone.Anchovy),
37 },
38 MissingLine: LineStyle{
39 LineNumber: lipgloss.NewStyle().
40 Background(charmtone.Ash),
41 Code: lipgloss.NewStyle().
42 Background(charmtone.Ash),
43 },
44 EqualLine: LineStyle{
45 LineNumber: lipgloss.NewStyle().
46 Foreground(charmtone.Charcoal).
47 Background(charmtone.Ash),
48 Code: lipgloss.NewStyle().
49 Foreground(charmtone.Pepper).
50 Background(charmtone.Salt),
51 },
52 InsertLine: LineStyle{
53 LineNumber: lipgloss.NewStyle().
54 Foreground(charmtone.Turtle).
55 Background(lipgloss.Color("#c8e6c9")),
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 Symbol: lipgloss.NewStyle().
68 Foreground(charmtone.Cherry).
69 Background(lipgloss.Color("#ffebee")),
70 Code: lipgloss.NewStyle().
71 Foreground(charmtone.Pepper).
72 Background(lipgloss.Color("#ffebee")),
73 },
74 Filename: LineStyle{
75 LineNumber: lipgloss.NewStyle().
76 Foreground(charmtone.Iron).
77 Background(charmtone.Thunder),
78 Code: lipgloss.NewStyle().
79 Foreground(charmtone.Iron).
80 Background(charmtone.Thunder),
81 },
82 }
83}
84
85// DefaultDarkStyle provides a default dark theme style for the diff view.
86func DefaultDarkStyle() Style {
87 return Style{
88 DividerLine: LineStyle{
89 LineNumber: lipgloss.NewStyle().
90 Foreground(charmtone.Smoke).
91 Background(charmtone.Sapphire),
92 Code: lipgloss.NewStyle().
93 Foreground(charmtone.Smoke).
94 Background(charmtone.Ox),
95 },
96 MissingLine: LineStyle{
97 LineNumber: lipgloss.NewStyle().
98 Background(charmtone.Charcoal),
99 Code: lipgloss.NewStyle().
100 Background(charmtone.Charcoal),
101 },
102 EqualLine: LineStyle{
103 LineNumber: lipgloss.NewStyle().
104 Foreground(charmtone.Ash).
105 Background(charmtone.Charcoal),
106 Code: lipgloss.NewStyle().
107 Foreground(charmtone.Salt).
108 Background(charmtone.Pepper),
109 },
110 InsertLine: LineStyle{
111 LineNumber: lipgloss.NewStyle().
112 Foreground(charmtone.Turtle).
113 Background(lipgloss.Color("#293229")),
114 Symbol: lipgloss.NewStyle().
115 Foreground(charmtone.Turtle).
116 Background(lipgloss.Color("#303a30")),
117 Code: lipgloss.NewStyle().
118 Foreground(charmtone.Salt).
119 Background(lipgloss.Color("#303a30")),
120 },
121 DeleteLine: LineStyle{
122 LineNumber: lipgloss.NewStyle().
123 Foreground(charmtone.Cherry).
124 Background(lipgloss.Color("#332929")),
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 Filename: LineStyle{
133 LineNumber: lipgloss.NewStyle().
134 Foreground(charmtone.Smoke).
135 Background(charmtone.Sapphire),
136 Code: lipgloss.NewStyle().
137 Foreground(charmtone.Smoke).
138 Background(charmtone.Sapphire),
139 },
140 }
141}