Skip to content

Commit

Permalink
chore(player): Simplify help model creation
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed Apr 27, 2024
1 parent e3bfb86 commit fd995f4
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 9 deletions.
38 changes: 38 additions & 0 deletions internal/movie/help.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package movie

import (
"github.com/charmbracelet/bubbles/help"
"github.com/charmbracelet/lipgloss"
)

func newHelp(renderer *lipgloss.Renderer) help.Model {
keyStyle := lipgloss.NewStyle().Foreground(lipgloss.AdaptiveColor{
Light: "#909090",
Dark: "#626262",
}).Renderer(renderer)

descStyle := lipgloss.NewStyle().Foreground(lipgloss.AdaptiveColor{
Light: "#B2B2B2",
Dark: "#4A4A4A",
}).Renderer(renderer)

sepStyle := lipgloss.NewStyle().Foreground(lipgloss.AdaptiveColor{
Light: "#DDDADA",
Dark: "#3C3C3C",
}).Renderer(renderer)

return help.Model{
ShortSeparator: " • ",
FullSeparator: " ",
Ellipsis: "…",
Styles: help.Styles{
ShortKey: keyStyle,
ShortDesc: descStyle,
ShortSeparator: sepStyle,
Ellipsis: sepStyle.Copy(),
FullKey: keyStyle.Copy(),
FullDesc: descStyle.Copy(),
FullSeparator: sepStyle.Copy(),
},
}
}
10 changes: 1 addition & 9 deletions internal/movie/player.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func NewPlayer(m *Movie, logger *log.Entry, renderer *lipgloss.Renderer) Player
playCtx: playCtx,
playCancel: playCancel,
keymap: newKeymap(),
help: help.New(),
help: newHelp(renderer),
helpViewStale: true,
}

Expand All @@ -41,14 +41,6 @@ func NewPlayer(m *Movie, logger *log.Entry, renderer *lipgloss.Renderer) Player
player.log = logger.WithField("duration", player.durationHook)
}

player.help.Styles.Ellipsis = player.help.Styles.Ellipsis.Renderer(renderer)
player.help.Styles.ShortKey = player.help.Styles.ShortKey.Renderer(renderer)
player.help.Styles.ShortDesc = player.help.Styles.ShortDesc.Renderer(renderer)
player.help.Styles.ShortSeparator = player.help.Styles.ShortSeparator.Renderer(renderer)
player.help.Styles.FullKey = player.help.Styles.FullKey.Renderer(renderer)
player.help.Styles.FullDesc = player.help.Styles.FullDesc.Renderer(renderer)
player.help.Styles.FullSeparator = player.help.Styles.FullSeparator.Renderer(renderer)

return player
}

Expand Down

0 comments on commit fd995f4

Please sign in to comment.