8000 How to include themed icons from an SVG sprite sheet in JointJS+ nodes · clientIO joint · Discussion #2981 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

How to include themed icons from an SVG sprite sheet in JointJS+ nodes #2981

Answered by MartinKanera
Jennygra asked this question in Q&A
Discussion options

You must be logged in to vote

You can make icons from an SVG sprite respond to light/dark themes by combining with native CSS theming. Here’s how I handled it in JointJS:

const MenuIcon = dia.Element.extend({
    defaults: util.defaultsDeep({
        type: 'standard.MenuIcon',
        size: { width: 50, height: 50 },
    }, dia.Element.prototype.defaults),
    markup: util.svg`
        <use @selector="menu" />
    `
});

const iconElement = new MenuIcon({
    attrs: {
        menu: {
            href: `${baseUrl}#square`, // ID in your sprite
            style: {
                color: 'light-dark(yellow, blue)' // native CSS theming
            }
        }
    }
});

This only works if the referenced in your SVG sprit…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Jennygra
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
0