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

Feature: dark-mode svg :) #14

Closed
tfiers opened this issue Dec 11, 2022 · 8 comments
Closed

Feature: dark-mode svg :) #14

tfiers opened this issue Dec 11, 2022 · 8 comments
Labels
feature An enhancement to src/ visible to end-users
Milestone

Comments

@tfiers
Copy link
Owner

tfiers commented Dec 11, 2022

should work, e.g: https://www.ctrl.blog/entry/svg-embed-dark-mode.html (css media query, plus, mayb, ..)

We'd post-process dot's output

@tfiers
Copy link
Owner Author

tfiers commented Dec 11, 2022

maybe just setting bg to transparent instead of white would already be enough, actually

@tfiers tfiers added the feature An enhancement to src/ visible to end-users label Dec 12, 2022
@tfiers
Copy link
Owner Author

tfiers commented Dec 25, 2022

yeah, 'wontfix', in favor of

@tfiers tfiers closed this as completed Dec 25, 2022
@tfiers
Copy link
Owner Author

tfiers commented Dec 27, 2022

Actually, reopening.
Via e0ba81a:
DarkReader does a nice thing with vanilla (daylight) svg: lines becomes white
But only on dreampuf! not on gh neither on pages.

So, yes, a post-process of svg to make the edges (arrows) (and node borders then too) white.
(a dark mode rule)

From above link

The following example simply creates a white canvas in default/light mode, or a black canvas in dark mode.

<svg xmlns="http://www.w3.org/2000/svg">
  <defs>
    <style>
      svg {
        background-color: white;
        color-scheme:light dark;
      }
      @media (prefers-color-scheme:dark) {
        svg {
          background-color: black;
        }
      }
    </style>
  </defs>
</svg>

We'd do that, but for..
..Give every ellipse..

Excerpts from https://github.com/tfiers/PkgGraph.jl/blob/5edfa49/docs/img/Unitful-deps.svg?short_path=f1a5c6f :

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
 "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 5.0.1 (20220820.1526)
 -->
<!-- Pages: 1 -->
<svg width="791pt" height="476pt"
 viewBox="0.00 0.00 790.69 476.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 472)">
<!-- Unitful -->
<g id="node1" class="node">
<title>Unitful</title>
<ellipse fill="white" stroke="black" cx="500.55" cy="-450" rx="37.09" ry="18"/>
<text text-anchor="middle" x="500.55" y="-446.3" font-family="sans-serif" font-size="14.00">Unitful</text>
</g>
<!-- Unitful&#45;&gt;ConstructionBase -->
<g id="edge1" class="edge">
<title>Unitful&#45;&gt;ConstructionBase</title>
<path fill="none" stroke="black" d="M475.52,-436.49C454.53,-425.99 424.19,-410.82 399.95,-398.7"/>
<polygon fill="black" stroke="black" points="401.23,-395.9 391.98,-394.72 398.48,-401.41 401.23,-395.9"/>
</g>

@tfiers tfiers reopened this Dec 27, 2022
@tfiers
Copy link
Owner Author

tfiers commented Dec 27, 2022

So:

g.node ellipse → stroke: white
g.edge path & polygon → stroke: white

Or we could go full dark mode, do what DarkReader does with the vanilla.
And add:

g.node text → color: white
g.node ellipse → fill: black

To make this work, mayb: remove this individual styling from every node; and replace by stylesheet on top (also for light mode).
alternatively (maybe more robustly?) do the dark mode with !importants

@tfiers
Copy link
Owner Author

tfiers commented Dec 27, 2022

(readme would then be: "This will open the browser to [this url], which renders something like the following image")

@tfiers tfiers added this to the v0.3 milestone Dec 29, 2022
@tfiers
Copy link
Owner Author

tfiers commented Jan 5, 2023

Test:

upload of

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
   <style>
        ellipse {
            fill: black;
        }
        @media (prefers-color-scheme: dark) {
            ellipse { fill: white; }
        }
    </style>
    <ellipse cx="20.84" cy="20" rx="20.69" ry="18"/>
</svg>

(adapted from https://stackoverflow.com/a/67190894/2611913)

@tfiers
Copy link
Owner Author

tfiers commented Jan 5, 2023

ok that test works: on github it switches. but not locally. so ok, is all good.

tfiers added a commit that referenced this issue Jan 5, 2023
on the way to #14

(now to integrate in code: postprocess of dot-generated file (or user downloaded file from webapp?))
@tfiers
Copy link
Owner Author

tfiers commented Jan 5, 2023

yossss. it works online

@tfiers tfiers closed this as completed in 4e16d93 Jan 5, 2023
@tfiers tfiers modified the milestones: v0.4, v0.3 Jan 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature An enhancement to src/ visible to end-users
Projects
None yet
Development

No branches or pull requests

1 participant