_mixins.scss 9.01 KB
Newer Older
1
// common - utilities - mixins and extends
2 3
// ====================

4
// Table of Contents
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
// * +Font Sizing - Mixin
// * +Line Height - Mixin
// * +Sizing - Mixin
// * +Square - Mixin
// * +Placeholder Styling - Mixin
// * +Flex Support - Mixin
// * +Flex Polyfill - Extends
// * +UI - Wrapper - Extends
// * +UI - Window - Extend
// * +UI - Visual Link - Extend
// * +UI - Functional Disable - Extend
// * +UI - Visual Link - Extend
// * +UI - Depth Levels - Extends
// * +UI - Clear Children - Extends
// * +UI - Buttons - Extends
// * +UI - Well Archetype - Extends
// * +Content - No List - Extends
// * +Content - Hidden Image Text - Extend
// * +Content - Screenreader Text - Extend
// * +Content - Text Wrap - Extend
// * +Content - Text Truncate - Extend
26
// * +Icon - Font-Awesome  - Extend
27
// * +Icon - SSO icon images
28 29

// +Font Sizing - Mixin
30
// ====================
31
@mixin font-size($sizeValue: 16){
32 33 34 35
  font-size: $sizeValue + px;
  font-size: ($sizeValue/10) + rem;
}

36
// +Line Height - Mixin
37
// ====================
38
@mixin line-height($fontSize: auto){
Brian Talbot committed
39 40 41 42
  line-height: ($fontSize*1.48) + px;
  line-height: (($fontSize/10)*1.48) + rem;
}

43
// +Sizing - Mixin
44
// ====================
Brian Talbot committed
45 46 47 48 49
@mixin size($width: $baseline, $height: $baseline) {
  height: $height;
  width: $width;
}

50
// +Square - Mixin
51
// ====================
Brian Talbot committed
52 53
@mixin square($size: $baseline) {
  @include size($size);
54 55
}

56
// +Placeholder Styling - Mixin
57
// ====================
58 59 60 61 62 63 64
@mixin placeholder($color) {
  :-moz-placeholder {
    color: $color;
  }
  ::-webkit-input-placeholder {
    color: $color;
  }
Brian Talbot committed
65 66
  :-ms-input-placeholder {
     color: $color;
67
  }
68 69
}

70
// +Flex Support - Mixin
71
// ====================
72 73 74 75 76 77 78 79
@mixin ui-flexbox() {
  display: -webkit-box;
  display: -moz-box;
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;
}

80
// +Flex PolyFill - Extends
81
// ====================
82 83

// justify-content right for display:flex alignment in older browsers
84
%ui-justify-right-flex {
85 86 87 88
  -webkit-box-pack: flex-end;
  -moz-box-pack: flex-end;
  -ms-flex-pack: flex-end;
  -webkit-justify-content: flex-end;
89 90 91
  justify-content: flex-end;
}

92
// justify-content left for display:flex alignment in older browsers
93
%ui-justify-left-flex {
94 95 96 97
  -webkit-box-pack: flex-start;
  -moz-box-pack: flex-start;
  -ms-flex-pack: flex-start;
  -webkit-justify-content: flex-start;
98 99 100
  justify-content: flex-start;
}

101
// align items center for display:flex alignment in older browsers
102 103 104 105 106 107 108 109
%ui-align-center-flex {
  -webkit-flex-align: center;
  -ms-flex-align: center;
  -webkit-align-items: center;
  align-items: center;
}


110
// +UI - Wrapper - Extends
111
// ====================
112
// used for page/view-level wrappers (for centering/grids)
113
%ui-wrapper {
Brian Talbot committed
114 115
  @include clearfix();
  @include box-sizing(border-box);
116 117 118
  width: 100%;
}

119
// layout placeholders
120
.ui-col-wide  {
121
  width: flex-grid(9, 12);
122 123
  @include margin-right(flex-gutter());
  @include float(left);
124 125
}

126
.ui-col-narrow  {
127
  width: flex-grid(3, 12);
128
  @include float(left);
129 130
}

131
// +UI - Window - Extends
132
// ====================
133
%ui-window {
134
  @include clearfix();
135 136
  border-radius: ($baseline/10);
  box-shadow: 0 1px 1px $shadow-l2;
137 138 139
  margin-bottom: $baseline;
  border: 1px solid $gray-l2;
  background: $white;
140 141 142 143 144

  // STATE: hover/active
  &:hover, &:active {
    box-shadow: 0 1px 1px $shadow;
  }
145 146
}

