_mixins.scss 8.67 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 28

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

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

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

160
// +UI - Depth Levels - Extends
161
// ====================
162 163 164 165 166 167
%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
168 169


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

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

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

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

192
// +UI - Buttons - Extends
193
// ====================
194
%ui-btn {
Brian Talbot committed
195
  @include box-sizing(border-box);
196
  @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
197 198 199 200
  display: inline-block;
  cursor: pointer;

  &:hover, &:active {
201 202 203

  }

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

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

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

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

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

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

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

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

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

264
  &:hover, &:active, &:focus {
Brian Talbot committed
265 266 267 268 269 270 271

  }

  &.current, &.active {

  }
}
272

273
%ui-btn-flat-outline {
274
  @include transition(all .15s);
275 276
  @extend %t-strong;
  @extend %t-action4;
277 278 279 280
  text-align: center;
  border-radius: ($baseline/4);
  border: 1px solid $blue-l2;
  padding: 1px ($baseline/2) 2px ($baseline/2);
281
  background-color: transparent;
282 283
  color: $blue-l2;

284
  &:hover, &:focus {
285 286 287 288 289 290 291 292 293 294 295 296 297 298
    border: 1px solid $blue;
    background-color: $blue;
    color: $white;
  }

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

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

311
  &:hover, &:focus {
312 313 314
    background-color: $gray-l1;
    color: $white;
  }
315 316

  span {
317
    @extend %cont-text-sr;
318
  }
319 320
}

321 322 323 324 325 326 327 328 329 330
// button with no button shell until hover for understated actions
%ui-btn-non-blue {
  @extend %ui-btn-non;

  &:hover, &:focus {
    background-color: $blue;
    color: $white;
  }
}

331
// +UI - Well Archetype - Extends
332
// ====================
333
%ui-well {
334
  box-shadow: inset 0 1px 2px 1px $shadow;
335
  padding: ($baseline*0.75) $baseline;
336
}
337

338 339
%no-content {
  @extend %ui-well;
340
  padding: ($baseline*2);
341 342 343
  background-color: $gray-l4;
  text-align: center;
  color: $gray;
344 345 346 347

  .button,
  .action {
    @extend %btn-primary-green;
348
    @extend %t-action3;
349 350
    margin-left: $baseline;

351
    .icon {
352 353 354
      margin-right: ($baseline/2);
    }
  }
355 356
}

357 358 359
.ui-loading {
  @include animation(fadeIn $tmg-f2 linear 1);
  @extend %ui-well;
Frances Botsford committed
360
  @extend %t-copy-base;
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375
  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);
  }
}

376 377 378 379
.is-hidden {
  display: none;
}

380
// +Content - No List - Extends
381
// ====================
382
// removes list styling/spacing when using uls, ols for navigation and less content-centric cases
383
%cont-no-list {
384 385 386 387 388 389 390 391 392 393 394
  list-style: none;
  margin: 0;
  padding: 0;
  text-indent: 0;

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

395
// +Content - Hidden Image Text - Extend
396
// ====================
397
// image-replacement hidden text
398
%cont-text-hide {
399 400 401 402 403
  text-indent: 100%;
  white-space: nowrap;
  overflow: hidden;
}

404
// +Content - Screenreader Text - Extend
405
// ====================
406
%cont-text-sr {
407 408 409 410 411 412 413 414 415 416
  border: 0;
  clip: rect(0 0 0 0);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
}

417
// +Content - Text Wrap - Extend
418
// ====================
419
%cont-text-wrap {
420 421 422
  word-wrap: break-word;
}

423
// +Content - Text Truncate - Extend
424
// ====================
425
%cont-truncated {
426 427 428 429 430
  @include box-sizing(border-box);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
431

432
// * +Icon - Font-Awesome  - Extend
433
// ====================
434
%use-font-awesome {
435
  display: inline-block;
436 437 438 439
  font-family: FontAwesome;
  -webkit-font-smoothing: antialiased;
  speak: none;
}
440 441 442 443 444 445 446

%btn-no-style {
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
}