From ea58e1139bbea6e30fccd4aeb98799ab5785c3a8 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Mon, 6 Feb 2023 13:12:43 -0800 Subject: [PATCH] update back font size --- ci/release/changelogs/next.md | 1 + d2exporter/export.go | 4 +- d2graph/d2graph.go | 5 ++ .../d2sketch/testdata/class/sketch.exp.svg | 26 +++---- .../d2sketch/testdata/opacity/sketch.exp.svg | 14 ++-- .../testdata/sql_tables/sketch.exp.svg | 70 +++++++++--------- .../measured/empty-class/dagre/board.exp.json | 2 +- .../measured/empty-class/dagre/sketch.exp.svg | 2 +- .../empty-sql_table/dagre/board.exp.json | 2 +- .../empty-sql_table/dagre/sketch.exp.svg | 2 +- .../empty_class_height/dagre/board.exp.json | 22 +++--- .../empty_class_height/dagre/sketch.exp.svg | 14 ++-- .../empty_class_height/elk/board.exp.json | 22 +++--- .../empty_class_height/elk/sketch.exp.svg | 14 ++-- .../dagre/board.exp.json | 72 +++++++++---------- .../dagre/sketch.exp.svg | 10 +-- .../elk/board.exp.json | 54 +++++++------- .../elk/sketch.exp.svg | 10 +-- .../sql_table_overflow/dagre/board.exp.json | 16 ++--- .../sql_table_overflow/dagre/sketch.exp.svg | 22 +++--- .../sql_table_overflow/elk/board.exp.json | 16 ++--- .../sql_table_overflow/elk/sketch.exp.svg | 22 +++--- .../dagre/board.exp.json | 28 ++++---- .../dagre/sketch.exp.svg | 52 +++++++------- .../elk/board.exp.json | 16 ++--- .../elk/sketch.exp.svg | 52 +++++++------- .../stable/class/dagre/board.exp.json | 6 +- .../stable/class/dagre/sketch.exp.svg | 26 +++---- .../testdata/stable/class/elk/board.exp.json | 6 +- .../testdata/stable/class/elk/sketch.exp.svg | 26 +++---- .../dagre/board.exp.json | 16 ++--- .../dagre/sketch.exp.svg | 20 +++--- .../elk/board.exp.json | 16 ++--- .../elk/sketch.exp.svg | 20 +++--- .../dagre/board.exp.json | 30 ++++---- .../dagre/sketch.exp.svg | 16 ++--- .../elk/board.exp.json | 22 +++--- .../elk/sketch.exp.svg | 16 ++--- .../stable/sql_tables/dagre/board.exp.json | 62 ++++++++-------- .../stable/sql_tables/dagre/sketch.exp.svg | 70 +++++++++--------- .../stable/sql_tables/elk/board.exp.json | 58 +++++++-------- .../stable/sql_tables/elk/sketch.exp.svg | 70 +++++++++--------- .../unnamed_only_height/dagre/board.exp.json | 8 +-- .../unnamed_only_height/dagre/sketch.exp.svg | 48 ++++++------- .../unnamed_only_height/elk/board.exp.json | 8 +-- .../unnamed_only_height/elk/sketch.exp.svg | 48 ++++++------- .../unnamed_only_width/dagre/board.exp.json | 56 +++++++-------- .../unnamed_only_width/dagre/sketch.exp.svg | 52 +++++++------- .../unnamed_only_width/elk/board.exp.json | 28 ++++---- .../unnamed_only_width/elk/sketch.exp.svg | 52 +++++++------- .../dagre/board.exp.json | 12 ++-- .../dagre/sketch.exp.svg | 48 ++++++------- .../shape_set_width_height/elk/board.exp.json | 12 ++-- .../shape_set_width_height/elk/sketch.exp.svg | 48 ++++++------- 54 files changed, 738 insertions(+), 732 deletions(-) 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