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

Export SVG with CSS responsive Light and Dark themes #3147

Closed
2 tasks done
AdamCoulterOz opened this issue Nov 2, 2022 · 14 comments
Closed
2 tasks done

Export SVG with CSS responsive Light and Dark themes #3147

AdamCoulterOz opened this issue Nov 2, 2022 · 14 comments

Comments

@AdamCoulterOz
Copy link

  • I agree to follow the Code of Conduct that this project adheres to.
  • I have searched the issue tracker for a feature request that matches the one I want to file, without success.

Is your feature request related to a problem? Please describe.
I use drawio for a lot of technical documentation in source control. I export to the SVG format and reference the images in markdown files. With the advent of light/dark modes, my diagrams often become unreadable in dark mode. There is no way to have an exported diagram change between light and dark.

Describe the solution you'd like
You've clearly put a lot of work into the light/dark editing in drawio. When I switch between light and dark in the drawio app, the colours used for my diagram invert and I can clearly see the diagram. Could these "alternate themes" be embedded in the SVG file exports with @media (prefers-color-scheme: dark) { ... } CSS styles so your colour invertions can come along for the ride when exported, i.e. the SVG changes to dark based on the browser it's being viewed in? It would be very cool.

Describe alternatives you've considered
The workaround is to export my diagrams with a solid white background.

Additional context
Example screenshots without changing anything about the diagram itself other than switching between light and dark mode.
light
dark

@alderg
Copy link
Contributor

alderg commented Nov 2, 2022

You can manually add a style in the defs section as described here. We're planning to add an option for this in the SVG export dialog in one of the upcoming releases.

@AdamCoulterOz
Copy link
Author

@alderg that is awesome, I just manually inserted that style section in the defs block, and it worked perfectly. Is having this baked into the export function far away?

@alderg
Copy link
Contributor

alderg commented Jan 20, 2023

We'll update this ticket when it's added. Can't give an ETA.

@alderg
Copy link
Contributor

alderg commented Sep 20, 2023

It has been added to the export dialog:
Screenshot 2023-09-20 at 09 19 07

@AdamCoulterOz
Copy link
Author

@davidjgraph - I've installed the latest version for the last few weeks, I haven't seen it released yet? What commit was it added in?

@davidjgraph
Copy link
Collaborator

The change in the dialog is there in the core build at version 22.0.5:

Capture d’écran 2023-10-20 à 09 55 22

@davidjgraph
Copy link
Collaborator

The commit was ec5dcc2. The 21.8.0 release.

@AdamCoulterOz
Copy link
Author

@davidjgraph - that doesn't have the Automatic option shown in @alderg's previous post which is the specific feature "responsive" we are talking about. :-)

@AdamCoulterOz
Copy link
Author

@davidjgraph, what you've referenced is different than what this issue was talking about. The screenshot from @alderg is the actual thing I was looking for.

@AdamCoulterOz
Copy link
Author

AdamCoulterOz commented Jan 27, 2024

@alderg / @davidjgraph - can I please get an answer regarding this one? because its still not implemented. It was supposed to be in v22 and now v23 is here, but this feature still isn't.

@davidjgraph
Copy link
Collaborator

23.0.2 shows:

Capture d’écran 2024-01-27 à 18 01 53

What browser are you using?

@AdamCoulterOz
Copy link
Author

@davidjgraph desktop on macOS

@alderg
Copy link
Contributor

alderg commented Feb 16, 2024

Check Improve Contrast under Extras, Appearance for the option to appear in the Export SVG dialog in draw.io desktop:

Screenshot 2024-02-16 at 09 40 03

@AdamCoulterOz
Copy link
Author

thanks @alderg, that wasn't immediately obvious, I've been checking regularly for it for ages. I've noticed that this setting isn't remembered when you re-open an exported "theme-automatic.drawio.svg", so when you save it (and it automatically syncs the exported SVG), it loses the automatic part. Can it be persisted to exported file's mxfile attributes and read back when reading back in an exported model, so subsequent saves keep it?

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

3 participants