a054be839f5b34abd607fda993c291597e82126e

Author
Christian Rocha <christian@rocha.is>
Committer
Ayman Bagabas <ayman.bagabas@gmail.com>
Date

Message

chore: adjust highlight style in top level repo selector

Diff

  1diff --git a/ui/components/selector/selector.go b/ui/components/selector/selector.go
  2index ed044990e6d76473d015bb7b2c93b5352408bc02..4beea1fe3e6ca934688c680bcebdeceaf9af6a73 100644
  3--- a/ui/components/selector/selector.go
  4+++ b/ui/components/selector/selector.go
  5@@ -15,7 +15,8 @@ type Selector struct {
  6 	filterState list.FilterState
  7 }
  8 
  9-// IdentifiableItem is an item that can be identified by a string. Implements list.DefaultItem.
 10+// IdentifiableItem is an item that can be identified by a string. Implements
 11+// list.DefaultItem.
 12 type IdentifiableItem interface {
 13 	list.DefaultItem
 14 	ID() string
 15diff --git a/ui/pages/selection/item.go b/ui/pages/selection/item.go
 16index 8629add33afe730cc14fa87d5d2ef684007ef845..859ebdf4b7beb6e1cde110a2e0fddd446e257932 100644
 17--- a/ui/pages/selection/item.go
 18+++ b/ui/pages/selection/item.go
 19@@ -84,7 +84,6 @@ func (d ItemDelegate) Update(msg tea.Msg, m *list.Model) tea.Cmd {
 20 
 21 // Render implements list.ItemDelegate.
 22 func (d ItemDelegate) Render(w io.Writer, m list.Model, index int, listItem list.Item) {
 23-	styles := d.common.Styles
 24 	i := listItem.(Item)
 25 	s := strings.Builder{}
 26 	var matchedRunes []int
 27@@ -95,20 +94,13 @@ func (d ItemDelegate) Render(w io.Writer, m list.Model, index int, listItem list
 28 		isFiltered = m.FilterState() == list.Filtering || m.FilterState() == list.FilterApplied
 29 	)
 30 
 31-	itemStyle := styles.MenuItem.Copy()
 32+	styles := d.common.Styles.RepoSelector.Normal
 33 	if isSelected {
 34-		itemStyle = itemStyle.Copy().
 35-			BorderStyle(lipgloss.Border{
 36-				Left: "โ”ƒ",
 37-			}).
 38-			BorderForeground(styles.ActiveBorderColor)
 39-		if d.activePane != nil && *d.activePane == readmePane {
 40-			itemStyle = itemStyle.BorderForeground(styles.InactiveBorderColor)
 41-		}
 42+		styles = d.common.Styles.RepoSelector.Active
 43 	}
 44 
 45 	title := i.Title()
 46-	title = common.TruncateString(title, m.Width()-itemStyle.GetHorizontalFrameSize())
 47+	title = common.TruncateString(title, m.Width()-styles.Base.GetHorizontalFrameSize())
 48 	if i.repo.IsPrivate() {
 49 		title += " ๐Ÿ”’"
 50 	}
 51@@ -116,15 +108,12 @@ func (d ItemDelegate) Render(w io.Writer, m list.Model, index int, listItem list
 52 		title += " "
 53 	}
 54 	updatedStr := fmt.Sprintf(" Updated %s", humanize.Time(i.lastUpdate))
 55-	if m.Width()-itemStyle.GetHorizontalFrameSize()-lipgloss.Width(updatedStr)-lipgloss.Width(title) <= 0 {
 56+	if m.Width()-styles.Base.GetHorizontalFrameSize()-lipgloss.Width(updatedStr)-lipgloss.Width(title) <= 0 {
 57 		updatedStr = ""
 58 	}
 59-	updatedStyle := styles.MenuLastUpdate.Copy().
 60+	updatedStyle := styles.Updated.Copy().
 61 		Align(lipgloss.Right).
 62-		Width(m.Width() - itemStyle.GetHorizontalFrameSize() - lipgloss.Width(title))
 63-	if isSelected {
 64-		updatedStyle = updatedStyle.Bold(true)
 65-	}
 66+		Width(m.Width() - styles.Base.GetHorizontalFrameSize() - lipgloss.Width(title))
 67 	updated := updatedStyle.Render(updatedStr)
 68 
 69 	if isFiltered && index < len(m.VisibleItems()) {
 70@@ -141,30 +130,20 @@ func (d ItemDelegate) Render(w io.Writer, m list.Model, index int, listItem list
 71 		}
 72 		title = lipgloss.StyleRunes(title, matchedRunes, matched, unmatched)
 73 	}
 74-	titleStyle := lipgloss.NewStyle()
 75-	if isSelected {
 76-		titleStyle = titleStyle.Bold(true)
 77-	}
 78-	title = titleStyle.Render(title)
 79+	title = styles.Title.Render(title)
 80 	desc := i.Description()
 81-	descStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("243"))
 82-	if desc == "" {
 83-		desc = "No description"
 84-		descStyle = descStyle.Faint(true)
 85-	}
 86-	desc = common.TruncateString(desc, m.Width()-itemStyle.GetHorizontalFrameSize())
 87-	desc = descStyle.Render(desc)
 88+	desc = common.TruncateString(desc, m.Width()-styles.Base.GetHorizontalFrameSize())
 89+	desc = styles.Desc.Render(desc)
 90 
 91 	s.WriteString(lipgloss.JoinHorizontal(lipgloss.Bottom, title, updated))
 92-	s.WriteString("\n")
 93+	s.WriteRune('\n')
 94 	s.WriteString(desc)
 95-	s.WriteString("\n")
 96-	cmdStyle := styles.Repo.Command.Copy()
 97-	cmd := common.TruncateString(i.Command(), m.Width()-itemStyle.GetHorizontalFrameSize())
 98-	cmd = cmdStyle.Render(cmd)
 99+	s.WriteRune('\n')
100+	cmd := common.TruncateString(i.Command(), m.Width()-styles.Base.GetHorizontalFrameSize())
101+	cmd = styles.Command.Render(cmd)
102 	if !i.copied.IsZero() && i.copied.Add(time.Second).After(time.Now()) {
103-		cmd = cmdStyle.Render("Copied!")
104+		cmd = styles.Command.Render("Copied!")
105 	}
106 	s.WriteString(cmd)
107-	fmt.Fprint(w, itemStyle.Render(s.String()))
108+	fmt.Fprint(w, styles.Base.Render(s.String()))
109 }
110diff --git a/ui/pages/selection/selection.go b/ui/pages/selection/selection.go
111index 0e965a7f7006f2c51f9a5c08f199e93a61e00aba..01e3d52a2683931589dd55fb29bea4d0cfe4203a 100644
112--- a/ui/pages/selection/selection.go
113+++ b/ui/pages/selection/selection.go
114@@ -52,7 +52,7 @@ func New(cfg *config.Config, pk ssh.PublicKey, common common.Common) *Selection
115 	}
116 	t := tabs.New(common, ts)
117 	t.TabSeparator = lipgloss.NewStyle()
118-	t.TabInactive = common.Styles.TopLevelTabNormal.Copy()
119+	t.TabInactive = common.Styles.TopLevelNormalTab.Copy()
120 	t.TabActive = common.Styles.TopLevelActiveTab.Copy()
121 	t.TabDot = common.Styles.TopLevelActiveTabDot.Copy()
122 	t.UseDot = true
123diff --git a/ui/styles/styles.go b/ui/styles/styles.go
124index 5b079bbfb0c20d7f1a36fef2b3ae16e3567aa220..55b4989d1229b6012f42c754ee537d7a3d047909 100644
125--- a/ui/styles/styles.go
126+++ b/ui/styles/styles.go
127@@ -21,6 +21,23 @@ type Styles struct {
128 	MenuItem       lipgloss.Style
129 	MenuLastUpdate lipgloss.Style
130 
131+	RepoSelector struct {
132+		Normal struct {
133+			Base,
134+			Title,
135+			Desc,
136+			Command,
137+			Updated lipgloss.Style
138+		}
139+		Active struct {
140+			Base,
141+			Title,
142+			Desc,
143+			Command,
144+			Updated lipgloss.Style
145+		}
146+	}
147+
148 	Repo struct {
149 		Base       lipgloss.Style
150 		Title      lipgloss.Style
151@@ -154,6 +171,40 @@ func DefaultStyles() *Styles {
152 	s.TopLevelActiveTabDot = lipgloss.NewStyle().
153 		Foreground(lipgloss.Color("29"))
154 
155+	s.RepoSelector.Normal.Base = lipgloss.NewStyle().
156+		PaddingLeft(1).
157+		Border(lipgloss.Border{Left: " "}, false, false, false, true).
158+		Height(3)
159+
160+	s.RepoSelector.Normal.Title = lipgloss.NewStyle().
161+		Foreground(lipgloss.Color("212")).
162+		Bold(true)
163+
164+	s.RepoSelector.Normal.Desc = lipgloss.NewStyle().
165+		Foreground(lipgloss.Color("250"))
166+
167+	s.RepoSelector.Normal.Command = lipgloss.NewStyle().
168+		Foreground(lipgloss.Color("246"))
169+
170+	s.RepoSelector.Normal.Updated = lipgloss.NewStyle()
171+
172+	s.RepoSelector.Active.Base = s.RepoSelector.Normal.Base.Copy().
173+		BorderStyle(lipgloss.Border{Left: "โ”ƒ"}).
174+		BorderForeground(selectorColor)
175+
176+	s.RepoSelector.Active.Title = lipgloss.NewStyle().
177+		Foreground(highlightColor).
178+		Bold(true)
179+
180+	s.RepoSelector.Active.Desc = lipgloss.NewStyle().
181+		Foreground(highlightColorDim)
182+
183+	s.RepoSelector.Active.Updated = s.RepoSelector.Normal.Updated.Copy().
184+		Foreground(highlightColorDim)
185+
186+	s.RepoSelector.Active.Command = lipgloss.NewStyle().
187+		Foreground(lipgloss.Color("138"))
188+
189 	s.MenuItem = lipgloss.NewStyle().
190 		PaddingLeft(1).
191 		Border(lipgloss.Border{