You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Rightmost characters cut off when cell content is right-aligned with margins.
To Reproduce
Steps to reproduce the behavior:
If you set margins on a cell style and set the text to be right-aligned, you will see the rightmost character truncated.
funcTestStyleFunc(t*testing.T) {
TestStyle:=func(row, colint) lipgloss.Style {
switch {
// this is the headercaserow==HeaderRow:
returnlipgloss.NewStyle().Align(lipgloss.Center)
// this is the first row of datacaserow==0:
returnlipgloss.NewStyle().Margin(0, 1).Align(lipgloss.Right)
default:
returnlipgloss.NewStyle().Margin(0, 1)
}
}
table:=New().
Border(lipgloss.NormalBorder()).
StyleFunc(TestStyle).
Headers("LANGUAGE", "FORMAL", "INFORMAL").
Row("Chinese", "Nǐn hǎo", "Nǐ hǎo").
Row("French", "Bonjour", "Salut").
Row("Japanese", "こんにちは", "やあ").
Row("Russian", "Zdravstvuyte", "Privet").
Row("Spanish", "Hola", "¿Qué tal?")
t.Log(table.String())
}
Expected
The text was updated successfully, but these errors were encountered:
After thinking about this a bit, the way margin is working does make sense. It shouldn't be considered part of the width of the element (same as in CSS). Table cells should only use padding to define extra spacing within a cell.
I see two options here:
a) before rendering cells, unset margins + add a note in the godoc for tables to "use Margin not Padding for cell styles". (Margins don't work by default)
b) get margin values and convert that to padding before rendering the cells. (Margins are applied to padding)
Note: in both cases this change will need to be both for headers & cells
When I was learning CSS I found it so confusing that margins weren't factored into widths. I would personally err on including both the margins and padding in the calculation. Case-in-point, you were initially confused about this as well.
Beyond that, though, one should be able use to margins and padding together for, say, an effect like the following:
Anyway, this is a great candidate for the various queries that bundle margin, padding, and border like GetFrameSize.
Describe the bug
Rightmost characters cut off when cell content is right-aligned with margins.
To Reproduce
Steps to reproduce the behavior:
If you set margins on a cell style and set the text to be right-aligned, you will see the rightmost character truncated.
Expected
The text was updated successfully, but these errors were encountered: