Skip to content

Commit b0a1f0a

Browse files
authored
Use user highlight color as constant (#14)
1 parent 7cc9ad5 commit b0a1f0a

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
build:
2-
-mkdir -p ./bin
2+
mkdir -p ./bin
33
CGO_ENABLED=0 go build -o ./bin/ttchat ./main.go
44

55
test:
6-
go test -v -count=1 -v -cover -race ./...
6+
go test -v -count=1 -cover -race ./...
77

88
cover-profile:
99
go test -coverprofile=coverage.out ./...

internal/irc/irc.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func (c IRCService) Publish(msg string) {
7979

8080
styled := highlightUserMentions(msg, c.displayName)
8181
c.upstream <- types.PrivateMessage{
82-
Name: lipgloss.NewStyle().Background(lipgloss.Color(UserHighlightColor)).Render(c.displayName),
82+
Name: UserHighLightStyle.Render(c.displayName),
8383
Text: styled,
8484
}
8585
}
@@ -88,7 +88,7 @@ func highlightUserMentions(text string, displayName string) string {
8888
texts := strings.Split(text, " ")
8989
for i, w := range texts {
9090
if strings.Contains(w, fmt.Sprintf("@%s", displayName)) {
91-
texts[i] = lipgloss.NewStyle().Background(lipgloss.Color(UserHighlightColor)).Render(w)
91+
texts[i] = UserHighLightStyle.Render(w)
9292
}
9393
}
9494
return strings.Join(texts, " ")

internal/irc/irc_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func TestGetMessageSource(t *testing.T) {
7171
Text: "hi @user",
7272
},
7373
lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color(DefaultNameColor)).Render("foo"),
74-
fmt.Sprintf("hi %s", lipgloss.NewStyle().Background(lipgloss.Color(UserHighlightColor)).Render("@user")),
74+
fmt.Sprintf("hi %s", UserHighLightStyle.Render("@user")),
7575
},
7676
{
7777
"incoming is you",
@@ -118,7 +118,7 @@ func TestPublish(t *testing.T) {
118118
"publish message",
119119
"user",
120120
"testText",
121-
lipgloss.NewStyle().Background(lipgloss.Color(UserHighlightColor)).Render("user"),
121+
UserHighLightStyle.Render("user"),
122122
"testText",
123123
},
124124
}

0 commit comments

Comments
 (0)