Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to add an embeded style element with css definitions #15

Open
hansroland opened this issue Jan 9, 2023 · 0 comments
Open

Allow to add an embeded style element with css definitions #15

hansroland opened this issue Jan 9, 2023 · 0 comments

Comments

@hansroland
Copy link

Today all browsers support light and dark modes. Therefore it should be possible to generate SVG files, that display nicely in both modes.

An example motivated by these SO answers is :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
    "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
    <svg xmlns="http://www.w3.org/2000/svg" width="200" xmlns:xlink="http://www.w3.org/1999/xlink" height="200" version="1.11.1">
    <style>
        line { stroke: black; stroke-width: "1";}
        rect { fill: white; }
        @media (prefers-color-scheme: dark) {
            line { stroke: white; stroke-width: "1";}
            rect { fill: black; }
        }
    </style>
    <rect width="100%" height="100%" fill="currentColor"/>
    <line y1="199" x1="1" y2="199" x2="199"/>
    <line y1="199" x1="1" y2="1" x2="1"/>
    <line y1="199" x1="199" y2="1" x2="199"/>
    <line y1="1" x1="1" y2="1" x2="199"/>
    <line y1="139" x1="15" y2="177" x2="115"/>
    <line y1="147" x1="147" y2="177" x2="115"/>
                       ... more lines ...
    </svg>

I failed to construct such a SVG file with svg-builder. I can create a style element with the style_ function, however, I'm unable to create the css contents.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant