summaryrefslogtreecommitdiff
path: root/app/assets/stylesheets/vendor/survival-kit/_tools.scss
blob: e753dfe1fba15b3f63689c766fe5544ad6d41d7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
// Survival ✚ Kit
$container-width           : 1000px !default;
$compatibility-mode        : true, ie ie7 ie8 ie9 ff2 chrome9 !default;

// Function to know if we're in compatibility mode, if $version is set it'll return if there's  a match for that browser.
@function in-compatibility-mode($version: false) {
  @if $compatibility-mode {
    @if $version {
      @return index(nth($compatibility-mode, 2), $version);
    } @else {
      @return nth($compatibility-mode, 1);
    }
  } @else {
    @return false;
  }
}

// Shortcut to remove margin an padding.
// Used on several @mixins.
@mixin no-mp($extend:false) {
  @if $extend {
    @extend .no-mp;
  } @else {
    margin:0;
    padding:0;
  }
}
// Sometimes it's better to extend a class.
.no-mp {
  margin:0;
  padding:0;
}

// Center an element.
@mixin center-container($container-width, $vertical-margin:0, $padding:0) {
  margin:$vertical-margin auto;
  @if $padding == 0 {
    width:$container-width;
  } @else {
    @include size($container-width, auto, $padding);
  }
}

// Inline Block CrossBrowser.
// Disregards FF2 and IE6
@mixin inline-block {
  display: inline-block;
  @if in-compatibility-mode(ie7) {
    zoom: 1;
    *display:inline;
  }
}

// Shortcut to set absolute positioning.
@mixin pos($pos, $debug: false) {
  @if length($pos) == 1 {
    $pos: $pos 0 0 0;
  }
  @if length($pos) == 2 {
    $pos: nth($pos,1) nth($pos,2) 0 0;
  }
  @if length($pos) == 3 {
    $pos: nth($pos,1) nth($pos,2) nth($pos, 3) 0;
  }
  position:absolute;
  @if "#{nth($pos, 1)}" != "0" { top: nth($pos, 1); }
  @if "#{nth($pos, 2)}" != "0" { right: nth($pos, 2); }
  @if "#{nth($pos, 3)}" != "0" { bottom: nth($pos, 3); }
  @if "#{nth($pos, 4)}" != "0" { left: nth($pos, 4); }
	@if $debug { @include debug($debug); }
}

// Center a absolute element horizontally; optional offset.
@mixin pos-x-center($width, $offset:0) {
  @include pos(0 50% 0 50%);
  margin-left:$offset - ( $width / 2 );
  width:$width;
}

// Center a absolute element vertically; optional offset.
@mixin pos-y-center($height, $offset:0) {
  @include pos(50% 0 50% 0);
  height:$height;
  margin-top:$offset - ( $height / 2 );
}

// Set a debug variable.
@mixin debug($color:red) {
  @if $debug != false {
		@if $color == true { $color:red; }
    background: rgba($color, 0.2); // incompatible with IE.
  }
}

// Class available to center container to 1000px
.w, .pagewidth {
	@include center-container($container-width);
}

// Crossbrowser linear gradient.
// Compatible Browsers: FF3.6+ Saf4+ Chrome IE6-IE9
// @author SitePoint
@mixin background-gradient($from, $to, $start: top, $end: bottom, $fallback:$from, $ie:false) {
  @include gradient($from, $to, $start, $end, $fallback);
}
@mixin gradient($from, $to, $start: top, $end: bottom, $fallback:$from){
  background-color: $fallback;

  @if $end == bottom and $start == top {
    @if $start == 0 {
      background-image: -webkit-gradient(linear, left $start, left bottom, from($from), to($to));
    } @else {
      background-image: -webkit-gradient(linear, $start, left bottom, from($from), to($to));
    }
    background-image: -webkit-linear-gradient($start, $from, $to);
    background-image: -moz-linear-gradient($start, $from, $to);
    background-image: -ms-linear-gradient($start, $from, $to);
    background-image: -o-linear-gradient($start, $from, $to);
    @if in-compatibility-mode()  {
      filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#{ie-hex-str($from)}', EndColorStr='#{ie-hex-str($to)}');
    }
  } @else if $end == bottom {
    background-image: -webkit-gradient(linear, left $start,  0 $end, from($from), to($to));
    background-image: -webkit-linear-gradient(top, $from $start+px, $to);
    background-image: -moz-linear-gradient(top, $from $start+px, $to);
    background-image: -ms-linear-gradient(top, $from $start+px, $to);
    background-image: -o-linear-gradient(top, $from $start+px, $to);

  } @else {
    background-image: -webkit-gradient(linear, left $start,  0 $end, from($from), to($to));
    background-image: -webkit-linear-gradient(top, $from $start+px, $to $end+px);
    background-image: -moz-linear-gradient(top, $from $start+px, $to $end+px);
    background-image: -ms-linear-gradient(top, $from $start+px, $to $end+px);
    background-image: -o-linear-gradient(top, $from $start+px, $to $end+px);
    // No IE support for positioned gradients
  }
}

