Skip to content

Commit f7e20e3

Browse files
committed
Latest form/button styling from my framework
1 parent 02c4719 commit f7e20e3

File tree

7 files changed

+102
-78
lines changed

7 files changed

+102
-78
lines changed

src/assets/sass/designpatterns.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ $colors: (
4848
"text-footnote": $color-text-footnote,
4949
"gradient-from": $color-gradient-from,
5050
"gradient-to": $color-gradient-to,
51-
"gradient-border": $color-gradient-border,
5251
"border": $color-border,
52+
"border-light": $color-border-light,
5353
"link": $color-link,
5454
"link-hover": $color-link-hover,
5555
"link-focus": $color-link-focus,

src/assets/sass/modules/_buttons.scss

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@ button {
99
text-transform: none; /* 1 */
1010
}
1111

12+
/**
13+
* Remove the inner border and padding in Firefox.
14+
*/
15+
16+
button::-moz-focus-inner,
17+
[type="button"]::-moz-focus-inner,
18+
[type="reset"]::-moz-focus-inner,
19+
[type="submit"]::-moz-focus-inner {
20+
padding: 0;
21+
border-style: none;
22+
}
23+
1224
/**
1325
* 1. Improve usability and consistency of cursor style between image-type
1426
* `input` and others.
@@ -36,41 +48,30 @@ button,
3648
box-shadow: 0 2px 0 $color-button-shadow;
3749
cursor: pointer; /* 1 */
3850
appearance: none; /* 2 */
51+
user-select: none;
3952

4053
&:hover {
41-
@include gradient-linear(lighten($color-button-gradient-from, 2%), lighten($color-button-gradient-to, 2%));
54+
@include gradient-linear(lighten($color-button-gradient-from, 4%), lighten($color-button-gradient-to, 4%));
4255

43-
border-color: darken($color-button-border, 13%);
56+
border-color: shade($color-button-border, 15%);
4457
color: $color-text-button-hover;
4558
text-decoration: none;
4659
}
4760

4861
&:active {
4962
top: 2px;
50-
border-color: darken($color-button-border, 13%);
63+
border-color: shade($color-button-border, 15%);
5164
color: $color-text-button-active;
5265
text-decoration: none;
5366
box-shadow: none;
5467
}
5568

5669
&:focus {
5770
border-color: $color-link-focus;
58-
outline: 1px solid transparent; // Allows for repainting in high contrast modes.
71+
outline: 2px solid transparent; // Allows for repainting in high contrast modes.
5972
}
6073
}
6174

62-
/**
63-
* Remove the inner border and padding in Firefox.
64-
*/
65-
66-
button::-moz-focus-inner,
67-
[type="button"]::-moz-focus-inner,
68-
[type="reset"]::-moz-focus-inner,
69-
[type="submit"]::-moz-focus-inner {
70-
padding: 0;
71-
border-style: none;
72-
}
73-
7475
/**
7576
* Primary buttons.
7677
*
@@ -89,11 +90,11 @@ button::-moz-focus-inner,
8990
&:hover {
9091
@include gradient-linear(lighten($color-button-primary-gradient-from, 6%), lighten($color-button-primary-gradient-to, 6%));
9192

92-
border-color: darken($color-button-primary-border, 13%);
93+
border-color: shade($color-button-primary-border, 15%);
9394
}
9495

9596
&:active {
96-
border-color: darken($color-button-primary-border, 13%);
97+
border-color: shade($color-button-primary-border, 15%);
9798
box-shadow: none;
9899
}
99100

@@ -165,5 +166,6 @@ button[disabled],
165166
[type="reset"][disabled],
166167
[type="submit"][disabled],
167168
.button.disabled {
168-
top: 2px !important;
169+
top: 0 !important;
170+
background: $color-background-form-disabled !important;
169171
}

src/assets/sass/modules/_forms.scss

Lines changed: 60 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@ legend {
4848
margin-bottom: 0.5em;
4949
}
5050

51+
/**
52+
* Show the overflow in Edge.
53+
*/
54+
55+
button,
56+
input {
57+
overflow: visible;
58+
}
59+
5160
/**
5261
* 1. Prevent elements from spilling out of their parent.
5362
* 2. Address margins set differently in Firefox 4+, Safari, and Chrome.
@@ -99,6 +108,10 @@ textarea {
99108
background: $color-background-form;
100109
appearance: none; /* 1 */
101110

