_helpers.sass 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. // *************************************
  2. //
  3. // Helpers
  4. // -> Functions, Mixins, Extends, Animations
  5. //
  6. // *************************************
  7. // -------------------------------------
  8. // Functions
  9. // -------------------------------------
  10. // ----- Em ----- //
  11. // -> Converts pixel value to an em
  12. //
  13. // $target - the target pixel size
  14. // $context - the context font-size
  15. @function em($target, $context: $b-fontSize)
  16. @if ($target == 0)
  17. @return 0
  18. @else
  19. @return ($target / $context) * 1em
  20. // ----- Opposite Position ----- //
  21. // -> Returns the opposite side
  22. //
  23. // $side - the side to return the opposite of
  24. //
  25. @function opposite-position($side)
  26. @if $side == 'top'
  27. @return 'bottom'
  28. @if $side == 'bottom'
  29. @return 'top'
  30. @if $side == 'left'
  31. @return 'right'
  32. @if $side == 'right'
  33. @return 'left'
  34. // -------------------------------------
  35. // Mixins
  36. // -------------------------------------
  37. // ----- Font Face ----- //
  38. // -> https://github.com/thoughtbot/bourbon/edit/master/app/assets/stylesheets/css3/_font-face.scss#
  39. //
  40. // $family - the font-family
  41. // $path - the font path
  42. // $weight - the font-weight
  43. // $style - the font-style
  44. // $asset-pipeline - use the Rails asset pipeline (boolean)
  45. =font-face($family, $path, $weight: normal, $style: normal, $asset-pipeline: true)
  46. @font-face
  47. font-family: $family
  48. font-style: $style
  49. font-weight: $weight
  50. @if $asset-pipeline == true
  51. src: font-url('#{$path}.eot')
  52. src: font-url('#{$path}.eot?#iefix') format('embedded-opentype'), font-url('#{$path}.woff') format('woff'), font-url('#{$path}.ttf') format('truetype'), font-url('#{$path}.svg##{$family}') format('svg')
  53. @else
  54. src: url('#{$path}.eot')
  55. src: url('#{$path}.eot?#iefix') format('embedded-opentype'), url('#{$path}.woff') format('woff'), url('#{$path}.ttf') format('truetype'), url('#{$path}.svg##{$family}') format('svg')
  56. // ----- Respond-to ----- //
  57. // -> Generates a media query
  58. //
  59. // $val - the breakpoint size
  60. // $query - the type of query ('min-width', 'max-width')
  61. // $media - the media type ('screen', 'print', etc.)
  62. // @content - the generated content within the mixin
  63. =respond-to($val, $query: min-width, $media: screen)
  64. @media #{$media} and ($query: $val)
  65. @content
  66. // ----- Caret ----- //
  67. // -> Adds an arrow to an element
  68. //
  69. // $side - the side ('left', 'right', 'top', 'bottom')
  70. // $size - the size of the caret
  71. // $color - the color of the caret
  72. //
  73. =caret($side, $size, $color)
  74. $opposite: opposite-position($side)
  75. border: $size solid transparent
  76. border-#{$opposite}: $size solid $color
  77. border-#{$side}: 0
  78. bottom: auto
  79. content: ''
  80. display: block
  81. height: 0
  82. left: 50%
  83. margin: (-$size) 0 0 (-$size)
  84. margin-#{$side}: 0
  85. position: absolute
  86. right: auto
  87. top: 50%
  88. width: 0
  89. #{$side}: -$size
  90. #{$opposite}: auto
  91. // ----- Transform ----- //
  92. // -> Auto-prefixed transform properties
  93. //
  94. // $args - a variable number of transform values
  95. //
  96. =transform($args...)
  97. -webkit-transform: $args
  98. -moz-transform: $args
  99. -ms-transform: $args
  100. transform: $args
  101. // ----- Transition ----- //
  102. // -> Auto-prefixed transition properties
  103. //
  104. // $args - a variable number of transition values
  105. //
  106. =transition($args...)
  107. -webkit-transition: $args
  108. transition: $args
  109. // ----- Transition Transform ----- //
  110. // -> Auto-prefixed transition properties (for transforms)
  111. //
  112. // $args - a variable number of transform values
  113. //
  114. =transition-transform($args...)
  115. -webkit-transition: -webkit-transform $args
  116. transition: transform $args
  117. // -------------------------------------
  118. // Extends
  119. // -------------------------------------
  120. // ----- Clearfix ----- //
  121. %group::after
  122. clear: both
  123. content: ''
  124. display: table
  125. // ----- Faux Hide ----- //
  126. %fauxHide
  127. height: 0
  128. opacity: 0
  129. overflow: hidden
  130. visibility: hidden
  131. // ----- Faux Show ----- //
  132. %fauxShow
  133. height: auto
  134. opacity: 1
  135. overflow: visible
  136. visibility: visible
  137. // ----- Box Sizing ----- //
  138. %boxSizing
  139. -moz-box-sizing: border-box
  140. box-sizing: border-box
  141. // -------------------------------------
  142. // Animations
  143. // -------------------------------------
  144. // ...