Cannot use themes anymore in v2
Description
func (l *Login) askForSSHPassphrase() { if ok, err := utils.IsKeyEncrypted(l.SSHKey); ok && err == nil && l.SSHPassphrase == "" { if err := huh.NewInput(). Title("ssh-key is encrypted please enter the passphrase: "). Validate(huh.ValidateNotEmpty()). EchoMode(huh.EchoModePassword). Value(&l.SSHPassphrase). //WithTheme(theme.GetTheme()). WithTheme(huh.ThemeCharm()). Run(); err != nil { log.Fatal(err) } } }
modules/config/login.go:22:2: "code.gitea.io/tea/modules/theme" imported and not used modules/config/login.go:377:14: not enough arguments in call to huh.ThemeCharm have () want (bool) modules/config/login.go:377:14: cannot use huh.ThemeCharm() (value of type *huh.Styles) as huh.Theme value in argument to huh.NewInput().Title("ssh-key is encrypted please enter the passphrase: ").Validate(huh.ValidateNotEmpty()).EchoMode(huh.EchoModePassword).Value(&l.SSHPassphrase).WithTheme: *huh.Styles does not implement huh.Theme (missing method Theme)
- the theme now requires a value that is difficult to get
- it does not return a value that can be used in WithTheme
workaround:
package theme
import ( "charm.land/huh/v2" "charm.land/lipgloss/v2" "charm.land/lipgloss/v2/compat" )
type myTheme struct {}
func (t myTheme) Theme (isDark bool) *huh.Styles { theme := huh.ThemeCharm(isDark)
title := compat.AdaptiveColor{Light: lipgloss.Color("#02BA84"), Dark: lipgloss.Color("#02BF87")}
theme.Focused.Title = theme.Focused.Title.Foreground(title).Bold(true)
theme.Blurred = theme.Focused
return theme
} func GetTheme() myTheme { var t myTheme return t }
Version
v2.0.1
Environment
No response
Source: charmbracelet/huh