111+
&:hover {
112+
border-color: shade($color-border, 15%);
113+
}
114+
102115
&:focus {
103116
border-color: $color-link-focus;
104117
outline: 1px solid transparent; // Allows for repainting in high contrast modes.
@@ -113,11 +126,11 @@ textarea {
113126
[type="checkbox"]:not(.ui-checkboxradio),
114127
[type="radio"]:not(.ui-checkboxradio) {
115128
position: relative;
116-
bottom: -2px; // 2px / 13px
129+
bottom: -2px;
117130
width: 16px;
118131
height: 16px;
119132
padding: 0; /* 1 */
120-
border: 1px solid darken($color-border, 13%);
133+
border: 1px solid shade($color-border, 15%);
121134
background: $color-background-form;
122135
appearance: none;
123136
box-sizing: border-box;
@@ -126,13 +139,12 @@ textarea {
126139
margin: 0 0.5em 0 0; /* 2 */
127140

128141
&:last-of-type {
129-
/* 2 */
130-
margin: 0;
142+
margin: 0; /* 2 */
131143
}
132144
}
133145

134146
&:hover {
135-
border-color: darken($color-border, 26%);
147+
border-color: shade($color-border, 30%);
136148
cursor: pointer;
137149
}
138150

@@ -164,7 +176,7 @@ textarea {
164176
}
165177

166178
&[disabled]:checked {
167-
background: $color-border-light url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%23fff' d='M13 2.5l-7 7-2-2-2 2 4 4L15 4.5z'/%3E%3C/svg%3E") !important;
179+
background: $color-text-footnote url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%23fff' d='M13 2.5l-7 7-2-2-2 2 4 4L15 4.5z'/%3E%3C/svg%3E") !important;
168180
}
169181
}
170182

@@ -224,7 +236,7 @@ textarea {
224236
}
225237

226238
[type="range"]:hover::-webkit-slider-thumb {
227-
border-color: darken($color-border, 13%);
239+
border-color: shade($color-border, 15%);
228240
}
229241

230242
[type="range"]:active::-webkit-slider-thumb,
@@ -236,14 +248,13 @@ textarea {
236248
width: 100%;
237249
height: 0.75em; // 12px / 16px
238250
border: 1px solid $color-border;
239-
border-radius: 0.375em;
240-
background-color: #e7e7e7;
251+
background-color: $color-gradient-to;
241252
cursor: pointer;
242253
box-sizing: border-box;
243254
}
244255

245256
[type="range"]:hover::-webkit-slider-runnable-track {
246-
border-color: darken($color-border, 13%);
257+
border-color: shade($color-border, 15%);
247258
}
248259

249260
[type="range"]:active::-webkit-slider-runnable-track,
@@ -266,7 +277,7 @@ textarea {
266277
}
267278

268279
[type="range"]:hover::-moz-range-thumb {
269-
border-color: darken($color-border, 13%);
280+
border-color: shade($color-border, 15%);
270281
}
271282

272283
[type="range"]:focus::-moz-range-thumb {
@@ -278,13 +289,13 @@ textarea {
278289
height: 0.75em; // 12px / 16px
279290
border: 1px solid $color-border;
280291
border-radius: 0.375em;
281-
background-color: #e7e7e7;
292+
background-color: $color-gradient-to;
282293
cursor: pointer;
283294
box-sizing: border-box;
284295
}
285296

286297
[type="range"]:hover::-moz-range-track {
287-
border-color: darken($color-border, 13%);
298+
border-color: shade($color-border, 15%);
288299
}
289300

290301
[type="range"]:focus::-moz-range-track {
@@ -295,7 +306,7 @@ textarea {
295306
border-style: none;
296307
}
297308

298-
// Trident/EdgeHTML.
309+
// EdgeHTML.
299310

300311
[type="range"]::-ms-thumb {
301312
width: 1.25em; // 20px / 16px
@@ -311,7 +322,7 @@ textarea {
311322
}
312323

313324
[type="range"]:hover::-ms-thumb {
314-
border-color: darken($color-border, 13%);
325+
border-color: shade($color-border, 15%);
315326
}
316327

317328
[type="range"]:focus::-ms-thumb {
@@ -323,13 +334,13 @@ textarea {
323334
height: 0.75em; // 12px / 16px
324335
border: 1px solid $color-border;
325336
border-radius: 0.375em;
326-
background-color: #e7e7e7;
337+
background-color: $color-gradient-to;
327338
cursor: pointer;
328339
box-sizing: border-box;
329340
}
330341

331342
[type="range"]:hover::-ms-track {
332-
border-color: darken($color-border, 13%);
343+
border-color: shade($color-border, 15%);
333344
}
334345

335346
[type="range"]:focus::-ms-track {
@@ -341,7 +352,8 @@ textarea {
341352
*/
342353

343354
[type="search"]::-webkit-search-decoration {
344-
-webkit-appearance: none;
355+
/* autoprefixer: off */
356+
appearance: none;
345357
}
346358

347359
/**
@@ -350,7 +362,7 @@ textarea {
350362

351363
select {
352364
padding-right: 1.5em; // 24px / 16px
353-
background: $color-background-form url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 17 5'%3E%3Cpolygon fill='%23333' points='0,0 5,5 10,0'/%3E%3C/svg%3E") right center no-repeat;
365+
background: $color-background-form url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='17' height='5' viewBox='0 0 17 5'%3E%3Cpolygon fill='%23333' points='0,0 5,5 10,0'/%3E%3C/svg%3E") right center no-repeat;
354366
background-size: 1.0625em 0.3125em; // 17px / 16px, 5px / 16px
355367
text-transform: none;
356368
}
@@ -361,7 +373,7 @@ select {
361373

362374
select:-moz-focusring {
363375
color: transparent;
364-
text-shadow: 0 0 0 $color-text-form;
376+
text-shadow: none;
365377
}
366378

367379
/**
@@ -411,20 +423,17 @@ textarea {
411423
* Make sure disabled elements really are disabled and styled appropriately.
412424
*
413425
* 1. Re-set default cursor for disabled elements.
414-
* 2. Override default iOS opacity setting.
415426
*/
416427

417428
[disabled],
418429
[disabled] option,
419430
[disabled] optgroup,
420431
span.disabled {
421-
border-color: $color-border-light !important;
422-
background: $color-background-form-disabled !important;
423-
color: $color-text-form-disabled !important;
424-
text-shadow: none !important;
432+
border: 1px solid $color-border !important;
433+
background-color: $color-background-form-disabled !important;
425434
box-shadow: none !important;
426435
cursor: default !important; /* 1 */
427-
opacity: 1; /* 2 */
436+
opacity: 0.33 !important;
428437
}
429438

430439
/**
@@ -456,18 +465,6 @@ input {
456465
}
457466
}
458467

459-
/**
460-
* Styling for required field indicators.
461-
*
462-
* Example HTML:
463-
*
464-
* <span class="required" title="Required" aria-label="Required">●</span>
465-
*/
466-
467-
.required {
468-
color: $color-warning-text;
469-
}
470-
471468
/**
472469
* Styling for form field validation.
473470
*/
@@ -493,3 +490,28 @@ textarea {
493490
box-shadow: none;
494491
}
495492
}
493+
494+
/**
495+
* Normalize form placeholder style across browsers.
496+
*
497+
* 1. Fix placeholder font properties inheritance.
498+
*/
499+
500+
::placeholder {
501+
color: $color-text-form-placeholder;
502+
font: inherit; /* 1 */
503+
opacity: 1;
504+
}
505+
506+
/**
507+
* Styling for required field indicators.
508+
*
509+
* Example HTML:
510+
*
511+
* <abbr class="required" title="Required" aria-label="Required">●</abbr>
512+
*/
513+
514+
abbr.required {
515+
color: $color-warning-text;
516+
text-decoration: none;
517+
}

src/assets/sass/setup/_colours.scss

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@
1313
$color-text: #333333 !default;
1414
$color-text-button: $color-text !default;
1515
$color-text-button-hover: $color-text-button !default;
16-
$color-text-button-active: darken($color-text-button, 10%) !default;
16+
$color-text-button-active: shade($color-text-button, 15%) !default;
1717
$color-text-form: #000000 !default;
18-
$color-text-form-disabled: #aaaaaa !default;
18+
$color-text-form-placeholder: #999999 !default;
1919
$color-text-footnote: #585858 !default;
2020
$color-text-inverse: #ffffff !default;
21+
2122
$color-text-print: #000000 !default; // solid black prints faster/cleaner
2223

2324
// interaction colours
@@ -28,28 +29,27 @@ $color-link-focus: $color-link-hover !default;
2829
$color-selecting: tint($color-link-hover, 80%) !default;
2930
$color-selected: tint($color-link-hover, 90%) !default;
3031

31-
// borders
32-
33-
$color-border: #cccccc !default;
34-
$color-border-light: #d4d4d4 !default;
35-
3632
// neutral colours
3733

3834
$color-background: #ffffff !default;
3935
$color-background-zebra: #f0f0f0 !default;
4036
$color-background-box: #f7f7f7 !default;
4137
$color-background-form: #ffffff !default;
42-
$color-background-form-disabled: #eeeeee !default;
38+
$color-background-form-disabled: #e4e4e4 !default;
4339
$color-gradient-from: #eeeeee !default;
4440
$color-gradient-to: darken($color-gradient-from, 6.5%) !default;
45-
$color-gradient-border: darken($color-gradient-from, 13.5%) !default;
4641

4742
// accent colours
4843

4944
$color-highlight: #ffda44 !default;
5045
$color-strong-highlight-box: tint($color-highlight, 36%) !default;
5146
$color-highlight-box: tint($color-highlight, 84%) !default;
5247

48+
// border colours
49+
50+
$color-border: #cccccc !default;
51+
$color-border-light: #d4d4d4 !default;
52+
5353
// button colours
5454

5555
$color-button-gradient-from: $color-gradient-from !default;

0 commit comments

Comments
 (0)