background-gradient.scss 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. @function linear-gradient-bevel($direction, $bg-color) {
  2. @return linear-gradient($direction, color_stops(
  3. lighten($bg-color, 15%),
  4. lighten($bg-color, 8%) 30%,
  5. $bg-color 65%,
  6. darken($bg-color, 6%)
  7. ));
  8. }
  9. @function linear-gradient-glossy($direction, $bg-color) {
  10. @return linear-gradient($direction, color_stops(
  11. lighten($bg-color, 15%),
  12. lighten($bg-color, 5%) 50%,
  13. $bg-color 51%,
  14. darken($bg-color, 5%)
  15. ));
  16. }
  17. @function linear-gradient-recessed($direction, $bg-color) {
  18. @return linear-gradient($direction, color_stops(
  19. darken($bg-color, 10%),
  20. darken($bg-color, 5%) 10%,
  21. $bg-color 65%,
  22. lighten($bg-color, .5%)
  23. ));
  24. }
  25. @function linear-gradient-matte($direction, $bg-color) {
  26. @return linear-gradient($direction, color_stops(
  27. lighten($bg-color, 3%),
  28. darken($bg-color, 4%)
  29. ));
  30. }
  31. @function linear-gradient-matte-reverse($direction, $bg-color) {
  32. @return linear-gradient($direction, color_stops(
  33. darken($bg-color, 6%),
  34. lighten($bg-color, 4%)
  35. ));
  36. }
  37. @function linear-gradient-panel-header($direction, $bg-color) {
  38. @return linear-gradient($direction, color_stops(
  39. adjust-color($bg-color, $hue: -0.857deg, $saturation: -1.63%, $lightness: 3.529%),
  40. adjust-color($bg-color, $hue: 0.158deg, $saturation: -1.21%, $lightness: 0.392%) 45%,
  41. adjust-color($bg-color, $hue: 1.154deg, $saturation: 0.607%, $lightness: -7.647%) 46%,
  42. adjust-color($bg-color, $hue: 1.154deg, $saturation: 0.607%, $lightness: -7.647%) 50%,
  43. adjust-color($bg-color, $hue: 1.444deg, $saturation: -1.136%, $lightness: -4.706%) 51%,
  44. $bg-color
  45. ));
  46. }
  47. @function linear-gradient-tabbar($direction, $bg-color) {
  48. @return linear-gradient($direction, color_stops(
  49. adjust-color($bg-color, $hue: 0.0deg, $saturation: 1.604%, $lightness: 4.706%),
  50. $bg-color
  51. ));
  52. }
  53. @function linear-gradient-tab($direction, $bg-color) {
  54. @return linear-gradient($direction, color_stops(
  55. adjust-color($bg-color, $hue: 1.382deg, $saturation: -18.571%, $lightness: -4.902%),
  56. adjust-color($bg-color, $hue: 0.43deg, $saturation: -10.311%, $lightness: -2.157%) 25%,
  57. $bg-color 45%
  58. ));
  59. }
  60. @function linear-gradient-tab-active($direction, $bg-color) {
  61. @return linear-gradient($direction, color_stops(
  62. adjust-color($bg-color, $hue: -212.903deg, $saturation: -88.571%, $lightness: 6.863%),
  63. adjust-color($bg-color, $hue: 0.43deg, $saturation: -6.753%, $lightness: 4.706%) 25%,
  64. $bg-color 45%
  65. ));
  66. }
  67. @function linear-gradient-tab-over($direction, $bg-color) {
  68. @return linear-gradient($direction, color_stops(
  69. adjust-color($bg-color, $hue: 4.462deg, $saturation: -9.524%, $lightness: -3.725%),
  70. adjust-color($bg-color, $hue: 2.272deg, $saturation: 0.0%, $lightness: -1.569%) 25%,
  71. $bg-color 45%
  72. ));
  73. }
  74. @function linear-gradient-tab-disabled($direction, $bg-color) {
  75. @return linear-gradient($direction, color_stops(
  76. $bg-color,
  77. adjust-color($bg-color, $hue: -0.267deg, $saturation: 18.571%, $lightness: 2.941%)
  78. ));
  79. }
  80. @function linear-gradient-grid-header($direction, $bg-color) {
  81. @return linear-gradient($direction, color_stops(
  82. adjust-color($bg-color, $hue: 0deg, $saturation: 0%, $lightness: 20.392%),
  83. adjust-color($bg-color, $hue: 220.0deg, $saturation: 5.66%, $lightness: 12.353%)
  84. ));
  85. }
  86. @function linear-gradient-grid-header-over($direction, $bg-color) {
  87. @return linear-gradient($direction, color_stops(
  88. adjust-color($bg-color, $hue: 0.175deg, $saturation: 0.967%, $lightness: 14.118%),
  89. adjust-color($bg-color, $hue: 0.175deg, $saturation: 0.967%, $lightness: 14.118%) 39%,
  90. adjust-color($bg-color, $hue: 0.372deg, $saturation: 0.101%, $lightness: 10.196%) 40%,
  91. adjust-color($bg-color, $hue: 0.372deg, $saturation: 0.101%, $lightness: 10.196%)
  92. ));
  93. }
  94. @function linear-gradient-grid-row-over($direction, $bg-color) {
  95. @return linear-gradient($direction, color_stops(
  96. adjust-color($bg-color, $hue: 0.175deg, $saturation: 0.967%, $lightness: 14.118%),
  97. $bg-color
  98. ));
  99. }
  100. @function linear-gradient-grid-cell-special($direction, $bg-color) {
  101. @return linear-gradient($direction, color_stops(
  102. $bg-color,
  103. darken($bg-color, 5)
  104. ));
  105. }
  106. @function linear-gradient-glossy-button($direction, $bg-color) {
  107. @return linear-gradient($direction, color_stops(
  108. $bg-color,
  109. adjust-color($bg-color, $hue: 0deg, $saturation: 0%, $lightness: -2.353%) 48%,
  110. adjust-color($bg-color, $hue: 0deg, $saturation: 0%, $lightness: -11.373%) 52%,
  111. adjust-color($bg-color, $hue: 0deg, $saturation: 0%, $lightness: -9.412%)
  112. ));
  113. }
  114. @function linear-gradient-glossy-button-over($direction, $bg-color) {
  115. @return linear-gradient($direction, color_stops(
  116. $bg-color,
  117. adjust-color($bg-color, $hue: 1.754deg, $saturation: 0.0%, $lightness: -2.157%) 48%,
  118. adjust-color($bg-color, $hue: 5.833deg, $saturation: -35.135%, $lightness: -9.216%) 52%,
  119. adjust-color($bg-color, $hue: 5.833deg, $saturation: -27.273%, $lightness: -7.647%)
  120. ));
  121. }
  122. @function linear-gradient-glossy-button-pressed($direction, $bg-color) {
  123. @return linear-gradient($direction, color_stops(
  124. $bg-color,
  125. adjust-color($bg-color, $hue: -1.839deg, $saturation: -2.18%, $lightness: 2.157%) 48%,
  126. adjust-color($bg-color, $hue: -2.032deg, $saturation: 37.871%, $lightness: -4.706%) 52%,
  127. adjust-color($bg-color, $hue: -1.641deg, $saturation: 36.301%, $lightness: -2.549%)
  128. ));
  129. }
  130. // Patch compass background-image mixin to fix EXTJSIV-9723.
  131. // This patch is only guaranteed to be compatible with the current Sencha Cmd-bundled
  132. // version of compass - 0.12.2
  133. // Remove this override when proper support for w3c style gradients is implemented in
  134. // the compass framework. For more info see:
  135. // https://github.com/chriseppstein/compass/issues/965#ref-pullrequest-10812518
  136. @mixin background-image(
  137. $image-1,
  138. $image-2: false,
  139. $image-3: false,
  140. $image-4: false,
  141. $image-5: false,
  142. $image-6: false,
  143. $image-7: false,
  144. $image-8: false,
  145. $image-9: false,
  146. $image-10: false
  147. ) {
  148. $images: compact($image-1, $image-2, $image-3, $image-4, $image-5, $image-6, $image-7, $image-8, $image-9, $image-10);
  149. $add-pie-bg: prefixed(-pie, $images) or -compass-list-size($images) > 1;
  150. @if $experimental-support-for-svg and prefixed(-svg, $images) { background-image: -svg($images); background-size: 100%; }
  151. @if $support-for-original-webkit-gradients and prefixed(-owg, $images) { background-image: -owg($images); }
  152. @if $experimental-support-for-webkit and prefixed(-webkit, $images) { background-image: -webkit($images); }
  153. @if $experimental-support-for-mozilla and prefixed(-moz, $images) { background-image: -moz($images); }
  154. @if $experimental-support-for-opera and prefixed(-o, $images) { background-image: -o($images); }
  155. @if $experimental-support-for-pie and $add-pie-bg { @warn "PIE does not support background-image. Use @include background(#{$images}) instead." }
  156. // begin patch
  157. background-image: -ms-#{$images};
  158. // end patch
  159. background-image: $images ;
  160. }
  161. /**
  162. * Creates a background gradient.
  163. *
  164. * Example usage:
  165. * .foo {
  166. * @include background-gradient(#808080, matte, left);
  167. * }
  168. *
  169. * @param {Color} $bg-color The background color of the gradient
  170. * @param {String/List} [$type=$base-gradient] The type of gradient to be used. Can either
  171. * be a String which is a predefined gradient name, or it can can be a list of color stops.
  172. * If null is passed, this mixin will still set the `background-color` to $bg-color.
  173. * The available predefined gradient names are:
  174. *
  175. * * bevel
  176. * * glossy
  177. * * recessed
  178. * * matte
  179. * * matte-reverse
  180. * * panel-header
  181. * * tabbar
  182. * * tab
  183. * * tab-active
  184. * * tab-over
  185. * * tab-disabled
  186. * * grid-header
  187. * * grid-header-over
  188. * * grid-row-over
  189. * * grid-cell-special
  190. * * glossy-button
  191. * * glossy-button-over
  192. * * glossy-button-pressed
  193. *
  194. * Each of these gradient names corresponds to a function named linear-gradient[name].
  195. * Themes can override these functions to customize the color stops that they return.
  196. * For example, to override the glossy-button gradient function add a function named
  197. * "linear-gradient-glossy-button" to a file named "sass/etc/mixins/background-gradient.scss"
  198. * in your theme. The function should return the result of calling the Compass linear-gradient
  199. * function with the desired direction and color-stop information for the gradient. For example:
  200. *
  201. * @function linear-gradient-glossy-button($direction, $bg-color) {
  202. * @return linear-gradient($direction, color_stops(
  203. * mix(#fff, $bg-color, 10%),
  204. * $bg-color 50%,
  205. * mix(#000, $bg-color, 5%) 51%,
  206. * $bg-color
  207. * ));
  208. * }
  209. *
  210. * @param {String} [$direction=top] The direction of the gradient. Can either be
  211. * `top` or `left`.
  212. *
  213. * @member Global_CSS
  214. */
  215. @mixin background-gradient(
  216. $bg-color,
  217. $type: $base-gradient,
  218. $direction: top
  219. ) {
  220. background-image: none;
  221. background-color: $bg-color;
  222. @if not is-null($base-gradient) and $bg-color != transparent {
  223. $gradient: null;
  224. //color_stops
  225. @if type-of($type) == "list" {
  226. $gradient: linear-gradient($direction, $type);
  227. }
  228. //default gradients
  229. @else if $type == bevel {
  230. $gradient: linear-gradient-bevel($direction, $bg-color);
  231. } @else if $type == glossy {
  232. $gradient: linear-gradient-glossy($direction, $bg-color);
  233. } @else if $type == recessed {
  234. $gradient: linear-gradient-recessed($direction, $bg-color);
  235. } @else if $type == matte {
  236. $gradient: linear-gradient-matte($direction, $bg-color);
  237. } @else if $type == matte-reverse {
  238. $gradient: linear-gradient-matte-reverse($direction, $bg-color);
  239. }
  240. // gradients
  241. @else if $type == panel-header {
  242. $gradient: linear-gradient-panel-header($direction, $bg-color);
  243. } @else if $type == tabbar {
  244. $gradient: linear-gradient-tabbar($direction, $bg-color);
  245. } @else if $type == tab {
  246. $gradient: linear-gradient-tab($direction, $bg-color);
  247. } @else if $type == tab-active {
  248. $gradient: linear-gradient-tab-active($direction, $bg-color);
  249. } @else if $type == tab-over {
  250. $gradient: linear-gradient-tab-over($direction, $bg-color);
  251. } @else if $type == tab-disabled {
  252. $gradient: linear-gradient-tab-disabled($direction, $bg-color);
  253. } @else if $type == grid-header {
  254. $gradient: linear-gradient-grid-header($direction, $bg-color);
  255. } @else if $type == grid-header-over {
  256. $gradient: linear-gradient-grid-header-over($direction, $bg-color);
  257. } @else if $type == grid-row-over {
  258. $gradient: linear-gradient-grid-row-over($direction, $bg-color);
  259. } @else if $type == grid-cell-special {
  260. $gradient: linear-gradient-grid-cell-special($direction, $bg-color);
  261. } @else if $type == glossy-button or $type == glossy-button-disabled {
  262. $gradient: linear-gradient-glossy-button($direction, $bg-color);
  263. } @else if $type == glossy-button-over {
  264. $gradient: linear-gradient-glossy-button-over($direction, $bg-color);
  265. } @else if $type == glossy-button-pressed {
  266. $gradient: linear-gradient-glossy-button-pressed($direction, $bg-color);
  267. }
  268. @if $gradient != null {
  269. @include background-image($gradient);
  270. }
  271. }
  272. }