x icon indicating copy to clipboard operation
x copied to clipboard

refactor(colors): update to lipgloss alpha

Open bashbunni opened this issue 1 year ago • 0 comments

TODO

  • [ ] update the lipgloss branch to the latest v2-exp

Example Usage:

Divides into Light and Dark colour palettes. In your app, you can switch which colour palette depending on the TerminalBackgroundMsg

func NewStyle(isDark bool) Styles {
	color := colors.Light
	if isDark {
    	color = colors.Dark
	}
	return Styles{
    	Normal:        	lipgloss.NewStyle().Foreground(color.Normal),
    	NormalDim:     	lipgloss.NewStyle().Foreground(color.NormalDim),
    	Keyword:       	lipgloss.NewStyle().Foreground(color.Green),
    	KeywordDim:    	lipgloss.NewStyle().Foreground(color.GreenDim),
    	Item:          	lipgloss.NewStyle().PaddingLeft(3),
    	DeletingItem:  	lipgloss.NewStyle().Foreground(color.Red),
    	SelectedItem:  	lipgloss.NewStyle().Foreground(lipgloss.Color("170")),
    	Accent:        	lipgloss.NewStyle().Foreground(color.Fuschia),
}}

In your model’s Update:

	case tea.BackgroundColorMsg:
    	isDark := lipgloss.IsDarkColor(msg)
    	// Update styles
    	m.Styles = NewStyle(isDark)
    	m.setBubbleStyles() // sets the styles for all of the submodels/bubbles used by this model

bashbunni avatar Aug 22 '24 18:08 bashbunni