Skip to content

Commit 406b219

Browse files
authored
Updated buttons to be more accessible. (#373)
* Darkened hover colors * Darkened disabled text color * Removed elevated button styles * Refactored many button styles to overrideable variables * Added link description text
1 parent d11de56 commit 406b219

File tree

3 files changed

+32
-84
lines changed

3 files changed

+32
-84
lines changed

pattern-library/sass/global/_settings.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ $text-de-emphasized-font-weight: font-weight(normal) !default;
320320

321321

322322
// links
323-
$link-color: palette(primary, base) !default;
323+
$link-color: palette(primary, dark) !default;
324324
$link-focus-color: palette(primary, light) !default;
325325
$link-visited-color: palette(primary, dark) !default;
326326

pattern-library/sass/patterns/_buttons.scss

+30-70
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
// #NEUTRAL
1212
// #BRAND
1313
// #LINK
14-
// #ELEVATED
1514
// #INVERSE
1615
// #COMBO
1716
// #APPLICATION
@@ -26,6 +25,11 @@ $btn-border-size: 1px !default;
2625
$btn-shadow: 3px !default;
2726
$btn-font-weight: font-weight(semi-bold) !default;
2827
$btn-border-radius: $component-border-radius !default;
28+
$btn-focus-color: palette(primary, dark) !default;
29+
$btn-focus-text-color: palette(primary, x-back) !default;
30+
$btn-disabled-text-color: palette(grayscale, accent) !default;
31+
$btn-disabled-background-color: palette(grayscale, x-back) !default;
32+
$btn-disabled-border-color: palette(grayscale, back) !default;
2933

3034
// sizes
3135
$btn-large-padding-vertical: spacing-vertical(small);
@@ -120,9 +124,9 @@ $btn-small-font-size: font-size(small);
120124
&.is-hovered,
121125
&:focus,
122126
&.is-focused {
123-
border-color: palette(primary, accent);
124-
background: palette(primary, accent);
125-
color: palette(primary, x-back);
127+
border-color: $btn-focus-color;
128+
background: $btn-focus-color;
129+
color: $btn-focus-text-color;
126130
}
127131

128132
// STATE: is pressed or active
@@ -137,8 +141,8 @@ $btn-small-font-size: font-size(small);
137141
// STATE: is disabled
138142
&:disabled,
139143
&.is-disabled {
140-
border-color: palette(grayscale, back);
141-
color: palette(grayscale, back);
144+
border-color: $btn-disabled-border-color;
145+
color: $btn-disabled-text-color;
142146
}
143147
}
144148

@@ -157,9 +161,9 @@ $btn-small-font-size: font-size(small);
157161
&.is-hovered,
158162
&:focus,
159163
&.is-focused {
160-
border-color: palette(primary, accent);
161-
background: palette(primary, accent);
162-
color: palette(primary, x-back);
164+
border-color: $btn-focus-color;
165+
background: $btn-focus-color;
166+
color: $btn-focus-text-color;
163167
}
164168

165169
// STATE: is pressed or active
@@ -173,9 +177,9 @@ $btn-small-font-size: font-size(small);
173177
// STATE: is disabled
174178
&:disabled,
175179
&.is-disabled {
176-
border-color: palette(grayscale, back);
177-
background: palette(grayscale, x-back);
178-
color: palette(grayscale, back);
180+
border-color: $btn-disabled-border-color;
181+
background: $btn-disabled-background-color;
182+
color: $btn-disabled-text-color;
179183
}
180184
}
181185

@@ -195,9 +199,9 @@ $btn-small-font-size: font-size(small);
195199
&.is-hovered,
196200
&:focus,
197201
&.is-focused {
198-
border-color: palette(primary, accent);
199-
background: palette(primary, accent);
200-
color: palette(primary, x-back);
202+
border-color: $btn-focus-color;
203+
background: $btn-focus-color;
204+
color: $btn-focus-text-color;
201205
}
202206

203207
// STATE: is pressed or active
@@ -212,9 +216,9 @@ $btn-small-font-size: font-size(small);
212216
// STATE: is disabled
213217
&:disabled,
214218
&.is-disabled {
215-
border-color: palette(grayscale, back);
216-
background: palette(grayscale, x-back);
217-
color: palette(grayscale, back);
219+
border-color: $btn-disabled-border-color;
220+
background: $btn-disabled-background-color;
221+
color: $btn-disabled-text-color;
218222
}
219223
}
220224

@@ -232,50 +236,16 @@ $btn-small-font-size: font-size(small);
232236
padding: 1px;
233237
background: $transparent;
234238