147
// +UI - Visual Link - Extends
148
// ====================
149
%ui-fake-link {
Brian Talbot committed
150 151
  cursor: pointer;
}
152

153
// +UI - Functional Disable - Extends
154
// ====================
155
%ui-disabled {
Brian Talbot committed
156 157
  pointer-events: none;
  outline: none;
158
  cursor: default;
159 160
}

161
// +UI - Depth Levels - Extends
162
// ====================
163 164 165 166 167 168
%ui-depth0 { z-index: 0; }
%ui-depth1 { z-index: 10; }
%ui-depth2 { z-index: 100; }
%ui-depth3 { z-index: 1000; }
%ui-depth4 { z-index: 10000; }
%ui-depth5 { z-index: 100000; }
Brian Talbot committed
169 170


171
// +UI - Clear Children - Extends
172
// ====================
173
// extends - UI - utility - first child clearing
174 175 176 177 178 179 180 181 182
%wipe-first-child {

  &:first-child {
    margin-top: 0;
    border-top: none;
    padding-top: 0;
  }
}

183
// extends - UI - utility - last child clearing
184 185 186 187 188 189 190 191 192
%wipe-last-child {

  &:last-child {
    margin-bottom: 0;
    border-bottom: none;
    padding-bottom: 0;
  }
}

193
// +UI - Buttons - Extends
194
// ====================
195
%ui-btn {
Brian Talbot committed
196
  @include box-sizing(border-box);
197
  @include transition(color $tmg-f2 ease-in-out 0s, border-color $tmg-f2 ease-in-out 0s, background $tmg-f2 ease-in-out 0s, box-shadow $tmg-f2 ease-in-out 0s);
Brian Talbot committed
198 199 200 201
  display: inline-block;
  cursor: pointer;

  &:hover, &:active {
202 203 204

  }

205
  &.disabled, &[disabled], &.is-disabled {
Brian Talbot committed
206 207
    cursor: default;
    pointer-events: none;
208 209 210
    border: 1px solid $gray-l3;
    background-color: $gray-l3;
    color: $gray-l5;
Brian Talbot committed
211 212 213 214 215 216 217
  }

  .icon-inline {
    display: inline-block;
    vertical-align: middle;
    margin-right: ($baseline/4);
  }
218 219
}

Brian Talbot committed
220
// pill button
221
%ui-btn-pill {
222
  border-radius: ($baseline/5);
223 224
}

225
%ui-btn-rounded {
226
  border-radius: ($baseline/2);
227 228
}

Brian Talbot committed
229
// primary button
230 231 232
%ui-btn-primary {
  @extend %ui-btn;
  @extend %ui-btn-pill;
233
  @extend %t-strong;
Brian Talbot committed
234 235 236
  padding:($baseline/2) $baseline;
  border-width: 1px;
  border-style: solid;
237
  box-shadow: none;
Brian Talbot committed
238 239 240
  line-height: 1.5em;
  text-align: center;

241
  &:hover, &:active, &:focus {
242
    box-shadow: 0 2px 1px $shadow;
Brian Talbot committed
243 244 245
  }

  &.current, &.active {
246
    box-shadow: inset 1px 1px 2px $shadow-d1;
Brian Talbot committed
247

248
    &:hover, &:active, &:focus {
249
      box-shadow: inset 1px 1px 1px $shadow-d1;
Brian Talbot committed
250 251
    }
  }
252 253
}

Brian Talbot committed
254
// secondary button
255 256 257
%ui-btn-secondary {
  @extend %ui-btn;
  @extend %ui-btn-pill;
Brian Talbot committed
258 259 260 261 262 263 264
  border-width: 1px;
  border-style: solid;
  padding:($baseline/2) $baseline;
  background: transparent;
  line-height: 1.5em;
  text-align: center;
}
265

266
%ui-btn-flat-outline {
267
  @include transition(all .15s);
268 269
  @extend %t-strong;
  @extend %t-action4;
270 271
  text-align: center;
  border-radius: ($baseline/4);
272
  border: 1px solid $uxpl-blue-base;
273
  padding: 1px ($baseline/2) 2px ($baseline/2);
274 275
  background-color: $white;
  color: $uxpl-blue-base;
276

277
  &:hover, &:focus {
278 279
    border: 1px solid $uxpl-blue-hover-active;
    background-color: $uxpl-blue-hover-active;
280 281 282 283 284 285 286 287 288 289 290 291
    color: $white;
  }

  &.is-disabled,
  &[disabled="disabled"]{
   border: 1px solid $gray-l2;
   background-color: $gray-l4;
   color: $gray-l2;
   pointer-events: none;
  }
}

