Merge pull request #1967 from alixander/fix-style-inherit
Fix edge style inherit
This commit is contained in:
commit
f639f6f87f
7 changed files with 32239 additions and 3 deletions
|
|
@ -10,3 +10,5 @@
|
||||||
- Local relative icons are relative to the d2 file instead of CLI invoke path [#1924](https://github.com/terrastruct/d2/pull/1924)
|
- Local relative icons are relative to the d2 file instead of CLI invoke path [#1924](https://github.com/terrastruct/d2/pull/1924)
|
||||||
- Custom label positions weren't being read when the width was smaller than the label [#1928](https://github.com/terrastruct/d2/pull/1928)
|
- Custom label positions weren't being read when the width was smaller than the label [#1928](https://github.com/terrastruct/d2/pull/1928)
|
||||||
- Using `shape: circle` for arrowheads no longer removes all arrowheads along path in sketch mode [#1942](https://github.com/terrastruct/d2/pull/1942)
|
- Using `shape: circle` for arrowheads no longer removes all arrowheads along path in sketch mode [#1942](https://github.com/terrastruct/d2/pull/1942)
|
||||||
|
- Globs to null connections work [#1965](https://github.com/terrastruct/d2/pull/1965)
|
||||||
|
- Edge globs setting styles inherit correctly in child boards [#1967](https://github.com/terrastruct/d2/pull/1967)
|
||||||
|
|
|
||||||
|
|
@ -862,9 +862,6 @@ func (mk *Key) HasTripleGlob() bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if mk.EdgeIndex != nil && mk.EdgeIndex.Glob {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
if mk.EdgeKey.HasTripleGlob() {
|
if mk.EdgeKey.HasTripleGlob() {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -392,6 +392,9 @@ func (g *globContext) prefixed(dst *Map) *globContext {
|
||||||
if len(prefix.Path) > 0 {
|
if len(prefix.Path) > 0 {
|
||||||
g2.refctx.Key.Key = prefix
|
g2.refctx.Key.Key = prefix
|
||||||
}
|
}
|
||||||
|
if !g2.refctx.Key.HasTripleGlob() && g2.refctx.Key.EdgeKey != nil {
|
||||||
|
prefix.Path = append(prefix.Path, g2.refctx.Key.EdgeKey.Path...)
|
||||||
|
}
|
||||||
return g2
|
return g2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -322,6 +322,67 @@ x -> y
|
||||||
assertQuery(t, m, 4, 0, nil, "")
|
assertQuery(t, m, 4, 0, nil, "")
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "field-glob-style-inherit",
|
||||||
|
run: func(t testing.TB) {
|
||||||
|
m, err := compile(t, `*.style.opacity: 0
|
||||||
|
x: {
|
||||||
|
style.opacity: 1
|
||||||
|
}
|
||||||
|
|
||||||
|
scenarios: {
|
||||||
|
1: {
|
||||||
|
x
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
assert.Success(t, err)
|
||||||
|
assertQuery(t, m, 0, 0, 1, "x.style.opacity")
|
||||||
|
assertQuery(t, m, 0, 0, 1, "scenarios.1.x.style.opacity")
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "edge-glob-style-inherit/1",
|
||||||
|
run: func(t testing.TB) {
|
||||||
|
m, err := compile(t, `(* -> *)[*].style.opacity: 0
|
||||||
|
x -> y: {
|
||||||
|
style.opacity: 1
|
||||||
|
}
|
||||||
|
|
||||||
|
scenarios: {
|
||||||
|
1: {
|
||||||
|
x
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
assert.Success(t, err)
|
||||||
|
assertQuery(t, m, 0, 0, 1, "(x -> y)[0].style.opacity")
|
||||||
|
assertQuery(t, m, 0, 0, 1, "scenarios.1.(x -> y)[0].style.opacity")
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "edge-glob-style-inherit/2",
|
||||||
|
run: func(t testing.TB) {
|
||||||
|
m, err := compile(t, `*.style.opacity: 0
|
||||||
|
(* -> *)[*].style.opacity: 0
|
||||||
|
x -> y
|
||||||
|
|
||||||
|
steps: {
|
||||||
|
1: {
|
||||||
|
x.style.opacity: 1
|
||||||
|
}
|
||||||
|
2: {
|
||||||
|
(x -> y)[0].style.opacity: 1
|
||||||
|
}
|
||||||
|
3: {
|
||||||
|
y.style.opacity: 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
assert.Success(t, err)
|
||||||
|
assertQuery(t, m, 0, 0, 1, "steps.3.(x -> y)[0].style.opacity")
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "double-glob/edge/1",
|
name: "double-glob/edge/1",
|
||||||
run: func(t testing.TB) {
|
run: func(t testing.TB) {
|
||||||
|
|
|
||||||
4166
testdata/d2ir/TestCompile/patterns/edge-glob-style-inherit/1.exp.json
generated
vendored
Normal file
4166
testdata/d2ir/TestCompile/patterns/edge-glob-style-inherit/1.exp.json
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
25179
testdata/d2ir/TestCompile/patterns/edge-glob-style-inherit/2.exp.json
generated
vendored
Normal file
25179
testdata/d2ir/TestCompile/patterns/edge-glob-style-inherit/2.exp.json
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
2828
testdata/d2ir/TestCompile/patterns/field-glob-style-inherit.exp.json
generated
vendored
Normal file
2828
testdata/d2ir/TestCompile/patterns/field-glob-style-inherit.exp.json
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue