Add dark mode style for DAG

Closes zcash/developers#2.
This commit is contained in:
Jack Grigg 2021-12-09 02:07:00 +00:00
parent b0ef47e636
commit ac8d5d62b6
3 changed files with 35 additions and 1 deletions

2
.gitignore vendored
View File

@ -1,5 +1,5 @@
__pycache__
public
public/*.svg
github_schema.json
github_schema.py

30
public/zcash-dag.css Normal file
View File

@ -0,0 +1,30 @@
@media (prefers-color-scheme: dark) {
svg .graph > polygon {
fill: #0d1117;
}
svg .node polygon {
stroke: #c9d1d9;
}
svg .node.open polygon {
fill: #057715;
}
svg .node.committed polygon {
fill: #1862b9;
}
svg .node.closed polygon {
fill: #b93b1e;
}
svg .node polyline {
stroke: #c9d1d9;
}
svg .edge path {
stroke: #c9d1d9;
}
svg .edge polygon {
fill: #c9d1d9;
stroke: #c9d1d9;
}
svg text {
fill: #c9d1d9;
}
}

View File

@ -234,10 +234,13 @@ def main():
if n.title:
attrs['label'] = '\n'.join(['%s' % n] + wrap(n.title, 25))
if n.state == 'closed':
attrs['class'] = 'closed'
attrs['fillcolor'] = '#fad8c7'
elif n.is_committed:
attrs['class'] = 'committed'
attrs['fillcolor'] = '#a6cfff'
else:
attrs['class'] = 'open'
attrs['fillcolor'] = '#c2e0c6'
attrs['penwidth'] = 2 if n in do_next else 1
attrs['shape'] = 'component' if n.is_pr else 'box'
@ -259,6 +262,7 @@ def main():
# Draw the result!
ag.graph_attr['rankdir'] = 'LR'
ag.graph_attr['stylesheet'] = 'zcash-dag.css'
ag.layout(prog='dot')
os.makedirs('public', exist_ok=True)
ag.draw('public/zcash-%s-dag.svg' % DAG_VIEW)