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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
|
// @category Button
// Values default to global values (evaluated when the mixins are called)
$v-button-background-color: null !default;
$v-button-bevel-style: null !default;
$v-button-bevel-depth: null !default;
$v-button-gradient-style: null !default;
$v-button-gradient-depth: null !default;
$v-button-shadow-style: null !default;
$v-button-shadow-depth: null !default;
$v-button-border-radius: $v-border-radius !default;
$v-button-unit-size: null !default;
$v-button-font-weight: max(400, $v-font-weight + 100) !default;
$v-button-cursor: pointer !default;
$v-button-hover-style-enabled: $v-hover-styles-enabled !default;
$v-button-border-width: $v-border-width !default;
$v-button-disabled-opacity: $v-disabled-opacity !default;
// The main mixin for Valo buttons
// @mixin v-valo-button
// @param $primary-stylename {String} the primary stylename to use for the output. Defaults to <code>v-button</code>
@mixin v-valo-button ($primary-stylename: v-button) {
.#{$primary-stylename} {
@include v-valo-button-common-properties;
@include v-valo-button-style;
}
}
@mixin v-valo-button-common-properties {
@include v-valo-tappable;
cursor: $v-button-cursor;
font-weight: $v-button-font-weight;
position: relative;
text-align: center;
white-space: nowrap;
// Generated element for :hover, :focus and :active styles
&:after {
content: "";
position: absolute;
top: -$v-button-border-width;
right: -$v-button-border-width;
bottom: -$v-button-border-width;
left: -$v-button-border-width;
border-radius: inherit;
border: inherit;
border-width: 0;
@if $v-animations-enabled {
@include transition(box-shadow 180ms, border 180ms);
}
}
&.v-disabled {
@include opacity($v-button-disabled-opacity);
&:after {
display: none;
}
}
@include v-valo-button-vertical-centering;
}
@mixin v-valo-button-vertical-centering {
// Vertical centering of icon and caption, independent of the height of the button
@include vertical-align-guide($to-align: div, $pseudo-element: before);
// WebKit handles line-heights and vertical-alignments somewhat differently, so we need to adjust
.v-sa &:before {
height: 110%;
}
// Firefox needs a bit of adjusting as well
.v-ff &:before {
height: 105%;
}
// ...and so does IE. Who knew?
.v-ie &:before {
margin-top: 4px;
}
}
@mixin v-valo-button-size ($unit-size, $border-radius) {
height: $unit-size;
$padding-width: ceil($unit-size/2.4);
$padding-width: $padding-width + ceil($border-radius/3);
padding: 0 $padding-width;
.v-icon {
margin: 0 ceil($padding-width/-5);
}
.v-icon + span:not(:empty) {
margin-left: ceil($padding-width/1.5);
}
}
@function v-valo-button-border-color ($bevel-style: $v-bevel-style, $bevel-depth: $v-bevel-depth,
$background-color: $v-button-background-color) {
$background-color: $background-color or $v-app-background-color;
$border-color: if(color-luminance($background-color) < color-luminance($v-app-background-color), $background-color, $v-app-background-color);
$border-color: blend-darken($border-color, scale-color($border-color, $lightness: max(-50%, -$bevel-depth/2)));
$border-color: scale-color($border-color, $saturation: -$bevel-depth/2);
@if contains($bevel-style, shade, true) {
$border-color: $border-color $border-color blend-multiply(transparentize(#000, max(0.8, 1-$bevel-depth/200%)), $border-color);
}
@return $border-color;
}
@mixin v-valo-button-style ($gradient-style: $v-button-gradient-style, $gradient-depth: $v-button-gradient-depth,
$bevel-style: $v-button-bevel-style, $bevel-depth: $v-button-bevel-depth,
$unit-size: $v-button-unit-size, $border-radius: $v-button-border-radius,
$background-color: $v-button-background-color) {
// Set up variable defaults
$background-color: $background-color or $v-app-background-color;
$gradient-style: $gradient-style or $v-gradient-style;
$gradient-depth: $gradient-depth or $v-gradient-depth;
$bevel-style: $bevel-style or $v-bevel-style;
$bevel-depth: $bevel-depth or $v-bevel-depth;
$unit-size: $unit-size or $v-unit-size;
@include v-valo-button-size($unit-size, $border-radius);
border-radius: $border-radius;
border: $v-button-border-width solid;
border-color: v-valo-button-border-color($bevel-style, $bevel-depth, $background-color);
@include v-valo-gradient($background-color, $gradient-style, $gradient-depth);
color: v-valo-font-color($background-color, 0.9);
box-shadow: v-valo-button-box-shadow($background-color, $bevel-style, $bevel-depth, $gradient-style, $gradient-depth);
text-shadow: v-valo-button-text-shadow($background-color, $bevel-depth);
@if $v-button-hover-style-enabled {
&:hover:after {
@include v-valo-button-hover-style($background-color: $background-color);
}
}
&:focus {
outline: none;
&:after {
@include v-valo-button-focus-style($background-color: $background-color);
}
}
&:active:after,
&.v-pressed:after {
@include v-valo-button-active-style($background-color: $background-color);
}
}
@mixin v-valo-button-focus-style ($background-color: $v-app-background-color, $border-fallback: inherit) {
$focus-color: v-valo-focus-color();
@if color-luminance($focus-color) + 50 < color-luminance($background-color) {
border: $v-button-border-width solid $focus-color;
} @else {
border: $border-fallback or v-valo-button-border-color($background-color: $background-color);
}
box-shadow: v-valo-focus-box-shadow($color: $focus-color);
@if $v-animations-enabled {
@include transition(none);
}
}
@mixin v-valo-button-active-style ($background-color: $v-app-background-color) {
$bg: scale-color($background-color, $lightness: -50%, $saturation: saturation($v-app-background-color));
background-color: rgba($bg, .1);
.v-ie8 & {
background-color: $bg;
filter: alpha(opacity=10);
}
}
@mixin v-valo-button-hover-style ($background-color: $v-app-background-color) {
$bg: lighten($background-color, 15%);
background-color: rgba($bg, .1);
border: inherit;
@if $v-animations-enabled {
@include transition(none);
}
.v-ie8 & {
background-color: $bg;
filter: alpha(opacity=20);
}
}
@mixin v-valo-button-borderless-style {
border: none;
box-shadow: none;
background: transparent;
color: inherit;
}
@mixin v-valo-button-icon-align-right-style ($primary-stylename: v-button) {
.#{$primary-stylename}-wrap {
display: inline-block;
}
.v-icon {
float: right;
$padding-width: ceil($v-unit-size/2.4);
margin-left: $padding-width + ceil($padding-width/-5);
+ span:not(:empty) {
margin-left: 0;
}
}
}
@function v-valo-button-box-shadow($background-color, $bevel-style: $v-bevel-style, $bevel-depth: $v-bevel-depth, $gradient-style: $v-gradient-style, $gradient-depth: $v-gradient-depth) {
@return v-valo-bevel($background-color, $bevel-style, $bevel-depth, $gradient-style, $gradient-depth), v-valo-shadow();
}
@function v-valo-button-text-shadow($background-color, $bevel-depth: $v-bevel-depth) {
@if is-dark-color($background-color) {
@return 0 -1px 0 transparentize(darken($background-color, $bevel-depth), 1-($bevel-depth/100%));
} @else {
@return 0 1px 0 transparentize(lighten($background-color, $bevel-depth), 1-($bevel-depth/100%));
}
}
|