diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index 538deb296..532aa4df1 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -28,6 +28,7 @@ - Ensures shapes with icons have enough padding for their labels. [#702](https://github.com/terrastruct/d2/pull/702) - `--force-appendix` flag adds an appendix to SVG outputs with tooltips or links. [#761](https://github.com/terrastruct/d2/pull/761) - `d2 themes` subcommand to list themes. [#760](https://github.com/terrastruct/d2/pull/760) +- `sql_table` header left-aligned with column [#769](https://github.com/terrastruct/d2/pull/769) #### Bugfixes ⛑️ diff --git a/d2exporter/export.go b/d2exporter/export.go index 5a57f0881..418e71370 100644 --- a/d2exporter/export.go +++ b/d2exporter/export.go @@ -136,10 +136,10 @@ func toShape(obj *d2graph.Object, theme *d2themes.Theme) d2target.Shape { case d2target.ShapeClass: shape.Class = *obj.Class // The label is the header for classes and tables, which is set in client to be 4 px larger than the object's set font size - shape.FontSize -= 4 + shape.FontSize -= d2target.HeaderFontAdd case d2target.ShapeSQLTable: shape.SQLTable = *obj.SQLTable - shape.FontSize -= 4 + shape.FontSize -= d2target.HeaderFontAdd } shape.Label = text.Text shape.LabelWidth = text.Dimensions.Width diff --git a/d2graph/d2graph.go b/d2graph/d2graph.go index 3d8cf71ce..811270371 100644 --- a/d2graph/d2graph.go +++ b/d2graph/d2graph.go @@ -465,6 +465,11 @@ func (obj *Object) Text() *d2target.MText { isItalic = true } fontSize := d2fonts.FONT_SIZE_M + + if obj.Class != nil || obj.SQLTable != nil { + fontSize = d2fonts.FONT_SIZE_XL + } + if obj.OuterSequenceDiagram() == nil { if obj.IsContainer() { fontSize = obj.Level().LabelSize() diff --git a/d2renderers/d2sketch/testdata/class/sketch.exp.svg b/d2renderers/d2sketch/testdata/class/sketch.exp.svg index 8c30a5e75..d49d10d78 100644 --- a/d2renderers/d2sketch/testdata/class/sketch.exp.svg +++ b/d2renderers/d2sketch/testdata/class/sketch.exp.svg @@ -51,19 +51,19 @@ width="626" height="572" viewBox="-102 -102 626 572"> \ No newline at end of file diff --git a/e2etests/testdata/measured/empty-sql_table/dagre/board.exp.json b/e2etests/testdata/measured/empty-sql_table/dagre/board.exp.json index f6fec0464..4bd68c182 100644 --- a/e2etests/testdata/measured/empty-sql_table/dagre/board.exp.json +++ b/e2etests/testdata/measured/empty-sql_table/dagre/board.exp.json @@ -30,7 +30,7 @@ "methods": null, "columns": null, "label": "", - "fontSize": 16, + "fontSize": 24, "fontFamily": "DEFAULT", "language": "", "color": "#0A0F25", diff --git a/e2etests/testdata/measured/empty-sql_table/dagre/sketch.exp.svg b/e2etests/testdata/measured/empty-sql_table/dagre/sketch.exp.svg index 4d951fc2d..b37f64c2c 100644 --- a/e2etests/testdata/measured/empty-sql_table/dagre/sketch.exp.svg +++ b/e2etests/testdata/measured/empty-sql_table/dagre/sketch.exp.svg @@ -39,7 +39,7 @@ width="254" height="216" viewBox="-102 -102 254 216"> \ No newline at end of file diff --git a/e2etests/testdata/regression/empty_class_height/dagre/board.exp.json b/e2etests/testdata/regression/empty_class_height/dagre/board.exp.json index 2f0ed2f93..afdf1799a 100644 --- a/e2etests/testdata/regression/empty_class_height/dagre/board.exp.json +++ b/e2etests/testdata/regression/empty_class_height/dagre/board.exp.json @@ -9,7 +9,7 @@ "x": 0, "y": 0 }, - "width": 283, + "width": 354, "height": 184, "opacity": 1, "strokeDash": 0, @@ -41,15 +41,15 @@ "methods": null, "columns": null, "label": "class with rows", - "fontSize": 16, + "fontSize": 24, "fontFamily": "DEFAULT", "language": "", "color": "#0A0F25", "italic": false, "bold": false, "underline": false, - "labelWidth": 178, - "labelHeight": 26, + "labelWidth": 249, + "labelHeight": 36, "zIndex": 0, "level": 1, "primaryAccentColor": "#0D32B2", @@ -60,11 +60,11 @@ "id": "class2", "type": "class", "pos": { - "x": 343, - "y": 51 + "x": 414, + "y": 41 }, - "width": 319, - "height": 82, + "width": 404, + "height": 102, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -84,15 +84,15 @@ "methods": null, "columns": null, "label": "class without rows", - "fontSize": 16, + "fontSize": 24, "fontFamily": "DEFAULT", "language": "", "color": "#0A0F25", "italic": false, "bold": false, "underline": false, - "labelWidth": 214, - "labelHeight": 26, + "labelWidth": 299, + "labelHeight": 36, "zIndex": 0, "level": 1, "primaryAccentColor": "#0D32B2", diff --git a/e2etests/testdata/regression/empty_class_height/dagre/sketch.exp.svg b/e2etests/testdata/regression/empty_class_height/dagre/sketch.exp.svg index e62d41570..d1a01b426 100644 --- a/e2etests/testdata/regression/empty_class_height/dagre/sketch.exp.svg +++ b/e2etests/testdata/regression/empty_class_height/dagre/sketch.exp.svg @@ -3,7 +3,7 @@ id="d2-svg" style="background: white;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" -width="866" height="388" viewBox="-102 -102 866 388">containerscloudtall cylinderclass- -num -int- -timeout -int- -pid -+ -getStatus() -Enum+ -getJobs() -Job[]+ -setTimeout(seconds int) -voidusersid -int -name -string -email -string -password -string -last_login -datetime -container

markdown text expanded to 800x400

+containerscloudtall cylinderclass- +num +int- +timeout +int- +pid ++ +getStatus() +Enum+ +getJobs() +Job[]+ +setTimeout(seconds int) +voidusersid +int +name +string +email +string +password +string +last_login +datetime +container

markdown text expanded to 800x400

:= 5 := a + 7 fmt.Printf("%d", b):= 5 := a + 7 -fmt.Printf("%d", b)circle containerdiamond containeroval containerhexagon containerdiamondcirclehexagonoval +fmt.Printf("%d", b)circle containerdiamond containeroval containerhexagon containerdiamondcirclehexagonoval containerscloudtall cylinderclass- -num -int- -timeout -int- -pid -+ -getStatus() -Enum+ -getJobs() -Job[]+ -setTimeout(seconds int) -voidusersid -int -name -string -email -string -password -string -last_login -datetime -container

markdown text expanded to 800x400

+containerscloudtall cylinderclass- +num +int- +timeout +int- +pid ++ +getStatus() +Enum+ +getJobs() +Job[]+ +setTimeout(seconds int) +voidusersid +int +name +string +email +string +password +string +last_login +datetime +container

markdown text expanded to 800x400

:= 5 := a + 7 fmt.Printf("%d", b):= 5 := a + 7 -fmt.Printf("%d", b)circle containerdiamond containeroval containerhexagon containerdiamondcirclehexagonoval +fmt.Printf("%d", b)circle containerdiamond containeroval containerhexagon containerdiamondcirclehexagonoval