feat(shared): Better theme support in Dot
This commit is contained in:
parent
108d83b834
commit
29fe78843f
4 changed files with 17 additions and 9 deletions
|
@ -36,6 +36,12 @@ const noBlack = orig => {
|
|||
if (orig.getAttribute('stroke') === '#000000') {
|
||||
orig.setAttribute('stroke', 'currentColor')
|
||||
}
|
||||
if (orig.getAttribute('fill') === '#000000') {
|
||||
orig.setAttribute('fill', 'currentColor')
|
||||
}
|
||||
if (orig.getAttribute('color') === '#000000') {
|
||||
orig.setAttribute('color', 'currentColor')
|
||||
}
|
||||
|
||||
return orig
|
||||
}
|
||||
|
@ -76,8 +82,8 @@ const coarse = (svg, options) => {
|
|||
|
||||
const rc = rough.svg(svg, options || {})
|
||||
|
||||
// Replace shapes
|
||||
const children = svg.querySelectorAll('circle, rect, ellipse, line, polygon, polyline, path')
|
||||
|
||||
for(let i = 0; i < children.length; i += 1) {
|
||||
const original = noBlack(children[i]);
|
||||
const params = [];
|
||||
|
@ -125,6 +131,11 @@ const coarse = (svg, options) => {
|
|||
|
||||
original.replaceWith(replacement);
|
||||
}
|
||||
|
||||
// Replace text color
|
||||
const text = svg.querySelectorAll('text')
|
||||
for(let i = 0; i < text.length; i += 1) noBlack(text[i])
|
||||
|
||||
}
|
||||
|
||||
export default coarse
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue