From 8f64c02dd8dc40f7fd7a8212bc5a69881dc7d27a Mon Sep 17 00:00:00 2001 From: melsonic Date: Tue, 8 Apr 2025 20:33:10 +0530 Subject: [PATCH 1/7] fix: made gradients work in sketch mode --- d2themes/sketch_overlay.go | 12 +++++++++--- lib/color/gradient.go | 6 ++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/d2themes/sketch_overlay.go b/d2themes/sketch_overlay.go index f1557c623..65ccde356 100644 --- a/d2themes/sketch_overlay.go +++ b/d2themes/sketch_overlay.go @@ -24,9 +24,15 @@ func (o *ThemableSketchOverlay) Render() (string, error) { if color.IsThemeColor(o.fill) { o.el.ClassName += fmt.Sprintf(" sketch-overlay-%s", o.fill) // e.g. sketch-overlay-B3 } else { - lc, err := color.LuminanceCategory(o.fill) - if err != nil { - return "", err + var lc string + if color.IsUrlGradientId(o.fill) { + lc = "normal" + } else { + var err error + lc, err = color.LuminanceCategory(o.fill) + if err != nil { + return "", err + } } o.el.ClassName += fmt.Sprintf(" sketch-overlay-%s", lc) // e.g. sketch-overlay-dark } diff --git a/lib/color/gradient.go b/lib/color/gradient.go index 29f29acc3..6b308b440 100644 --- a/lib/color/gradient.go +++ b/lib/color/gradient.go @@ -246,3 +246,9 @@ var GradientRegex = regexp.MustCompile(`^(linear|radial)-gradient\((.+)\)$`) func IsGradient(color string) bool { return GradientRegex.MatchString(color) } + +var UrlGradientId = regexp.MustCompile(`^url\('#grad-[a-f0-9]{40}'\)$`) + +func IsUrlGradientId(color string) bool { + return UrlGradientId.MatchString(color) +} From cc6d722e2e87921a0fea91ba2a8cc8256fabf422 Mon Sep 17 00:00:00 2001 From: melsonic Date: Fri, 11 Apr 2025 01:43:47 +0530 Subject: [PATCH 2/7] refactored fn calls & names --- d2themes/sketch_overlay.go | 13 +++---------- lib/color/color.go | 3 +++ lib/color/gradient.go | 6 +++--- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/d2themes/sketch_overlay.go b/d2themes/sketch_overlay.go index 65ccde356..abe9912f1 100644 --- a/d2themes/sketch_overlay.go +++ b/d2themes/sketch_overlay.go @@ -24,18 +24,11 @@ func (o *ThemableSketchOverlay) Render() (string, error) { if color.IsThemeColor(o.fill) { o.el.ClassName += fmt.Sprintf(" sketch-overlay-%s", o.fill) // e.g. sketch-overlay-B3 } else { - var lc string - if color.IsUrlGradientId(o.fill) { - lc = "normal" - } else { - var err error - lc, err = color.LuminanceCategory(o.fill) - if err != nil { - return "", err - } + lc, err := color.LuminanceCategory(o.fill) + if err != nil { + return "", err } o.el.ClassName += fmt.Sprintf(" sketch-overlay-%s", lc) // e.g. sketch-overlay-dark } - return o.el.Render(), nil } diff --git a/lib/color/color.go b/lib/color/color.go index cbd8971f7..fccb2a79c 100644 --- a/lib/color/color.go +++ b/lib/color/color.go @@ -86,6 +86,9 @@ func darkenCSS(colorString string) (string, error) { } func LuminanceCategory(colorString string) (string, error) { + if IsURLGradientID(colorString) { + return "normal", nil + } l, err := Luminance(colorString) if err != nil { return "", err diff --git a/lib/color/gradient.go b/lib/color/gradient.go index 6b308b440..51dbde637 100644 --- a/lib/color/gradient.go +++ b/lib/color/gradient.go @@ -247,8 +247,8 @@ func IsGradient(color string) bool { return GradientRegex.MatchString(color) } -var UrlGradientId = regexp.MustCompile(`^url\('#grad-[a-f0-9]{40}'\)$`) +var URLGradientID = regexp.MustCompile(`^url\('#grad-[a-f0-9]{40}'\)$`) -func IsUrlGradientId(color string) bool { - return UrlGradientId.MatchString(color) +func IsURLGradientID(color string) bool { + return URLGradientID.MatchString(color) } From b8fd3479d6743deeb79549879515800d406e7626 Mon Sep 17 00:00:00 2001 From: melsonic Date: Fri, 11 Apr 2025 01:44:10 +0530 Subject: [PATCH 3/7] added test --- d2compiler/compile_test.go | 14 + ...adient-fill-values-in-sketch-mode.exp.json | 497 ++++++++++++++++++ 2 files changed, 511 insertions(+) create mode 100644 testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.exp.json diff --git a/d2compiler/compile_test.go b/d2compiler/compile_test.go index 5a56d1e89..b2ec3e863 100644 --- a/d2compiler/compile_test.go +++ b/d2compiler/compile_test.go @@ -3894,6 +3894,20 @@ svc_1.t2 -> b: do with B tassert.Equal(t, "d2/testdata/d2compiler/TestCompile/meow.d2", g.Layers[0].Layers[0].AST.Range.Path) }, }, + { + name: "test-gradient-fill-values-in-sketch-mode", + text: ` + vars: { + d2-config: { + sketch: true + } + } + x->y + x.style.fill: "linear-gradient(#000000, #ffffff)" + y.style.fill: "linear-gradient(#ffffff, #000000)" + `, + expErr: "", + }, } for _, tc := range testCases { diff --git a/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.exp.json b/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.exp.json new file mode 100644 index 000000000..b7dae79a0 --- /dev/null +++ b/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.exp.json @@ -0,0 +1,497 @@ +{ + "graph": { + "name": "", + "isFolderOnly": false, + "ast": { + "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,0:0:0-9:3:183", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,1:4:5-5:5:62", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,1:4:5-1:8:9", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,1:4:5-1:8:9", + "value": [ + { + "string": "vars", + "raw_string": "vars" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,1:10:11-5:5:62", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,2:5:18-4:6:56", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,2:5:18-2:14:27", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,2:5:18-2:14:27", + "value": [ + { + "string": "d2-config", + "raw_string": "d2-config" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,2:16:29-4:6:56", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,3:6:37-3:18:49", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,3:6:37-3:12:43", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,3:6:37-3:12:43", + "value": [ + { + "string": "sketch", + "raw_string": "sketch" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "boolean": { + "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,3:14:45-3:18:49", + "value": true + } + } + } + } + ] + } + } + } + } + ] + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,6:4:67-6:8:71", + "edges": [ + { + "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,6:4:67-6:8:71", + "src": { + "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,6:4:67-6:5:68", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,6:4:67-6:5:68", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "src_arrow": "", + "dst": { + "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,6:7:70-6:8:71", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,6:7:70-6:8:71", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "dst_arrow": ">" + } + ], + "primary": {}, + "value": {} + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,7:4:76-7:53:125", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,7:4:76-7:16:88", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,7:4:76-7:5:77", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,7:6:78-7:11:83", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,7:12:84-7:16:88", + "value": [ + { + "string": "fill", + "raw_string": "fill" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "double_quoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,7:18:90-7:53:125", + "value": [ + { + "string": "linear-gradient(#000000, #ffffff)", + "raw_string": "linear-gradient(#000000, #ffffff)" + } + ] + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,8:4:130-8:53:179", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,8:4:130-8:16:142", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,8:4:130-8:5:131", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,8:6:132-8:11:137", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,8:12:138-8:16:142", + "value": [ + { + "string": "fill", + "raw_string": "fill" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "double_quoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,8:18:144-8:53:179", + "value": [ + { + "string": "linear-gradient(#ffffff, #000000)", + "raw_string": "linear-gradient(#ffffff, #000000)" + } + ] + } + } + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "iconStyle": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + "edges": [ + { + "index": 0, + "isCurve": false, + "src_arrow": false, + "dst_arrow": true, + "references": [ + { + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": {}, + "iconStyle": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ], + "objects": [ + { + "id": "x", + "id_val": "x", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,6:4:67-6:5:68", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,6:4:67-6:5:68", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,7:4:76-7:16:88", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,7:4:76-7:5:77", + "value": [ + { + "string": "x", + "raw_string": "x" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,7:6:78-7:11:83", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,7:12:84-7:16:88", + "value": [ + { + "string": "fill", + "raw_string": "fill" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "x" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": { + "fill": { + "value": "linear-gradient(#000000, #ffffff)" + } + }, + "iconStyle": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + }, + { + "id": "y", + "id_val": "y", + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,6:7:70-6:8:71", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,6:7:70-6:8:71", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + }, + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,8:4:130-8:16:142", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,8:4:130-8:5:131", + "value": [ + { + "string": "y", + "raw_string": "y" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,8:6:132-8:11:137", + "value": [ + { + "string": "style", + "raw_string": "style" + } + ] + } + }, + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,8:12:138-8:16:142", + "value": [ + { + "string": "fill", + "raw_string": "fill" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": -1 + } + ], + "attributes": { + "label": { + "value": "y" + }, + "labelDimensions": { + "width": 0, + "height": 0 + }, + "style": { + "fill": { + "value": "linear-gradient(#ffffff, #000000)" + } + }, + "iconStyle": {}, + "near_key": null, + "shape": { + "value": "rectangle" + }, + "direction": { + "value": "" + }, + "constraint": null + }, + "zIndex": 0 + } + ] + }, + "err": null +} From 759a4e89cd84e390f56fad12aed36cf4a9bb9c1a Mon Sep 17 00:00:00 2001 From: melsonic Date: Fri, 11 Apr 2025 09:29:14 +0530 Subject: [PATCH 4/7] remove unwanted changes --- d2themes/sketch_overlay.go | 1 + 1 file changed, 1 insertion(+) diff --git a/d2themes/sketch_overlay.go b/d2themes/sketch_overlay.go index abe9912f1..f1557c623 100644 --- a/d2themes/sketch_overlay.go +++ b/d2themes/sketch_overlay.go @@ -30,5 +30,6 @@ func (o *ThemableSketchOverlay) Render() (string, error) { } o.el.ClassName += fmt.Sprintf(" sketch-overlay-%s", lc) // e.g. sketch-overlay-dark } + return o.el.Render(), nil } From b7a0219680959d08a0bcb57fc82b4e9993a43305 Mon Sep 17 00:00:00 2001 From: melsonic Date: Sat, 12 Apr 2025 23:19:54 +0530 Subject: [PATCH 5/7] moved gradient test location --- d2compiler/compile_test.go | 14 --- d2renderers/d2sketch/sketch_test.go | 8 ++ .../sketch.exp.svg | 118 ++++++++++++++++++ lib/color/color.go | 2 + 4 files changed, 128 insertions(+), 14 deletions(-) create mode 100644 d2renderers/d2sketch/testdata/test-gradient-fill-values-in-sketch-mode/sketch.exp.svg diff --git a/d2compiler/compile_test.go b/d2compiler/compile_test.go index b2ec3e863..5a56d1e89 100644 --- a/d2compiler/compile_test.go +++ b/d2compiler/compile_test.go @@ -3894,20 +3894,6 @@ svc_1.t2 -> b: do with B tassert.Equal(t, "d2/testdata/d2compiler/TestCompile/meow.d2", g.Layers[0].Layers[0].AST.Range.Path) }, }, - { - name: "test-gradient-fill-values-in-sketch-mode", - text: ` - vars: { - d2-config: { - sketch: true - } - } - x->y - x.style.fill: "linear-gradient(#000000, #ffffff)" - y.style.fill: "linear-gradient(#ffffff, #000000)" - `, - expErr: "", - }, } for _, tc := range testCases { diff --git a/d2renderers/d2sketch/sketch_test.go b/d2renderers/d2sketch/sketch_test.go index 04b97e134..579af9633 100644 --- a/d2renderers/d2sketch/sketch_test.go +++ b/d2renderers/d2sketch/sketch_test.go @@ -1357,6 +1357,14 @@ item -> customer: is(Adult) customer -> item: true `, }, + { + name: "test-gradient-fill-values-in-sketch-mode", + script: ` + x->y + x.style.fill: "linear-gradient(#000000,#ffffff)" + y.style.fill: "linear-gradient(#ffffff,#000000)" + `, + }, } runa(t, tcs) } diff --git a/d2renderers/d2sketch/testdata/test-gradient-fill-values-in-sketch-mode/sketch.exp.svg b/d2renderers/d2sketch/testdata/test-gradient-fill-values-in-sketch-mode/sketch.exp.svg new file mode 100644 index 000000000..d6fb8498c --- /dev/null +++ b/d2renderers/d2sketch/testdata/test-gradient-fill-values-in-sketch-mode/sketch.exp.svg @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + + + + +xy + + + + \ No newline at end of file diff --git a/lib/color/color.go b/lib/color/color.go index fccb2a79c..7417a2b9d 100644 --- a/lib/color/color.go +++ b/lib/color/color.go @@ -86,6 +86,8 @@ func darkenCSS(colorString string) (string, error) { } func LuminanceCategory(colorString string) (string, error) { + // check if colorString matches the `url('#grad-')` format + // which is used to refer to a or element. if IsURLGradientID(colorString) { return "normal", nil } From 47d3a54f5a57ba1efde3872cd73b988658c02563 Mon Sep 17 00:00:00 2001 From: melsonic Date: Sat, 12 Apr 2025 23:34:30 +0530 Subject: [PATCH 6/7] deleted d2compiler exp data file --- ...adient-fill-values-in-sketch-mode.exp.json | 497 ------------------ 1 file changed, 497 deletions(-) delete mode 100644 testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.exp.json diff --git a/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.exp.json b/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.exp.json deleted file mode 100644 index b7dae79a0..000000000 --- a/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.exp.json +++ /dev/null @@ -1,497 +0,0 @@ -{ - "graph": { - "name": "", - "isFolderOnly": false, - "ast": { - "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,0:0:0-9:3:183", - "nodes": [ - { - "map_key": { - "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,1:4:5-5:5:62", - "key": { - "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,1:4:5-1:8:9", - "path": [ - { - "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,1:4:5-1:8:9", - "value": [ - { - "string": "vars", - "raw_string": "vars" - } - ] - } - } - ] - }, - "primary": {}, - "value": { - "map": { - "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,1:10:11-5:5:62", - "nodes": [ - { - "map_key": { - "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,2:5:18-4:6:56", - "key": { - "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,2:5:18-2:14:27", - "path": [ - { - "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,2:5:18-2:14:27", - "value": [ - { - "string": "d2-config", - "raw_string": "d2-config" - } - ] - } - } - ] - }, - "primary": {}, - "value": { - "map": { - "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,2:16:29-4:6:56", - "nodes": [ - { - "map_key": { - "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,3:6:37-3:18:49", - "key": { - "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,3:6:37-3:12:43", - "path": [ - { - "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,3:6:37-3:12:43", - "value": [ - { - "string": "sketch", - "raw_string": "sketch" - } - ] - } - } - ] - }, - "primary": {}, - "value": { - "boolean": { - "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,3:14:45-3:18:49", - "value": true - } - } - } - } - ] - } - } - } - } - ] - } - } - } - }, - { - "map_key": { - "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,6:4:67-6:8:71", - "edges": [ - { - "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,6:4:67-6:8:71", - "src": { - "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,6:4:67-6:5:68", - "path": [ - { - "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,6:4:67-6:5:68", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - } - ] - }, - "src_arrow": "", - "dst": { - "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,6:7:70-6:8:71", - "path": [ - { - "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,6:7:70-6:8:71", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "dst_arrow": ">" - } - ], - "primary": {}, - "value": {} - } - }, - { - "map_key": { - "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,7:4:76-7:53:125", - "key": { - "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,7:4:76-7:16:88", - "path": [ - { - "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,7:4:76-7:5:77", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - }, - { - "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,7:6:78-7:11:83", - "value": [ - { - "string": "style", - "raw_string": "style" - } - ] - } - }, - { - "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,7:12:84-7:16:88", - "value": [ - { - "string": "fill", - "raw_string": "fill" - } - ] - } - } - ] - }, - "primary": {}, - "value": { - "double_quoted_string": { - "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,7:18:90-7:53:125", - "value": [ - { - "string": "linear-gradient(#000000, #ffffff)", - "raw_string": "linear-gradient(#000000, #ffffff)" - } - ] - } - } - } - }, - { - "map_key": { - "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,8:4:130-8:53:179", - "key": { - "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,8:4:130-8:16:142", - "path": [ - { - "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,8:4:130-8:5:131", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - }, - { - "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,8:6:132-8:11:137", - "value": [ - { - "string": "style", - "raw_string": "style" - } - ] - } - }, - { - "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,8:12:138-8:16:142", - "value": [ - { - "string": "fill", - "raw_string": "fill" - } - ] - } - } - ] - }, - "primary": {}, - "value": { - "double_quoted_string": { - "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,8:18:144-8:53:179", - "value": [ - { - "string": "linear-gradient(#ffffff, #000000)", - "raw_string": "linear-gradient(#ffffff, #000000)" - } - ] - } - } - } - } - ] - }, - "root": { - "id": "", - "id_val": "", - "attributes": { - "label": { - "value": "" - }, - "labelDimensions": { - "width": 0, - "height": 0 - }, - "style": {}, - "iconStyle": {}, - "near_key": null, - "shape": { - "value": "" - }, - "direction": { - "value": "" - }, - "constraint": null - }, - "zIndex": 0 - }, - "edges": [ - { - "index": 0, - "isCurve": false, - "src_arrow": false, - "dst_arrow": true, - "references": [ - { - "map_key_edge_index": 0 - } - ], - "attributes": { - "label": { - "value": "" - }, - "labelDimensions": { - "width": 0, - "height": 0 - }, - "style": {}, - "iconStyle": {}, - "near_key": null, - "shape": { - "value": "" - }, - "direction": { - "value": "" - }, - "constraint": null - }, - "zIndex": 0 - } - ], - "objects": [ - { - "id": "x", - "id_val": "x", - "references": [ - { - "key": { - "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,6:4:67-6:5:68", - "path": [ - { - "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,6:4:67-6:5:68", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - } - ] - }, - "key_path_index": 0, - "map_key_edge_index": 0 - }, - { - "key": { - "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,7:4:76-7:16:88", - "path": [ - { - "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,7:4:76-7:5:77", - "value": [ - { - "string": "x", - "raw_string": "x" - } - ] - } - }, - { - "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,7:6:78-7:11:83", - "value": [ - { - "string": "style", - "raw_string": "style" - } - ] - } - }, - { - "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,7:12:84-7:16:88", - "value": [ - { - "string": "fill", - "raw_string": "fill" - } - ] - } - } - ] - }, - "key_path_index": 0, - "map_key_edge_index": -1 - } - ], - "attributes": { - "label": { - "value": "x" - }, - "labelDimensions": { - "width": 0, - "height": 0 - }, - "style": { - "fill": { - "value": "linear-gradient(#000000, #ffffff)" - } - }, - "iconStyle": {}, - "near_key": null, - "shape": { - "value": "rectangle" - }, - "direction": { - "value": "" - }, - "constraint": null - }, - "zIndex": 0 - }, - { - "id": "y", - "id_val": "y", - "references": [ - { - "key": { - "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,6:7:70-6:8:71", - "path": [ - { - "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,6:7:70-6:8:71", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - } - ] - }, - "key_path_index": 0, - "map_key_edge_index": 0 - }, - { - "key": { - "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,8:4:130-8:16:142", - "path": [ - { - "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,8:4:130-8:5:131", - "value": [ - { - "string": "y", - "raw_string": "y" - } - ] - } - }, - { - "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,8:6:132-8:11:137", - "value": [ - { - "string": "style", - "raw_string": "style" - } - ] - } - }, - { - "unquoted_string": { - "range": "d2/testdata/d2compiler/TestCompile/test-gradient-fill-values-in-sketch-mode.d2,8:12:138-8:16:142", - "value": [ - { - "string": "fill", - "raw_string": "fill" - } - ] - } - } - ] - }, - "key_path_index": 0, - "map_key_edge_index": -1 - } - ], - "attributes": { - "label": { - "value": "y" - }, - "labelDimensions": { - "width": 0, - "height": 0 - }, - "style": { - "fill": { - "value": "linear-gradient(#ffffff, #000000)" - } - }, - "iconStyle": {}, - "near_key": null, - "shape": { - "value": "rectangle" - }, - "direction": { - "value": "" - }, - "constraint": null - }, - "zIndex": 0 - } - ] - }, - "err": null -} From 5f1d9febe0ada48b7c11aa9ddf0b0f9a5cf731c2 Mon Sep 17 00:00:00 2001 From: melsonic Date: Mon, 14 Apr 2025 23:32:41 +0530 Subject: [PATCH 7/7] update next.md --- ci/release/changelogs/next.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index 9e7cabe91..14069f10c 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -34,6 +34,7 @@ - fixes inconsistencies when objects were double quoted [#2390](https://github.com/terrastruct/d2/pull/2390) - fixes globs not applying to spread substitutions [#2426](https://github.com/terrastruct/d2/issues/2426) - fixes panic when classes were mixed with layers incorrectly [#2448](https://github.com/terrastruct/d2/pull/2448) + - fixes panic when gradient colors are used in sketch mode [#2481](https://github.com/terrastruct/d2/pull/2487) - Formatter: - fixes substitutions in quotes surrounded by text [#2462](https://github.com/terrastruct/d2/pull/2462) - CLI: fetch and render remote images of mimetype octet-stream correctly [#2370](https://github.com/terrastruct/d2/pull/2370)