Skip to content

Commit b526f11

Browse files
committed
Reduce contrast of text and inline code elements.
To much contrast in dark mode can cause halation and makes text hard to read. The Accessible Perceptual Contrast Algorithm (APCA)[1] has preliminary guidelines ([2]) for maximum contrast in dark mode. The changes introduced in this PR ensure that the contrast for text content does not exceed Lc 90 and does not exceed Lc 75 for large text. The background color for inline code elements was also darkened so that there is less contrast with the surrounding text. 1. https://github.com/Myndex 2. Myndex/SAPC-APCA#106
1 parent ee4a371 commit b526f11

File tree

5 files changed

+27
-16
lines changed

5 files changed

+27
-16
lines changed
Lines changed: 1 addition & 1 deletion
Loading
Lines changed: 1 addition & 1 deletion
Loading
Lines changed: 1 addition & 1 deletion
Loading

guides/assets/stylesrc/_dark.scss

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
body.guide {
1010

1111
background-color: $gray-1000;
12-
color: #fff;
12+
color: $text-on-darker-bg;
1313

1414
&::-webkit-scrollbar {
1515
width: 12px;
@@ -27,8 +27,9 @@
2727
border-radius: 10px;
2828
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.5);
2929
}
30-
h1 {
31-
color: #fff;
30+
31+
h1, h2, h3 {
32+
color: $large-text-on-darker-bg;
3233
}
3334

3435
a {
@@ -44,17 +45,18 @@
4445
} // &:visited
4546
} // a
4647

47-
h2 a {
48+
h2 a, h3 a {
4849
&:link,
4950
&:visited {
50-
color: #fff;
51+
color: inherit;
5152
}
5253
} // h2 a
5354

5455
table {
5556
th {
5657
background-color: $gray-900;
5758
border-bottom: 2px solid $gray-700;
59+
color: $text-on-darker-bg;
5860
} // th
5961

6062
tr {
@@ -64,11 +66,11 @@
6466
}
6567
} // table
6668

67-
h3, h4, h5, h6 {
69+
h4, h5, h6 {
6870
a,
6971
a:link,
7072
a:visited {
71-
color: #fff;
73+
color: inherit;
7274
} // a, a:link, a:visited
7375
} // h3
7476

@@ -86,8 +88,8 @@
8688
} // pre, code
8789

8890
p code, ul code, li code {
89-
background-color: $gray-650;
90-
color: #fff;
91+
background-color: $gray-850;
92+
color: $text-on-darker-bg;
9193
}
9294

9395
td code {
@@ -137,7 +139,7 @@
137139
a,
138140
a:link,
139141
a:visited {
140-
color: $gray-100;
142+
color: $text-on-darker-bg;
141143
} // a
142144

143145
a#home_nav {
@@ -151,14 +153,14 @@
151153

152154
#guides {
153155
background: $gray-800;
154-
color: $gray-100;
156+
color: $text-on-dark-bg;
155157

156158
.guides-section {
157159
dd {
158160
a,
159161
a:link,
160162
a:visited {
161-
color: $gray-100;
163+
color: $text-on-dark-bg;
162164
} // a
163165

164166
a:hover,
@@ -204,7 +206,7 @@
204206
a,
205207
a:link,
206208
a:visited {
207-
color: $gray-100;
209+
color: inherit;
208210
}
209211

210212
a:hover,

guides/assets/stylesrc/style.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ $gray-600: #666666;
5151
$gray-650: #505050;
5252
$gray-700: #3A3939;
5353
$gray-800: #343434;
54+
$gray-850: #2E2E2E;
5455
$gray-900: #292929;
5556
$gray-1000: #181818;
5657

@@ -70,6 +71,14 @@ $stop-dark: rgba($stop, 0.5);
7071
$stop-bkgnd: rgba($stop, 15%);
7172
$stop-bkgnd-dark: rgba($stop, 5%);
7273

74+
// APCA has different rules if the background is darker than #333333.
75+
// The variables with darker in them are intended for those cases.
76+
// Large text is text that is > 24px
77+
// See https://github.com/Myndex/SAPC-APCA/discussions/106
78+
$text-on-dark-bg: #EDEDED; // APCA Lc 90 on gray-800
79+
$text-on-darker-bg: #E5E5E5; // APCA Lc -89.9 on gray-1000, Lc -87.4 on gray-900
80+
$large-text-on-darker-bg: #CCCCCC; // APCA Lc -74.6 on gray-1000, Lc -72.0 on gray-900
81+
7382
// ----------------------------------------------------------------------------
7483
// Fonts
7584
// These are the same fonts that are used on the marcom site, and they are

0 commit comments

Comments
 (0)