From 812957bf232e7f97ec13d02ba9064dba9b38f668 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Mon, 6 Feb 2023 01:15:18 -0800 Subject: [PATCH] Tests, changleog --- ci/release/changelogs/next.md | 2 + d2exporter/export.go | 3 + .../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 | 4 +- .../empty_class_height/dagre/sketch.exp.svg | 10 +-- .../empty_class_height/elk/board.exp.json | 4 +- .../empty_class_height/elk/sketch.exp.svg | 10 +-- .../dagre/board.exp.json | 6 +- .../dagre/sketch.exp.svg | 6 +- .../elk/board.exp.json | 6 +- .../elk/sketch.exp.svg | 6 +- .../sql_table_overflow/dagre/board.exp.json | 4 +- .../sql_table_overflow/dagre/sketch.exp.svg | 18 ++--- .../sql_table_overflow/elk/board.exp.json | 4 +- .../sql_table_overflow/elk/sketch.exp.svg | 18 ++--- .../dagre/board.exp.json | 4 +- .../dagre/sketch.exp.svg | 48 +++++++------- .../elk/board.exp.json | 4 +- .../elk/sketch.exp.svg | 48 +++++++------- .../stable/class/dagre/board.exp.json | 2 +- .../stable/class/dagre/sketch.exp.svg | 26 ++++---- .../testdata/stable/class/elk/board.exp.json | 2 +- .../testdata/stable/class/elk/sketch.exp.svg | 26 ++++---- .../dagre/board.exp.json | 4 +- .../dagre/sketch.exp.svg | 20 +++--- .../elk/board.exp.json | 4 +- .../elk/sketch.exp.svg | 20 +++--- .../dagre/board.exp.json | 8 +-- .../dagre/sketch.exp.svg | 66 +++++++++---------- .../elk/board.exp.json | 8 +-- .../elk/sketch.exp.svg | 66 +++++++++---------- .../dagre/board.exp.json | 4 +- .../dagre/sketch.exp.svg | 12 ++-- .../elk/board.exp.json | 4 +- .../elk/sketch.exp.svg | 12 ++-- .../stable/sql_tables/dagre/board.exp.json | 8 +-- .../stable/sql_tables/dagre/sketch.exp.svg | 66 +++++++++---------- .../stable/sql_tables/elk/board.exp.json | 8 +-- .../stable/sql_tables/elk/sketch.exp.svg | 66 +++++++++---------- .../unnamed_only_height/dagre/board.exp.json | 4 +- .../unnamed_only_height/dagre/sketch.exp.svg | 48 +++++++------- .../unnamed_only_height/elk/board.exp.json | 4 +- .../unnamed_only_height/elk/sketch.exp.svg | 48 +++++++------- .../unnamed_only_width/dagre/board.exp.json | 4 +- .../unnamed_only_width/dagre/sketch.exp.svg | 48 +++++++------- .../unnamed_only_width/elk/board.exp.json | 4 +- .../unnamed_only_width/elk/sketch.exp.svg | 48 +++++++------- .../dagre/board.exp.json | 4 +- .../dagre/sketch.exp.svg | 48 +++++++------- .../shape_set_width_height/elk/board.exp.json | 4 +- .../shape_set_width_height/elk/sketch.exp.svg | 48 +++++++------- 54 files changed, 481 insertions(+), 476 deletions(-) diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index 767ebf9ed..538deb296 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -7,6 +7,8 @@ - `d2 fmt` accepts multiple files to be formatted [#718](https://github.com/terrastruct/d2/issues/718) +- `font-size` works for `sql_table` and `class` shapes [#769](https://github.com/terrastruct/d2/issues/769) + - You can now use the reserved keywords `layers`/`scenarios`/`steps` to define diagrams with multiple levels of abstractions. [#714](https://github.com/terrastruct/d2/pull/714) Docs to come soon diff --git a/d2exporter/export.go b/d2exporter/export.go index 2a34ed64a..5a57f0881 100644 --- a/d2exporter/export.go +++ b/d2exporter/export.go @@ -135,8 +135,11 @@ func toShape(obj *d2graph.Object, theme *d2themes.Theme) d2target.Shape { shape.Label = obj.Attributes.Label.Value 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 case d2target.ShapeSQLTable: shape.SQLTable = *obj.SQLTable + shape.FontSize -= 4 } shape.Label = text.Text shape.LabelWidth = text.Dimensions.Width diff --git a/e2etests/testdata/measured/empty-class/dagre/board.exp.json b/e2etests/testdata/measured/empty-class/dagre/board.exp.json index 43926e6d3..8306771ac 100644 --- a/e2etests/testdata/measured/empty-class/dagre/board.exp.json +++ b/e2etests/testdata/measured/empty-class/dagre/board.exp.json @@ -30,7 +30,7 @@ "methods": null, "columns": null, "label": "", - "fontSize": 20, + "fontSize": 16, "fontFamily": "DEFAULT", "language": "", "color": "#0A0F25", diff --git a/e2etests/testdata/measured/empty-class/dagre/sketch.exp.svg b/e2etests/testdata/measured/empty-class/dagre/sketch.exp.svg index 6927edd4b..a18febc0f 100644 --- a/e2etests/testdata/measured/empty-class/dagre/sketch.exp.svg +++ b/e2etests/testdata/measured/empty-class/dagre/sketch.exp.svg @@ -39,7 +39,7 @@ width="316" height="248" viewBox="-102 -102 316 248"> \ 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 296451a21..f6fec0464 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": 20, + "fontSize": 16, "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 53a789b51..4d951fc2d 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 ae5cad2dc..2f0ed2f93 100644 --- a/e2etests/testdata/regression/empty_class_height/dagre/board.exp.json +++ b/e2etests/testdata/regression/empty_class_height/dagre/board.exp.json @@ -41,7 +41,7 @@ "methods": null, "columns": null, "label": "class with rows", - "fontSize": 20, + "fontSize": 16, "fontFamily": "DEFAULT", "language": "", "color": "#0A0F25", @@ -84,7 +84,7 @@ "methods": null, "columns": null, "label": "class without rows", - "fontSize": 20, + "fontSize": 16, "fontFamily": "DEFAULT", "language": "", "color": "#0A0F25", 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 e69b90472..e62d41570 100644 --- a/e2etests/testdata/regression/empty_class_height/dagre/sketch.exp.svg +++ b/e2etests/testdata/regression/empty_class_height/dagre/sketch.exp.svg @@ -39,11 +39,11 @@ 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