Skip to content

Commit 5f5b814

Browse files
authored
support for prefers-color-scheme (#1008)
* support for `prefers-color-scheme` * 2x brightness for captions and links in dark color scheme * table dark color scheme * prefers-color-scheme for links, footer, and table-of-contents * paginator css for `prefers-color-scheme`
1 parent 49bc947 commit 5f5b814

File tree

2 files changed

+133
-19
lines changed

2 files changed

+133
-19
lines changed

datafiles/static/hackage.css

Lines changed: 132 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,19 @@ html {
99
height: 100%;
1010
}
1111

12+
@media (prefers-color-scheme: dark) {
13+
body {
14+
background: #333;
15+
color: #fefefe;
16+
}
17+
}
18+
@media (prefers-color-scheme: light) {
19+
body {
20+
background: #fefefe;
21+
color: #333;
22+
}
23+
}
1224
body {
13-
background: #fefefe;
14-
color: #333;
1525
text-align: left;
1626
min-height: 100vh;
1727
position: relative;
@@ -59,8 +69,16 @@ dd {
5969
}
6070

6171
a { text-decoration: none; }
62-
a[href]:link { color: #9E358F; }
63-
a[href]:visited {color: #6F5F9C; }
72+
73+
@media (prefers-color-scheme: dark) {
74+
a[href]:link { color: #EB82DC; } /* 30% brighter */
75+
a[href]:visited { color: #D5C5FF; } /* 40% brighter */
76+
}
77+
@media (prefers-color-scheme: light) {
78+
a[href]:link { color: #9E358F; }
79+
a[href]:visited {color: #6F5F9C; }
80+
}
81+
6482
a[href]:hover { text-decoration:underline; }
6583

6684
/* @end */
@@ -142,9 +160,19 @@ pre, code, kbd, samp, .src {
142160

143161
/* @group Common */
144162

163+
@media (prefers-color-scheme: dark) {
164+
.caption, h1, h2, h3, h4, h5, h6 {
165+
color: #5E5184;
166+
filter: brightness(2.0);
167+
}
168+
}
169+
@media (prefers-color-scheme: light) {
170+
.caption, h1, h2, h3, h4, h5, h6 {
171+
color: #5E5184;
172+
}
173+
}
145174
.caption, h1, h2, h3, h4, h5, h6 {
146175
font-weight: bold;
147-
color: #5E5184;
148176
margin: 1.33em 0 0.7em 0;
149177
line-height: 1.05em;
150178
}
@@ -194,10 +222,19 @@ ul.links li a, ul.links li form {
194222
cursor: pointer;
195223
}
196224

225+
@media (prefers-color-scheme: dark) {
226+
pre {
227+
background-color: #474747; /* 20% brighter than background */
228+
}
229+
}
230+
@media (prefers-color-scheme: light) {
231+
pre {
232+
background-color: #f7f7f7;
233+
}
234+
}
197235
pre {
198236
padding: 0.5rem 1rem;
199237
margin: 1em 0;
200-
background-color: #f7f7f7;
201238
overflow: auto;
202239
}
203240

@@ -402,7 +439,6 @@ table.properties td, table.properties th {
402439
}
403440

404441
div #properties {
405-
background: #fefefe;
406442
width: 40%;
407443
margin-bottom: 2em;
408444
}
@@ -583,11 +619,21 @@ div#style-menu-holder {
583619
display: block;
584620
}
585621

622+
@media (prefers-color-scheme: dark) {
623+
#footer {
624+
background: #222;
625+
color: #ededed;
626+
}
627+
}
628+
@media (prefers-color-scheme: light) {
629+
#footer {
630+
background: #ededed;
631+
color: #222;
632+
}
633+
}
586634
#footer {
587-
background: #ededed;
588635
border-top: 1px solid #aaa;
589636
padding: 0.5em 0;
590-
color: #222;
591637
text-align: center;
592638
width: 100%;
593639
height: 3em;
@@ -625,8 +671,17 @@ ul.links li form button {
625671

626672
/* @group Front Matter */
627673

674+
@media (prefers-color-scheme: dark) {
675+
#table-of-contents {
676+
background: #222;
677+
}
678+
}
679+
@media (prefers-color-scheme: light) {
680+
#table-of-contents {
681+
background: #f7f7f7;
682+
}
683+
}
628684
#table-of-contents {
629-
background: #f7f7f7;
630685
padding: 1em;
631686
margin: 0;
632687
margin-top: 1em;
@@ -986,6 +1041,17 @@ table.fancy th {
9861041
background: #f0f0f0;
9871042
}
9881043

1044+
@media (prefers-color-scheme: dark) {
1045+
table.fancy td, table.properties td,
1046+
table.fancy th, table.properties th {
1047+
background: #333;
1048+
}
1049+
table.dataTable.compact.fancy tbody th,
1050+
table.dataTable.compact.fancy tbody td {
1051+
background: #333;
1052+
}
1053+
}
1054+
9891055
table.fancy td, table.properties td,
9901056
table.fancy th, table.properties th {
9911057
padding: 0.15em 0.45em;
@@ -997,8 +1063,8 @@ table.fancy tr.even td {
9971063

9981064
table.dataTable.compact.fancy tbody th,
9991065
table.dataTable.compact.fancy tbody td {
1000-
padding: 6px 10px;
1001-
line-height: normal;
1066+
padding: 6px 10px;
1067+
line-height: normal;
10021068
}
10031069

10041070
ul.searchresults li {
@@ -1063,8 +1129,20 @@ a.deprecated[href]:visited {
10631129
}
10641130

10651131
/* Styles Next/Prev when they have no href */
1132+
1133+
@media (prefers-color-scheme: dark) {
1134+
.paginator a {
1135+
color: #474747;
1136+
}
1137+
}
1138+
1139+
@media (prefers-color-scheme: light) {
1140+
.paginator a {
1141+
color: #666 !important;
1142+
}
1143+
}
1144+
10661145
.paginator a {
1067-
color: #666;
10681146
cursor: default;
10691147
background: none;
10701148
border: none;
@@ -1077,22 +1155,58 @@ a.deprecated[href]:visited {
10771155
padding: 0.5em 1em;
10781156
}
10791157

1158+
1159+
@media (prefers-color-scheme: dark) {
1160+
.paginator a:link:hover, .paginator a:visited:hover {
1161+
color: #474747;
1162+
}
1163+
}
1164+
1165+
@media (prefers-color-scheme: light) {
1166+
.paginator a:link:hover, .paginator a:visited:hover {
1167+
color: #333 !important;
1168+
}
1169+
}
1170+
10801171
.paginator a:link, .paginator a:visited {
1081-
color: #333;
10821172
border: 1px solid transparent;
10831173
border-radius: 2px;
10841174
}
10851175

1176+
@media (prefers-color-scheme: dark) {
1177+
.paginator a:link:hover, .paginator a:visited:hover {
1178+
color: #585858;
1179+
background: linear-gradient(to bottom, #fff 0%, #dcdcdc 100%);
1180+
}
1181+
}
1182+
1183+
@media (prefers-color-scheme: light) {
1184+
.paginator a:link:hover, .paginator a:visited:hover {
1185+
color: white !important;
1186+
background: linear-gradient(to bottom, #585858 0%, #111 100%);
1187+
}
1188+
}
1189+
10861190
.paginator a:link:hover, .paginator a:visited:hover {
1087-
color: white;
10881191
border: 1px solid #111;
1089-
background: linear-gradient(to bottom, #585858 0%, #111 100%);
10901192
text-decoration: none;
10911193
}
10921194

1195+
@media (prefers-color-scheme: dark) {
1196+
.paginator .current, .paginator .current:hover {
1197+
color: #474747;
1198+
background: linear-gradient(to bottom, #585858 0%, #111 100%);
1199+
}
1200+
}
1201+
1202+
@media (prefers-color-scheme: light) {
1203+
.paginator .current, .paginator .current:hover {
1204+
color: #666 !important;
1205+
background: linear-gradient(to bottom, #fff 0%, #dcdcdc 100%);
1206+
}
1207+
}
1208+
10931209
.paginator .current,
10941210
.paginator .current:hover {
1095-
color: #333;
10961211
border: 1px solid #979797;
1097-
background: linear-gradient(to bottom, #fff 0%, #dcdcdc 100%);
10981212
}

datafiles/templates/Html/browse.html.st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@
173173
<dd>Only show packages with more than 1000 downloads within the last 30 days. The download count is inexact because Hackage uses a <a href="https://en.wikipedia.org/wiki/Content_delivery_network" target=_blank>content delivery network</a>.</dd>
174174
<dt>(lastUpload &lt; 2021-10-29)</dt>
175175
<dd>Only show packages for which the last upload was before (i.e. excluding) the given UTC date in <a target=_blank href="https://www.w3.org/TR/NOTE-datetime">the 'complete date' format as specified using ISO 8601</a>.</dd>
176-
<dt>(lastUpload = 2021-10-29)</dt>
176+
<dt>(lastUpload = 2021-10-29)</dt>x
177177
<dd>Only show packages for which the last upload was within the 24 hours of the given UTC date.</dd>
178178
<dt>(maintainer:SimonMarlow)</dt>
179179
<dd>Only show packages for which the maintainers list includes the user name <a target=_blank href="/user/SimonMarlow">SimonMarlow</a>.</dd>

0 commit comments

Comments
 (0)