charmbracelet / charmbracelet/bubbles
Bubble Model Interface for Layout Management
- Dominant language
- Go
- Stars
- 8.9k
- Forks
- 457
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 5
Description
Bubbles' (visual) components should likely adhere/implement a `bubble.Model` interface so that we can help with layout management i.e. automatic resizing and layout management which is getting slightly repetitive in most projects with any sort of complicated layout.
The interface will likely have to allow setting widths and heights so that we can resize the visual component and possibly have blur and focus states so the component can act accordingly if we shift focus away from it (i.e. lazy rendering, stop blinking cursor, etc...).
```go
package bubbles
interface Visual {
SetHeight func(int)
SetWidth func(int)
Height func() int
Width func() int
}
```
We can then allow for relative / flex-box style layouts by allowing people to have a layout manager which can resize components automatically based on certain attributes when we received a `WindowResizeMsg`. For example, I could place two containers and give them a relative width of `0.5` each and the layout manager could `SetWidth` to half of the screen automatically so that layouts are responsive.
It's worth thinking about what logic should go in `lipgloss` vs `bubbles` itself.
Contributor guide
Assessment
This issue has not been assessed yet.