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.
fix #166
@meowgorithm @muesli This is not ready to be merged, but I'd like to have your opinion on it.
For some context, I'm the author of https://github.com/MichaelMure/git-bug. Also by necessity (as Charm didn't exist or barely at that time), https://github.com/MichaelMure/go-term-text (equivalent of
muesli/reflow
,muesli/ansi
) and https://github.com/MichaelMure/go-term-markdown (equivalent ofcharmbracelet/glow
). Nowadays I'd like to transition to or leverage Charm for git-bug.I nerd sniped myself into implementing this for two reasons:
As such, well, job done. I scratched that itch, and I'd be fine if this is not merged if it doesn't fit this project goals.
Now, onto the actual meat of this:
I find the idea of mirroring CSS to be brilliant. It's one of those things that makes so much sense retrospectively. I sense however that
lipgloss
currently fall a bit short how its promise (or what I expected that promise to be): what makes the web model great for interfaces is CSS and HTML. Cascading style sheets and a hierarchy of content and containers.What I mean by that is that
lipgloss
is great for styling and make a decent attempt at shaping content (width/height, alignment...), but fell quite short for laying out.JoinHorizontal
andJoinVertical
provides the beginning of that, but it's quite primitive: they lead to a world where we keep doing math with sizes, remaining space, and assembling fragment manually.This is IMHO limiting, and why I toyed with this idea of flexbox. What if we had strong layout support, directly in the bedrock that
lipgloss
is? We could easily build interfaces where containers would grow and shrink nicely, or wrap and adapt if the available space is not enough. We'd get powerful capabilities for spacing containers, adapting their flow into columns, rows, changing their order ... and all that would be as easily tweak-able as a style.I can see that happening in two ways:
lipgloss
as CSS and HTML.Style
would learn to have children styles (thus making a hierarchy of content).Style.SetString()
would become a first-class way to set content.Style.Render()
would learn to layout children (classic layout, flexbox, or even CSS grids).Style
attached to set styling and layout properties. That new primitive would know how to leverage the layout functions likeJoinHorizontal
, flexbox ... to do the final render.This hierarchy is a requirement, because a single layer of layout is still limiting. This page layout image I used higher is actually two flexbox. As the article container grow, it pushes the footer down. If the global container get squished, it might squish that article. A recursive layout is necessary to have those interactions both way.
I've included a toy program in
test-flexbox
to get a sense of the capabilities. You might still see some issues popping up. Also, not all flexbox is implemented.