-
Notifications
You must be signed in to change notification settings - Fork 304
feat(table): v2 table bubble #772
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v2-exp
Are you sure you want to change the base?
Conversation
// We can't get the rows and headers from the table, so the user needs to | ||
// provide them as arguments. | ||
m.rows = rows | ||
m.headers = headers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: I wrote a helper function on lipgloss to convert the internal Data
into a [][]string
:
To avoid having to ask for the data again here, I think we should have a GetHeaders()
and GetData()
functions on lipgloss.
There is a small decision to make here. I'm not sure if GetData()
should return a [][]string
directly. For me, it makes more sense to make it return the internal table.Data
interface and expose dataToMatrix
as a public function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, I think it makes more sense to only store the data once instead of managing the same set of values in two places (Model and lipgloss Table).
I vote that we add GetData()
that returns a Data
then the user can call DataToMatrix
. Performance-wise it would be the same as we would probably be doing that type conversion under the hood if we were returning [][]string
. This might lead users to want to include non-string values in the table... Is that something we want to support? I guess that feature could sit in the backlog for a bit while we think about it.
|
||
// OverwriteStylesFromLipgloss sets the [Model]'s style attributes from an | ||
// existing [lipgloss.Table]. | ||
func (m *Model) OverwriteStylesFromLipgloss(t *table.Table) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we could improve the name of this function...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could probably make it StyleFromLipgloss
?
It seems to be working well in my tests 👏 Let me know if you have specific scenarios that you want help testing. |
uses Lip Gloss table to render the table. Also allows users to create bubbles tables from existing Lip Gloss tables.
Depends on charmbracelet/lipgloss#512
Runnable example: charmbracelet/bubbletea#1380
github.com/charmbracelet/bubbles/table
incompatible changes
removed: FromValues -> seems unnecessary
Allow chaining setters
New -> changed from func(...Option) Model to func(...Option) *Model
(*Model).SetCursor: changed from func(int) to func(int) *Model
(*Model).SetHeight: changed from func(int) to func(int) *Model
(*Model).SetRows: changed from func([]Row) to func(...[]string) *Model
(*Model).SetStyles: changed from func(Styles) to func(Styles) *Model
(*Model).SetWidth: changed from func(int) to func(int) *Model
Height and Width calculations now delegated to Lip Gloss
removed: Model.Width
removed: Model.Height
Removed wrapper types
Column
andRow
Row
removed: Row -> using [][]string instead
refactor: WithRows -> changed from func([]Row) Option to func(...[]string) Option
refactor: Model.Rows -> changed from func() []Row to func() [][]string
refactor: Model.SelectedRow -> changed from func() Row to func() []string
Columns
, now headersrefactor: WithColumns() -> WithHeaders()
refactor: Model.Columns -> Model.Headers
refactor: (*Model).SetColumns -> (*Model).SetHeaders
removed: Column
Removed
viewport
removed: (*Model).UpdateViewport
compatible changes
Support Lip Gloss Border customizations
(*Model).Border: added
(*Model).BorderBottom: added
(*Model).BorderColumn: added
(*Model).BorderHeader: added
(*Model).BorderLeft: added
(*Model).BorderRight: added
(*Model).BorderRow: added
(*Model).BorderStyle: added
(*Model).BorderTop: added
(*Model).SetBorder: added
Manage styles
(*Model).OverwriteStyles: added
(*Model).OverwriteStylesFromLipgloss: added
(*Model).SetStyleFunc: added
(*Model).SetYOffset: added
NewFromTemplate: added
WithStyleFunc: added