Debian Codegraph @

sass-spec/spec/libsass/bourbon/lib/addons/_button.scss

raw
1 @mixin button ($style: simple, $base-color: #4294f0) {
2
3 @if type-of($style) == color {
4 $base-color: $style;
5 $style: simple;
6 }
7
8 // Grayscale button
9 @if $base-color == grayscale($base-color) {
10 @if $style == simple {
11 @include simple($base-color, $grayscale: true);
12 }
13
14 @else if $style == shiny {
15 @include shiny($base-color, $grayscale: true);
16 }
17
18 @else if $style == pill {
19 @include pill($base-color, $grayscale: true);
20 }
21 }
22
23 // Colored button
24 @else {
25 @if $style == simple {
26 @include simple($base-color);
27 }
28
29 @else if $style == shiny {
30 @include shiny($base-color);
31 }
32
33 @else if $style == pill {
34 @include pill($base-color);
35 }
36 }
37
38 &:disabled {
39 opacity: 0.5;
40 cursor: not-allowed;
41 }
42 }
43
44
45 // Simple Button
46 //************************************************************************//
47 @mixin simple($base-color, $grayscale: false) {
48 $color: hsl(0, 0, 100%);
49 $border: adjust-color($base-color, $saturation: 9%, $lightness: -14%);
50 $inset-shadow: adjust-color($base-color, $saturation: -8%, $lightness: 15%);
51 $stop-gradient: adjust-color($base-color, $saturation: 9%, $lightness: -11%);
52 $text-shadow: adjust-color($base-color, $saturation: 15%, $lightness: -18%);
53
54 @if lightness($base-color) > 70% {
55 $color: hsl(0, 0, 20%);
56 $text-shadow: adjust-color($base-color, $saturation: 10%, $lightness: 4%);
57 }
58
59 @if $grayscale == true {
60 $border: grayscale($border);
61 $inset-shadow: grayscale($inset-shadow);
62 $stop-gradient: grayscale($stop-gradient);
63 $text-shadow: grayscale($text-shadow);
64 }
65
66 border: 1px solid $border;
67 border-radius: 3px;
68 box-shadow: inset 0 1px 0 0 $inset-shadow;
69 color: $color;
70 display: inline-block;
71 font-size: 11px;
72 font-weight: bold;
73 @include linear-gradient ($base-color, $stop-gradient);
74 padding: 7px 18px;
75 text-decoration: none;
76 text-shadow: 0 1px 0 $text-shadow;
77 background-clip: padding-box;
78
79 &:hover:not(:disabled) {
80 $base-color-hover: adjust-color($base-color, $saturation: -4%, $lightness: -5%);
81 $inset-shadow-hover: adjust-color($base-color, $saturation: -7%, $lightness: 5%);
82 $stop-gradient-hover: adjust-color($base-color, $saturation: 8%, $lightness: -14%);
83
84 @if $grayscale == true {
85 $base-color-hover: grayscale($base-color-hover);
86 $inset-shadow-hover: grayscale($inset-shadow-hover);
87 $stop-gradient-hover: grayscale($stop-gradient-hover);
88 }
89
90 box-shadow: inset 0 1px 0 0 $inset-shadow-hover;
91 cursor: pointer;
92 @include linear-gradient ($base-color-hover, $stop-gradient-hover);
93 }
94
95 &:active:not(:disabled) {
96 $border-active: adjust-color($base-color, $saturation: 9%, $lightness: -14%);
97 $inset-shadow-active: adjust-color($base-color, $saturation: 7%, $lightness: -17%);
98
99 @if $grayscale == true {
100 $border-active: grayscale($border-active);
101 $inset-shadow-active: grayscale($inset-shadow-active);
102 }
103
104 border: 1px solid $border-active;
105 box-shadow: inset 0 0 8px 4px $inset-shadow-active, inset 0 0 8px 4px $inset-shadow-active, 0 1px 1px 0 #eee;
106 }
107 }
108
109
110 // Shiny Button
111 //************************************************************************//
112 @mixin shiny($base-color, $grayscale: false) {
113 $color: hsl(0, 0, 100%);
114 $border: adjust-color($base-color, $red: -117, $green: -111, $blue: -81);
115 $border-bottom: adjust-color($base-color, $red: -126, $green: -127, $blue: -122);
116 $fourth-stop: adjust-color($base-color, $red: -79, $green: -70, $blue: -46);
117 $inset-shadow: adjust-color($base-color, $red: 37, $green: 29, $blue: 12);
118 $second-stop: adjust-color($base-color, $red: -56, $green: -50, $blue: -33);
119 $text-shadow: adjust-color($base-color, $red: -140, $green: -141, $blue: -114);
120 $third-stop: adjust-color($base-color, $red: -86, $green: -75, $blue: -48);
121
122 @if lightness($base-color) > 70% {
123 $color: hsl(0, 0, 20%);
124 $text-shadow: adjust-color($base-color, $saturation: 10%, $lightness: 4%);
125 }
126
127 @if $grayscale == true {
128 $border: grayscale($border);
129 $border-bottom: grayscale($border-bottom);
130 $fourth-stop: grayscale($fourth-stop);
131 $inset-shadow: grayscale($inset-shadow);
132 $second-stop: grayscale($second-stop);
133 $text-shadow: grayscale($text-shadow);
134 $third-stop: grayscale($third-stop);
135 }
136
137 border: 1px solid $border;
138 border-bottom: 1px solid $border-bottom;
139 border-radius: 5px;
140 box-shadow: inset 0 1px 0 0 $inset-shadow;
141 color: $color;
142 display: inline-block;
143 font-size: 14px;
144 font-weight: bold;
145 @include linear-gradient(top, $base-color 0%, $second-stop 50%, $third-stop 50%, $fourth-stop 100%);
146 padding: 8px 20px;
147 text-align: center;
148 text-decoration: none;
149 text-shadow: 0 -1px 1px $text-shadow;
150
151 &:hover:not(:disabled) {
152 $first-stop-hover: adjust-color($base-color, $red: -13, $green: -15, $blue: -18);
153 $second-stop-hover: adjust-color($base-color, $red: -66, $green: -62, $blue: -51);
154 $third-stop-hover: adjust-color($base-color, $red: -93, $green: -85, $blue: -66);
155 $fourth-stop-hover: adjust-color($base-color, $red: -86, $green: -80, $blue: -63);
156
157 @if $grayscale == true {
158 $first-stop-hover: grayscale($first-stop-hover);
159 $second-stop-hover: grayscale($second-stop-hover);
160 $third-stop-hover: grayscale($third-stop-hover);
161 $fourth-stop-hover: grayscale($fourth-stop-hover);
162 }
163
164 cursor: pointer;
165 @include linear-gradient(top, $first-stop-hover 0%,
166 $second-stop-hover 50%,
167 $third-stop-hover 50%,
168 $fourth-stop-hover 100%);
169 }
170
171 &:active:not(:disabled) {
172 $inset-shadow-active: adjust-color($base-color, $red: -111, $green: -116, $blue: -122);
173
174 @if $grayscale == true {
175 $inset-shadow-active: grayscale($inset-shadow-active);
176 }
177
178 box-shadow: inset 0 0 20px 0 $inset-shadow-active, 0 1px 0 #fff;
179 }
180 }
181
182
183 // Pill Button
184 //************************************************************************//
185 @mixin pill($base-color, $grayscale: false) {
186 $color: hsl(0, 0, 100%);
187 $border-bottom: adjust-color($base-color, $hue: 8, $saturation: -11%, $lightness: -26%);
188 $border-sides: adjust-color($base-color, $hue: 4, $saturation: -21%, $lightness: -21%);
189 $border-top: adjust-color($base-color, $hue: -1, $saturation: -30%, $lightness: -15%);
190 $inset-shadow: adjust-color($base-color, $hue: -1, $saturation: -1%, $lightness: 7%);
191 $stop-gradient: adjust-color($base-color, $hue: 8, $saturation: 14%, $lightness: -10%);
192 $text-shadow: adjust-color($base-color, $hue: 5, $saturation: -19%, $lightness: -15%);
193
194 @if lightness($base-color) > 70% {
195 $color: hsl(0, 0, 20%);
196 $text-shadow: adjust-color($base-color, $saturation: 10%, $lightness: 4%);
197 }
198
199 @if $grayscale == true {
200 $border-bottom: grayscale($border-bottom);
201 $border-sides: grayscale($border-sides);
202 $border-top: grayscale($border-top);
203 $inset-shadow: grayscale($inset-shadow);
204 $stop-gradient: grayscale($stop-gradient);
205 $text-shadow: grayscale($text-shadow);
206 }
207
208 border: 1px solid $border-top;
209 border-color: $border-top $border-sides $border-bottom;
210 border-radius: 16px;
211 box-shadow: inset 0 1px 0 0 $inset-shadow, 0 1px 2px 0 #b3b3b3;
212 color: $color;
213 display: inline-block;
214 font-size: 11px;
215 font-weight: normal;
216 line-height: 1;
217 @include linear-gradient ($base-color, $stop-gradient);
218 padding: 5px 16px;
219 text-align: center;
220 text-decoration: none;
221 text-shadow: 0 -1px 1px $text-shadow;
222 background-clip: padding-box;
223
224 &:hover:not(:disabled) {
225 $base-color-hover: adjust-color($base-color, $lightness: -4.5%);
226 $border-bottom: adjust-color($base-color, $hue: 8, $saturation: 13.5%, $lightness: -32%);
227 $border-sides: adjust-color($base-color, $hue: 4, $saturation: -2%, $lightness: -27%);
228 $border-top: adjust-color($base-color, $hue: -1, $saturation: -17%, $lightness: -21%);
229 $inset-shadow-hover: adjust-color($base-color, $saturation: -1%, $lightness: 3%);
230 $stop-gradient-hover: adjust-color($base-color, $hue: 8, $saturation: -4%, $lightness: -15.5%);
231 $text-shadow-hover: adjust-color($base-color, $hue: 5, $saturation: -5%, $lightness: -22%);
232
233 @if $grayscale == true {
234 $base-color-hover: grayscale($base-color-hover);
235 $border-bottom: grayscale($border-bottom);
236 $border-sides: grayscale($border-sides);
237 $border-top: grayscale($border-top);
238 $inset-shadow-hover: grayscale($inset-shadow-hover);
239 $stop-gradient-hover: grayscale($stop-gradient-hover);
240 $text-shadow-hover: grayscale($text-shadow-hover);
241 }
242
243 border: 1px solid $border-top;
244 border-color: $border-top $border-sides $border-bottom;
245 box-shadow: inset 0 1px 0 0 $inset-shadow-hover;
246 cursor: pointer;
247 @include linear-gradient ($base-color-hover, $stop-gradient-hover);
248 text-shadow: 0 -1px 1px $text-shadow-hover;
249 background-clip: padding-box;
250 }
251
252 &:active:not(:disabled) {
253 $active-color: adjust-color($base-color, $hue: 4, $saturation: -12%, $lightness: -10%);
254 $border-active: adjust-color($base-color, $hue: 6, $saturation: -2.5%, $lightness: -30%);
255 $border-bottom-active: adjust-color($base-color, $hue: 11, $saturation: 6%, $lightness: -31%);
256 $inset-shadow-active: adjust-color($base-color, $hue: 9, $saturation: 2%, $lightness: -21.5%);
257 $text-shadow-active: adjust-color($base-color, $hue: 5, $saturation: -12%, $lightness: -21.5%);
258
259 @if $grayscale == true {
260 $active-color: grayscale($active-color);
261 $border-active: grayscale($border-active);
262 $border-bottom-active: grayscale($border-bottom-active);
263 $inset-shadow-active: grayscale($inset-shadow-active);
264 $text-shadow-active: grayscale($text-shadow-active);
265 }
266
267 background: $active-color;
268 border: 1px solid $border-active;
269 border-bottom: 1px solid $border-bottom-active;
270 box-shadow: inset 0 0 6px 3px $inset-shadow-active, 0 1px 0 0 #fff;
271 text-shadow: 0 -1px 1px $text-shadow-active;
272 }
273 }