use header width for sql_tables if larger than row width

This commit is contained in:
Gavin Nishizawa 2022-12-28 23:15:16 -08:00
parent 51c03985e7
commit 8b81428693
No known key found for this signature in database
GPG key ID: AE3B177777CE55CD
3 changed files with 8 additions and 5 deletions

View file

@ -805,7 +805,9 @@ func (obj *Object) GetDefaultSize(mtexts []*d2target.MText, ruler *textmeasure.R
// The rows get padded a little due to header font being larger than row font
dims.Height = labelDims.Height * (len(obj.SQLTable.Columns) + 1)
dims.Width = d2target.NamePadding + maxNameWidth + d2target.TypePadding + maxTypeWidth + d2target.TypePadding + constraintWidth
headerWidth := d2target.HeaderPadding + labelDims.Width + d2target.HeaderPadding
rowsWidth := d2target.NamePadding + maxNameWidth + d2target.TypePadding + maxTypeWidth + d2target.TypePadding + constraintWidth
dims.Width = go2.Max(headerWidth, rowsWidth)
}
return &dims, nil

View file

@ -19,8 +19,8 @@ func tableHeader(shape d2target.Shape, box *geo.Box, text string, textWidth, tex
if text != "" {
tl := label.InsideMiddleLeft.GetPointOnBox(
box,
20,
textWidth,
float64(d2target.HeaderPadding),
float64(shape.Width),
textHeight,
)

View file

@ -3,8 +3,9 @@ package d2target
import "oss.terrastruct.com/d2/d2renderers/d2fonts"
const (
NamePadding = 10
TypePadding = 20
NamePadding = 10
TypePadding = 20
HeaderPadding = 20
)
type SQLTable struct {