-
Notifications
You must be signed in to change notification settings - Fork 104
/
Copy path_buttons.scss
145 lines (122 loc) · 2.9 KB
/
_buttons.scss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
@import '../shims';
@import '../css3';
@import '../conditionals';
@import '../colours';
// Mixin and defaults for making buttons on GOV.UK services.
// For guidance, see: https://www.gov.uk/service-manual/design-and-content/resources/buttons.html
// Example usage:
// .button{
// @include button;
// }
// .button-secondary{
// @include button($grey-3);
// }
// .button-warning{
// @include button($red);
// }
@mixin button($colour: $button-colour) {
// Colour
background-color: $colour;
// Size and shape
position: relative;
@include inline-block;
padding: .526315em .789473em .263157em; // 10px 15px 5px
border: none;
@include border-radius(0);
outline: 1px solid transparent; // keep some button appearance when changing colour settings in browsers
outline-offset: -1px; // fixes bug in Safari that outline width on focus is not overwritten, is reset to 0 on focus in govuk_template
-webkit-appearance: none;
// Bottom edge effect
@include box-shadow(0 2px 0 darken($colour, 15%));
@include ie-lte(8) {
border-bottom: 2px solid darken($colour, 15%);
}
// Text
font-size: 1em; // inherit from parent
line-height: 1.25;
text-decoration: none;
-webkit-font-smoothing: antialiased;
// Interaction
cursor: pointer;
&:visited {
background-color: $colour;
}
&:hover,
&:focus {
background-color: darken($colour, 5%);
}
&:active {
top: 2px;
@include box-shadow(0 0 0 $colour);
}
// Disabled button styles
&.disabled,
&[disabled="disabled"],
&[disabled] {
@include opacity(0.5);
&:hover {
cursor: default;
background-color: $colour;
}
&:active {
top: 0;
@include box-shadow(0 2px 0 darken($colour, 15%));
@include ie-lte(8) {
border-bottom: 2px solid darken($colour, 15%);
}
}
}
// Set text colour depending on background colour
@if lightness($colour) < 50% {
color: $white;
&:link,
&:link:focus,
&:hover,
&:focus,
&:visited {
color: $white;
}
} @else {
color: $text-colour;
&:link,
&:link:focus,
&:hover,
&:focus,
&:visited {
color: $text-colour;
}
}
// making the click target bigger than the button
// (and fill the space made when the button moves)
&:before {
content: "";
height: 110%;
width: 100%;
display: block;
background: transparent;
position: absolute;
top: 0;
left: 0;
}
&:active:before {
top: -10%;
height: 120%;
// IE6 ignores the :before psuedo-class but applies the block to :active
// It therefore needs to be reset
@include ie(6) {
top: auto;
height: 100%;
}
}
// Fixes a bug where IE puts a black border around certain elements
@include ie-lte(8) {
&[type="submit"],
&[type="reset"],
&[type="button"] {
filter: chroma(color = $black);
}
&[type=submit].button {
filter: none;
}
}
}