235-
&:disabled {
236-
// disabled links shouldn't be in the interface
237-
// plus, having them pass AA guidelines would make them no longer look disabled
238-
display: none;
239-
}
240-
}
241-
242-
243-
// ----------------------------
244-
// #ELEVATED
245-
// ----------------------------
246-
%btn-elevated {
247-
@extend %btn;
248-
border-color: palette(primary, base);
249-
box-shadow: inset 0 -3px 0 0 palette(primary, dark);
250-
background: palette(primary, base);
251-
color: palette(primary, x-back);
252-
253-
// STATE: hover and focus
254239
&:hover,
255-
&.is-hovered,
256-
&:focus,
257-
&.is-focused {
258-
box-shadow: inset 0 -3px 0 0 palette(primary, base);
259-
background: palette(primary, accent);
260-
color: palette(primary, x-back);
261-
}
262-
263-
// STATE: is pressed or active
264240
&:active,
265-
&.is-pressed,
266-
&.is-active {
267-
box-shadow: inset 0 3px 0 0 palette(primary, dark);
268-
background: palette(primary, base);
269-
color: palette(primary, back);
241+
&:focus {
242+
text-decoration: underline;
270243
}
271244

272-
// STATE: is disabled
273-
&:disabled,
274-
&.is-disabled {
275-
box-shadow: none;
276-
border-color: palette(grayscale, back);
277-
background: palette(grayscale, x-back);
278-
color: palette(grayscale, back);
245+
&:disabled {
246+
// disabled links shouldn't be in the interface
247+
// plus, having them pass AA guidelines would make them no longer look disabled
248+
display: none;
279249
}
280250
}
281251

@@ -340,13 +310,8 @@ $btn-small-font-size: font-size(small);
340310
// STATE: is disabled
341311
&:disabled,
342312
&.is-disabled {
343-
border-color: palette(grayscale, back);
344-
color: palette(grayscale, back);
345-
346-
&:hover {
347-
border-color: palette(grayscale, back);
348-
color: palette(grayscale, back);
349-
}
313+
border-color: palette(grayscale, accent);
314+
color: $btn-disabled-text-color;
350315
}
351316
}
352317

@@ -374,11 +339,6 @@ $btn-small-font-size: font-size(small);
374339
@extend %btn-link;
375340
}
376341

377-
// elevated
378-
.btn-elevated {
379-
@extend %btn-elevated;
380-
}
381-
382342
// inverse
383343
.btn-inverse {
384344
@extend %btn-inverse;

pldoc/_components/buttons.md

+1-13
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,6 @@ info: Buttons should be used for performing actions within the edX envi
4343
<button type="button" class="btn-brand" disabled>Primary Disabled</button>
4444
</div>
4545

46-
<h3 class="example-set-hd">Elevated</h3>
47-
<div class="example-set">
48-
<button type="button" class="btn-elevated">Elevated</button>
49-
<button type="button" class="btn-elevated btn-large">Elevated Large</button>
50-
<button type="button" class="btn-elevated btn-small">Elevated Small</button>
51-
<button type="button" class="btn-elevated" disabled>Elevated Disabled</button>
52-
</div>
53-
5446
<h3 class="example-set-hd">Buttons with icons</h3>
5547
<div class="example-set">
5648
<button type="button" class="btn">
@@ -65,10 +57,6 @@ info: Buttons should be used for performing actions within the edX envi
6557
<span class="icon fa fa-comment" aria-hidden="true"></span>
6658
Brand
6759
</button>
68-
<button type="button" class="btn-elevated">
69-
<span class="icon fa fa-comment" aria-hidden="true"></span>
70-
Elevated
71-
</button>
7260
</div>
7361

7462
<h3 class="example-set-hd">Combo</h3>
@@ -102,10 +90,10 @@ info: Buttons should be used for performing actions within the edX envi
10290
<a href="http://ux.edx.org/" class="btn">View the UX Pattern Library</a>
10391
<a href="http://ux.edx.org/" class="btn-neutral">View the UX Pattern Library</a>
10492
<a href="http://ux.edx.org/" class="btn-brand">View the UX Pattern Library</a>
105-
<a href="http://ux.edx.org/" class="btn-elevated">View the UX Pattern Library</a>
10693
</div>
10794

10895
<h3 class="example-set-hd">Links without visual styling</h3>
96+
<p>Note: unread links use the primary color, while read/visited links use primary dark.</p>
10997
<div class="example-set">
11098
<button type="button" class="btn-link">Link</button>
11199
<button type="button" class="btn-link btn-large">Link Large</button>

0 commit comments

Comments
 (0)