From a2ce0c293ed051857783ed6f709098b962f03449 Mon Sep 17 00:00:00 2001 From: melsonic Date: Tue, 18 Mar 2025 23:34:43 +0530 Subject: [PATCH] a bit refactoring on icom style field init --- d2compiler/compile.go | 16 +++++++++------- .../TestCLI_E2E/internal_linked_pdf.exp.pdf | Bin 65656 -> 65656 bytes .../testdata/TestCLI_E2E/no-nav-pdf.exp.pdf | Bin 90706 -> 90706 bytes .../TestCLI_E2E/renamed-board.exp.pdf | Bin 104441 -> 104441 bytes .../testdata/TestCLI_E2E/theme-pdf.exp.pdf | Bin 17334 -> 17334 bytes .../vars/basic/quoted-var.exp.json | 6 +----- .../into_container_with_flat_style.exp.json | 6 +----- 7 files changed, 11 insertions(+), 17 deletions(-) diff --git a/d2compiler/compile.go b/d2compiler/compile.go index 1c2267a53..902384c1c 100644 --- a/d2compiler/compile.go +++ b/d2compiler/compile.go @@ -790,7 +790,7 @@ func (c *compiler) compileIconStyleField(attrs *d2graph.Attributes, f *d2ir.Fiel if f.Primary() == nil { return } - compileStyleFieldInit(attrs, f) + compileIconStyleFieldInit(attrs, f) scalar := f.Primary().Value err := attrs.IconStyle.Apply(f.Name.ScalarString(), scalar.ScalarString()) @@ -815,12 +815,7 @@ func compileStyleFieldInit(attrs *d2graph.Attributes, f *d2ir.Field) { case "stroke-dash": attrs.Style.StrokeDash = &d2graph.Scalar{MapKey: f.LastPrimaryKey()} case "border-radius": - if attrs.Style.BorderRadius == nil { - attrs.Style.BorderRadius = &d2graph.Scalar{MapKey: f.LastPrimaryKey()} - } - if attrs.IconStyle.BorderRadius == nil { - attrs.IconStyle.BorderRadius = &d2graph.Scalar{MapKey: f.LastPrimaryKey()} - } + attrs.Style.BorderRadius = &d2graph.Scalar{MapKey: f.LastPrimaryKey()} case "shadow": attrs.Style.Shadow = &d2graph.Scalar{MapKey: f.LastPrimaryKey()} case "3d": @@ -858,6 +853,13 @@ func compileStyleFieldInit(attrs *d2graph.Attributes, f *d2ir.Field) { } } +func compileIconStyleFieldInit(attrs *d2graph.Attributes, f *d2ir.Field) { + switch f.Name.ScalarString() { + case "border-radius": + attrs.IconStyle.BorderRadius = &d2graph.Scalar{MapKey: f.LastPrimaryKey()} + } +} + func (c *compiler) compileEdge(obj *d2graph.Object, e *d2ir.Edge) { edge, err := obj.Connect(e.ID.SrcPath, e.ID.DstPath, e.ID.SrcArrow, e.ID.DstArrow, "") if err != nil { diff --git a/e2etests-cli/testdata/TestCLI_E2E/internal_linked_pdf.exp.pdf b/e2etests-cli/testdata/TestCLI_E2E/internal_linked_pdf.exp.pdf index 3330e4b36556111fa2d81d78b31b657e9439578e..85be6ffc1b61b0ef956f779c11141c4337bcf2a5 100644 GIT binary patch delta 28 hcmey-!1AMkWkc;>7Gq;0gUOA5CBTf$bN}9E0syo)3=RMQ delta 28 hcmey-!1AMkWkc;>76VIT^T~~WCBTf$bN}9E0syrq3?u*m diff --git a/e2etests-cli/testdata/TestCLI_E2E/no-nav-pdf.exp.pdf b/e2etests-cli/testdata/TestCLI_E2E/no-nav-pdf.exp.pdf index a68b498250b9bec94123d14c40127826cf966eac..c636403be4a0ac72cbd4044df695a2cbb4456fc4 100644 GIT binary patch delta 175 zcmca~g!R%9)(x^!(?8fSDo_6Xrk>GgbM;$S|H+f)8EglNy;hjK;*G&%S*azHtKRZ$ zJ}-5+dHMkxMv#cg=4bN``A)wb%XpvBc>3-*Mngu!>2Kp0vlNVt4J|ae^nLSFToOxC z6*OF|j0}uS4S=FX#vr-v1-h7pp@D_@^qYx{ Fl>kDaHE;j` diff --git a/e2etests-cli/testdata/TestCLI_E2E/renamed-board.exp.pdf b/e2etests-cli/testdata/TestCLI_E2E/renamed-board.exp.pdf index 33d13525d0c7ba4f1e8d041b25fd5ef672d96f6e..aace2ad9c9ed0fa050a1b40b2afe45dd0107fa7a 100644 GIT binary patch delta 47 zcmeylp6%y)wuUW?M`k~2;M$=WNFy3G>Ha0Y$&N!7(0?gVjJC*Sc69Dg< B5widQ delta 47 zcmeylp6%y)wuUW?Mur#)u&N!7(0?gVjJC*Sc69Dip B5x@Wd diff --git a/e2etests-cli/testdata/TestCLI_E2E/theme-pdf.exp.pdf b/e2etests-cli/testdata/TestCLI_E2E/theme-pdf.exp.pdf index ccaf9c3be7fc194b183a88fca2ca534dfdaa1831..7ecdb663f67b9a297a0f52ab44f23dab0137224a 100644 GIT binary patch delta 28 gcmdni&bY0eaRav_i?Okx