Migrate to Charm v2 (bubbletea, bubbles, lipgloss)#14
Open
Gaurav-Gosain wants to merge 2 commits into
Open
Conversation
Bumps the TUI dependencies from the old github.com/charmbracelet/...
v1 modules to the new charm.land/.../v2 modules:
charm.land/bubbletea/v2 v2.0.6
charm.land/bubbles/v2 v2.1.0
charm.land/lipgloss/v2 v2.0.3
The migration touches only the jsonview package, which is the sole
consumer of bubbletea/bubbles/lipgloss. Notable v2 API changes
applied:
- tea.KeyMsg renamed to tea.KeyPressMsg
- Model.View() now returns tea.View, wrapped via tea.NewView
- viewport.New(w, h) replaced with viewport.New(WithWidth, WithHeight)
- Width/Height fields replaced with SetWidth/SetHeight methods on
viewport and help
- lipgloss.Color is now a function returning image/color.Color, so
the array/string/object color values move from const to var and
createTable's bgColor parameter is retyped accordingly
x/term is bumped 0.2.1 to 0.2.2 to align with the indirect deps
pulled in by charm v2.
go build, go vet, and the jsonview tests all pass.
In v1, viewport.View() rendered content even when its width was 0, which is what the explorer's TableView relied on, since Resize never called SetWidth on the table. In v2, viewport.View() short-circuits to an empty string when either dimension is 0, so rows stopped rendering after the migration. Setting the table width to the full window width fixes the empty rows but makes the underlying viewport pad each row to that width, which made the selected-row highlight overflow past the surrounding rounded border. Size the table to the natural content width (sum of column widths plus cell padding) so rows render and the highlight stays within the border.
|
Hello! One of the Bubble Tea/Lip Gloss authors here. Just chiming in to say that the main benefits you'll get from the upgrade here is rendering performance and correctness in terms of glyph rendering, particularly with non-latin characters such as Chinese, Japanese, Korean and so on. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Bumps the TUI dependencies from the old
github.com/charmbracelet/...v1 modules to the newcharm.land/.../v2modules at the latest stable versions:charm.land/bubbletea/v2v2.0.6charm.land/bubbles/v2v2.1.0charm.land/lipgloss/v2v2.0.3github.com/charmbracelet/x/termis also bumped from 0.2.1 to 0.2.2 to line up with the indirect deps that come with charm v2.Scope
The migration only touches the
internal/jsonviewpackage, which is the sole consumer of bubbletea/bubbles/lipgloss in this repo. The other 4 files modified arego.modandgo.sumfor the dep bump, and the test file for the import path swap.Notable v2 API changes applied
tea.KeyMsgrenamed totea.KeyPressMsgModel.View()now returnstea.View, wrapped viatea.NewViewviewport.New(w, h)replaced withviewport.New(WithWidth(w), WithHeight(h))Width/Heightfields replaced withSetWidth/SetHeightmethods on viewport and helplipgloss.Coloris now a function returningimage/color.Color, so thearrayColor/stringColor/objectColorvalues move fromconsttovar, andcreateTable'sbgColorparameter is retyped fromlipgloss.Colortocolor.ColorReference for the full set of v2 breaking changes: the upgrade guides shipped with each module (
UPGRADE_GUIDE_V2.md).Test plan