Skip to content

Commit dc27e98

Browse files
authored
Merge pull request #153 from hugovk/dark-mode
Add dark mode
2 parents c96cf2c + af790ba commit dc27e98

File tree

3 files changed

+75
-15
lines changed

3 files changed

+75
-15
lines changed

index.html

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,39 @@
1414
a.btn:last-child{border-bottom-width: 1px; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px;}
1515
pre {text-align: left;}
1616
footer{text-align: center;}
17+
@media (prefers-color-scheme: dark) {
18+
body {
19+
color: #ccc;
20+
background: black;
21+
}
22+
code, pre {
23+
color: #ccc;
24+
background: #222;
25+
}
26+
a {
27+
color: #5bf;
28+
}
29+
a:hover,
30+
a:hover div {
31+
color: black;
32+
background-color: #5bf;
33+
outline: 0.05em solid #5bf;
34+
}
35+
.btn-default {
36+
color: #ccc;
37+
background: black;
38+
border-color: #222;
39+
}
40+
.btn-default:hover,
41+
.btn-default:focus,
42+
.btn-default:active,
43+
.btn-default.active,
44+
.open.dropdown-toggle.btn-default {
45+
color: #ccc;
46+
background: #222;
47+
border-color: #333;
48+
}
49+
}
1750
</style>
1851
<title>Python Wheels</title>
1952
</head>

svg_wheel.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,11 @@
33
import xml.etree.ElementTree as et
44

55
HEADERS = b"""<?xml version=\"1.0\" standalone=\"no\"?>
6+
<?xml-stylesheet href="wheel.css" type="text/css"?>
67
<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"
78
\"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">
89
"""
910

10-
STYLES = """
11-
.success { stroke: #4CAE4C; stroke-width: 1; fill: #5CB85C; }
12-
.default { stroke: #cccccc; stroke-width: 1; fill: #ffffff; }
13-
"""
14-
1511
PATH_TEMPLATE = """
1612
M {start_outer_x},{start_outer_y}
1713
A{outer_radius},{outer_radius} 0 0 1 {end_outer_x},{end_outer_y}
@@ -59,7 +55,7 @@ def add_annular_sectors(wheel, packages, total):
5955
attrib={"class": result["css_class"]},
6056
)
6157
title = et.SubElement(sector, "title")
62-
title.text = "{0} {1}".format(result["name"], result["icon"])
58+
title.text = f"{result['name']} {result['icon']}"
6359

6460

6561
def angles(index, total):
@@ -78,11 +74,11 @@ def angles(index, total):
7874

7975
def add_fraction(wheel, packages, total):
8076
text_attributes = {
77+
"class": "wheel-text",
8178
"text-anchor": "middle",
8279
"dominant-baseline": "central",
8380
"font-size": str(2 * OFFSET),
8481
"font-family": '"Helvetica Neue",Helvetica,Arial,sans-serif',
85-
"fill": "#333333",
8682
}
8783

8884
# Packages with some sort of wheel
@@ -95,10 +91,10 @@ def add_fraction(wheel, packages, total):
9591
y=str(CENTER - OFFSET),
9692
attrib=text_attributes,
9793
)
98-
packages_with_wheels.text = "{0}".format(wheel_packages)
94+
packages_with_wheels.text = f"{wheel_packages}"
9995

10096
title = et.SubElement(packages_with_wheels, "title")
101-
percentage = "{:.0%}".format(wheel_packages / total)
97+
percentage = f"{wheel_packages / float(total):.0%}"
10298
title.text = percentage
10399

104100
# Dividing line
@@ -109,7 +105,7 @@ def add_fraction(wheel, packages, total):
109105
y1=str(CENTER),
110106
x2=str(CENTER + FRACTION_LINE // 2),
111107
y2=str(CENTER),
112-
attrib={"stroke": "#333333", "stroke-width": "2"},
108+
attrib={"class": "wheel-line", "stroke-width": "2"},
113109
)
114110

115111
# Total packages
@@ -120,7 +116,7 @@ def add_fraction(wheel, packages, total):
120116
y=str(CENTER + OFFSET),
121117
attrib=text_attributes,
122118
)
123-
total_packages.text = "{0}".format(total)
119+
total_packages.text = f"{total}"
124120

125121
title = et.SubElement(total_packages, "title")
126122
title.text = percentage
@@ -129,13 +125,10 @@ def add_fraction(wheel, packages, total):
129125
def generate_svg_wheel(packages, total):
130126
wheel = et.Element(
131127
"svg",
132-
viewBox="0 0 {0} {0}".format(2 * CENTER),
128+
viewBox=f"0 0 {2 * CENTER} {2 * CENTER}",
133129
version="1.1",
134130
xmlns="http://www.w3.org/2000/svg",
135131
)
136-
style = et.SubElement(wheel, "style", attrib={"type": "text/css"})
137-
style.text = STYLES
138-
139132
add_annular_sectors(wheel, packages, total)
140133

141134
add_fraction(wheel, packages, total)

wheel.css

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
.success {
2+
stroke: #4CAE4C;
3+
stroke-width: 1;
4+
fill: #5CB85C;
5+
}
6+
7+
.default {
8+
stroke: #cccccc;
9+
stroke-width: 1;
10+
fill: #ffffff;
11+
}
12+
13+
line.wheel-line {
14+
stroke: #333;
15+
}
16+
17+
text.wheel-text {
18+
fill: #333;
19+
}
20+
21+
@media (prefers-color-scheme: dark) {
22+
.default {
23+
stroke: #222;
24+
stroke-width: 1;
25+
fill: black;
26+
}
27+
line.wheel-line {
28+
stroke: #ccc;
29+
}
30+
text.wheel-text {
31+
fill: #ccc;
32+
}
33+
34+
}

0 commit comments

Comments
 (0)