292
// button with no button shell until hover for understated actions
293
%ui-btn-non {
294
  @include transition(all .15s);
295 296 297 298
  @extend %ui-btn-pill;
  @include transition(all $tmg-f2 linear 0s);
  display: inline-block;
  vertical-align: middle;
299 300
  border: none;
  padding: 3px ($baseline/2);
301
  background: none;
302 303
  color: $gray-l1;

304
  &:hover, &:focus {
305 306 307 308 309
    background-color: $gray-l1;
    color: $white;
  }
}

310 311 312 313 314
// button with no button shell until hover for understated actions
%ui-btn-non-blue {
  @extend %ui-btn-non;

  &:hover, &:focus {
315
    background-color: $uxpl-blue-base;
316 317 318 319
    color: $white;
  }
}

320
// +UI - Well Archetype - Extends
321
// ====================
322
%ui-well {
323
  box-shadow: inset 0 1px 2px 1px $shadow;
324
  padding: ($baseline*0.75) $baseline;
325
}
326

327 328
%no-content {
  @extend %ui-well;
329
  padding: ($baseline*2);
330 331 332
  background-color: $gray-l4;
  text-align: center;
  color: $gray;
333 334 335 336

  .button,
  .action {
    @extend %btn-primary-green;
337
    @extend %t-action3;
338 339
    margin-left: $baseline;

340
    .icon {
341 342 343
      margin-right: ($baseline/2);
    }
  }
344 345
}

346 347 348
.ui-loading {
  @include animation(fadeIn $tmg-f2 linear 1);
  @extend %ui-well;
Frances Botsford committed
349
  @extend %t-copy-base;
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364
  opacity: .6;
  background-color: $white;
  padding: ($baseline*1.5) $baseline;
  text-align: center;

  .spin {
    @extend %anim-rotateCW;
    display: inline-block;
  }

  .copy {
    padding-left: ($baseline/4);
  }
}

365 366 367 368
.is-hidden {
  display: none;
}

369
// +Content - No List - Extends
370
// ====================
371
// removes list styling/spacing when using uls, ols for navigation and less content-centric cases
372
%cont-no-list {
373 374 375 376 377 378 379 380 381 382 383
  list-style: none;
  margin: 0;
  padding: 0;
  text-indent: 0;

  li {
    margin: 0;
    padding: 0;
  }
}

384
// +Content - Hidden Image Text - Extend
385
// ====================
386
// image-replacement hidden text
387
%cont-text-hide {
388 389 390 391 392
  text-indent: 100%;
  white-space: nowrap;
  overflow: hidden;
}

393
// +Content - Screenreader Text - Extend
394
// ====================
395
%cont-text-sr {
396 397 398 399 400 401 402 403 404 405 406 407
    // clip has been deprecated but is still supported
    clip: rect(1px 1px 1px 1px);
    clip: rect(1px, 1px, 1px, 1px);
    position: absolute;
    margin: -1px;
    height: 1px;
    width: 1px;
    border: 0;
    padding: 0;
    overflow: hidden;
    // ensure there are spaces in sr text
    word-wrap: normal;
408 409
}

410
// +Content - Text Wrap - Extend
411
// ====================
412
%cont-text-wrap {
413 414 415
  word-wrap: break-word;
}

416
// +Content - Text Truncate - Extend
417
// ====================
418
%cont-truncated {
419 420 421 422 423
  @include box-sizing(border-box);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
424

425
// * +Icon - Font-Awesome  - Extend
426
// ====================
427
%use-font-awesome {
428
  display: inline-block;
429 430 431 432
  font-family: FontAwesome;
  -webkit-font-smoothing: antialiased;
  speak: none;
}
433 434 435 436 437 438 439

%btn-no-style {
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
}
440 441 442 443 444 445 446 447 448 449 450 451 452 453


// * +Icon - SSO icon images
// ====================

%sso-icon {
  .icon-image {
    width: auto;
    height: auto;
    max-height: 1.4em;
    max-width: 1.4em;
    margin-top: -2px;
  }
}