]>
Commit | Line | Data |
---|---|---|
6527f429 DM |
1 | /**\r |
2 | * @class Global_CSS\r | |
3 | */\r | |
4 | \r | |
5 | @import "compass/css3/images";\r | |
6 | \r | |
7 | $default-gradient: matte !default;\r | |
8 | $support-for-original-webkit-gradients: false;\r | |
9 | \r | |
10 | /**\r | |
11 | * Adds a background gradient into a specified selector.\r | |
12 | *\r | |
13 | * @include background-gradient(#444, 'glossy');\r | |
14 | *\r | |
15 | * You can also use color-stops if you want full control of the gradient:\r | |
16 | *\r | |
17 | * @include background-gradient(#444, color-stops(#333, #222, #111));\r | |
18 | *\r | |
19 | * @param {Color} $bg-color\r | |
20 | * The base color of the gradient.\r | |
21 | *\r | |
22 | * @param {String/List} [$type=matte]\r | |
23 | * The style of the gradient, one of five pre-defined options: matte, bevel, glossy, recessed, or linear:\r | |
24 | *\r | |
25 | * @include background-gradient(red, 'glossy');\r | |
26 | *\r | |
27 | * It can also accept a list of color-stop values:;\r | |
28 | *\r | |
29 | * @include background-gradient(black, color-stops(#333, #111, #000));\r | |
30 | *\r | |
31 | * Values 'flat' and 'none' will result in no gradient, just flat background-color\r | |
32 | *\r | |
33 | * @param {String} $direction\r | |
34 | * The direction of the gradient.\r | |
35 | */\r | |
36 | @mixin background-gradient($bg-color, $type: $default-gradient, $direction: top, $contrast: 1) {\r | |
37 | $flat: $type == null or $type == none or $type == flat;\r | |
38 | \r | |
39 | @if $flat or ($bg-color == transparent) {\r | |
40 | background-color: $bg-color;\r | |
41 | \r | |
42 | @if $bg-color != null {\r | |
43 | // invoking this mixin with null, none, or flat as the $type parameter means\r | |
44 | // "no gradient" so make sure we don't inherit one via the cascade\r | |
45 | background-image: none;\r | |
46 | }\r | |
47 | }\r | |
48 | \r | |
49 | @if not $flat {\r | |
50 | @if type-of($type) == "list" {\r | |
51 | // Color stops provided - no $bg-color required\r | |
52 | @include background-image(linear-gradient($direction, $type));\r | |
53 | } @else if $bg-color != transparent {\r | |
54 | // Named gradients\r | |
55 | @if $bg-color == null {\r | |
56 | @warn '@background-gradient: $bg-color is required for named gradient "#{$type}"';\r | |
57 | } @else if $type == bevel {\r | |
58 | @include background-image(bevel-gradient($bg-color, $direction, $contrast));\r | |
59 | } @else if $type == glossy {\r | |
60 | @include background-image(glossy-gradient($bg-color, $direction, $contrast));\r | |
61 | } @else if $type == recessed {\r | |
62 | @include background-image(recessed-gradient($bg-color, $direction, $contrast));\r | |
63 | } @else if $type == linear {\r | |
64 | @include background-image(linear-gradient($direction, color_stops(lighten($bg-color, 5%), darken($bg-color, 10%))));\r | |
65 | } @else if $type == matte {\r | |
66 | @include background-image(matte-gradient($bg-color, $direction, $contrast));\r | |
67 | } @else {\r | |
68 | @warn '@background-gradient: invalid gradient name "#{$type}"';\r | |
69 | }\r | |
70 | }\r | |
71 | }\r | |
72 | }\r | |
73 | \r | |
74 | // These are functions so they can be combined together with background-image()// ie. @include background-image(background_noise(), glossy-gradient());\r | |
75 | \r | |
76 | @function bevel-gradient($bg-color: $base-color, $direction: top, $contrast: 1) {\r | |
77 | @return linear-gradient($direction, color_stops(\r | |
78 | lighten($bg-color, 15%),\r | |
79 | lighten($bg-color, 8%) 30%,\r | |
80 | $bg-color 65%,\r | |
81 | darken($bg-color, 6%)\r | |
82 | ));\r | |
83 | }\r | |
84 | \r | |
85 | @function glossy-gradient($bg-color: $base-color, $direction: top, $contrast: 1) {\r | |
86 | @return linear-gradient($direction, color_stops(lighten($bg-color, 15% * $contrast), lighten($bg-color, 5% * $contrast) 50%, $bg-color 51%, darken($bg-color, 5% * $contrast)));\r | |
87 | }\r | |
88 | \r | |
89 | @function recessed-gradient($bg-color: $base-color, $direction: top, $contrast: 1) {\r | |
90 | @return linear-gradient($direction, color_stops(darken($bg-color, 10% * $contrast), darken($bg-color, 5% * $contrast) 10%, $bg-color 65%, lighten($bg-color, .5% * $contrast)));\r | |
91 | }\r | |
92 | \r | |
93 | @function matte-gradient (\r | |
94 | $bg-color: $base-color,\r | |
95 | $direction: top,\r | |
96 | $contrast: 1\r | |
97 | ) {\r | |
98 | @return linear-gradient(\r | |
99 | $direction,\r | |
100 | color_stops(\r | |
101 | lighten($bg-color, 15% * $contrast),\r | |
102 | lighten($bg-color, 5% * $contrast) 3%,\r | |
103 | darken($bg-color, 5% * $contrast)\r | |
104 | )\r | |
105 | );\r | |
106 | }\r |