// Mixin that allows you to set the size of the box to a fixed width/height
// taking into consideration the padding and borders for you.
//
// Examples:
//     @include size(100px, 100px, 10px, 5px solid red);
//     Will render a 100x100.
//
// $width: Pixel value for width
// $height: Pixel value for height
// $padding: Padding accepts: 1px or 1px 2px or 1px 2px 3px 4px
// $border: Border, accepts 1px solid #000 or 1px or 1px 2px or 1px 2px 3px 4px
// 					When passing a border declaration (1px solid #000) it'll add the CSS for you.
@mixin size($width, $height:auto, $padding: none, $border:none) {
	// Prepare the borders, accept the following:
	//   1px solid #000 or 1px or 1px 2px or 1px 2px 3px 4px
	@if true {
		@if $border == none {
			$border:0;
		}

		$border-len: length($border);
	  // Standardize padding to a list with 4 items.
		@if $border-len == 3 {
			border:$border;
			$bw: nth($border, 1);
			$border: $bw $bw $bw $bw;
		} @else if $border-len == 1 {
			$border: $border $border $border $border;
		} @else if $border-len == 2 {
			$border: join($border, $border);
		}
	}

	// Prepare padding, accept the following:
	//   1px or 1px 2px or 1px 2px 3px 4px
	@if true {
		@if $padding == none {
			$padding:0;
		} @else {
			padding:$padding;
		}

	  // Standardize padding to a list with 4 items.
		$padding-len: length($padding);
		@if $padding-len == 1 {
			$padding: $padding $padding $padding $padding;
		} @else if $padding-len == 2 {
			$padding: join($padding, $padding);
		}
	}

	@if $width != auto {
		width: $width - (nth($padding, 2) + nth($padding, 4)) - (nth($border, 2) + nth($border, 4));
	}
	@if $height != auto {
		height: $height - (nth($padding, 1) + nth($padding, 3)) - (nth($border, 1) + nth($border, 3));
	}
}

// Float an element with a given width and a direction. Third parameter allows easy debugging.
// Yes, we override Compass :(
// @TODO: Make it use box-size and allow padding.
@mixin float($side, $size:auto, $debug-color:false) {
  @if $size != auto {
    @if length($size) == 1 {
      width:$size;
    } @else {
      height:nth($size, 2);
      width:nth($size, 1);
    }

  }
  @if in-compatibility-mode(ie6) {
    display:inline;
  }
  float: $side;
  @if $debug-color and $debug {
    @include debug($debug-color);
  }
}

@mixin transition($property: all, $time: 400ms, $easing: ease-out){
  transition: $property $time $easing;
  -moz-transition: $property $time $easing;
  -ms-transition: $property $time $easing;
  -o-transition: $property $time $easing;
  -webkit-transition: $property $time $easing;
}

// Calculate the Golden Ratio of a given value.
// ----------------------------------------
@function golden-ratio($size, $type) {
  $big   : round($size / 1.61803);
  $small : $size - $big;
  @return if($type == large, $big, $small);
}


//
// @TODO: Add docs to link-colors!
//
@mixin link-colors($normal, $hover: false, $active: false, $visited: false, $focus: false) {
  @if $normal == default {
    $hover: $link-hover-color;
    $normal: $link-color;
    $visited: $link-visited-color;
  }
  color: $normal;
  @if $visited {
    &:visited {
      color: $visited; } }
  @if $focus {
    &:focus {
      color: $focus; } }
  @if $hover {
    &:hover {
      color: $hover; } }
  @if $active {
    &:active {
      color: $active; } }
}

// Substract the Body to the Container width to get the sidebar.
@function sidebar($body-width, $container-width-over: false) {
  @if $container-width-over == false {
    $container-width-over : $container-width;
  }
  @return $container-width - $body-width;
}