Skip to content

v2.2.0-alpha.0

Pre-release
Pre-release

Choose a tag to compare

@lrstanley lrstanley released this 26 Nov 12:55
· 1 commit to master since this release
v2.2.0-alpha.0
e9e8b2e

Highlights

This alpha adds semantic color roles, plus the color math they're built on. The role names and API should hold, but the derived colors may still be tuned.

Semantic roles

The new roles module works out what each color is for, such as surfaces, muted text, borders, accents and status, from any tint. You style by role instead of picking raw ANSI colors. Text stays readable on dark, light and single-hue tints, and roles fit the terminal's depth: true color, 256 colors, 16 colors, or none.

f := roles.Derive(tint.Current()).Fit(roles.Target{Depth: roles.Colors256})

title := lipgloss.NewStyle().Foreground(f.Color(roles.Accent))
hint := lipgloss.NewStyle().Foreground(f.Color(roles.Subtle))
dialog := lipgloss.NewStyle().Background(f.Color(roles.Raised))
row := f.On(roles.Selection) // text roles, re-checked for the selected row

Apps can add their own roles with roles.Define, and they're derived and fitted alongside the built-in ones. See the roles example.

Color helpers

The root package now has perceptual color helpers: OKLab and OKLCh, Mix, WCAG Contrast and Luminance, IsDark, EnsureContrast and MixReadable. It also has Slot, for the terminal's 16 ANSI colors. It still has no dependencies.

fg := t.BrightBlack.EnsureContrast(*t.Bg, 4.5) // same hue, readable on the background

Changelog

✨ New Features

  • 043124d: add perceptual color helpers, terminal slots, and a roles module (@lrstanley)

🧹 Misc

2 changes

Full changelog: v2.1.0...v2.2.0-alpha.0

📦 Install

go get github.com/lrstanley/bubbletint/chromatint/v2@v2.2.0-alpha.0
go get github.com/lrstanley/bubbletint/glamourtint/v2@v2.2.0-alpha.0
go get github.com/lrstanley/bubbletint/roles/v2@v2.2.0-alpha.0
go get github.com/lrstanley/bubbletint/sources/v2@v2.2.0-alpha.0
go get github.com/lrstanley/bubbletint/v2@v2.2.0-alpha.0

Docs:

💬 What to do next?