rwdcalc 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rwdcalc.rb +1 -1
- data/rwdcalc.gemspec +1 -1
- data/stylesheets/_rwdcalc.scss +18 -14
- metadata +2 -2
data/lib/rwdcalc.rb
CHANGED
data/rwdcalc.gemspec
CHANGED
data/stylesheets/_rwdcalc.scss
CHANGED
@@ -1,8 +1,3 @@
|
|
1
|
-
// Setup defaults
|
2
|
-
$target: 960 !default;
|
3
|
-
$context: 960 !default;
|
4
|
-
|
5
|
-
|
6
1
|
// Just drop this in if you feel like having box-sizing: border-box.
|
7
2
|
@mixin border-box {
|
8
3
|
* {
|
@@ -13,7 +8,10 @@ $context: 960 !default;
|
|
13
8
|
}
|
14
9
|
|
15
10
|
// RWDcalc function converts unitless values to a % of context.
|
16
|
-
@function rwdcalc($
|
11
|
+
@function rwdcalc($values: 0, $context: 960px) {
|
12
|
+
@if unit($context) == px {
|
13
|
+
$context: $context / 1px;
|
14
|
+
}
|
17
15
|
|
18
16
|
// start with an empty list of values.
|
19
17
|
$list: ();
|
@@ -23,7 +21,7 @@ $context: 960 !default;
|
|
23
21
|
|
24
22
|
// If the value has no unit, consider it a px-% converstion
|
25
23
|
@if unit($value) == "" {
|
26
|
-
$list: append($list, percentage($value / $
|
24
|
+
$list: append($list, percentage($value / $context), space);
|
27
25
|
}
|
28
26
|
|
29
27
|
// Else pass the value back to the list unchanged.
|
@@ -36,28 +34,34 @@ $context: 960 !default;
|
|
36
34
|
@return $list;
|
37
35
|
}
|
38
36
|
|
39
|
-
@mixin rwdcalc($target:
|
37
|
+
@mixin rwdcalc($target: 0, $context: 960px, $margin: false, $padding: false, $border: false) {
|
38
|
+
@if unit($context) == px {
|
39
|
+
$context: $context / 1px;
|
40
|
+
}
|
41
|
+
@if unit($target) == px {
|
42
|
+
$target: $target / 1px;
|
43
|
+
}
|
40
44
|
|
41
45
|
// Width is a straight converstion of target/context.
|
42
|
-
width:
|
43
|
-
|
46
|
+
width: rwdcalc($target, $context);
|
47
|
+
|
44
48
|
// Margin, padding, and border get converted to % if they are passed in as a unitless value.
|
45
49
|
@if $margin != false {
|
46
50
|
// just pull in the rwdcalc function for these.
|
47
|
-
margin: rwdcalc($
|
51
|
+
margin: rwdcalc($margin, $target);
|
48
52
|
}
|
49
53
|
@if $padding != false {
|
50
|
-
padding: rwdcalc($
|
54
|
+
padding: rwdcalc($padding, $target);
|
51
55
|
}
|
52
56
|
@if $border != false {
|
53
57
|
@if type-of($border) == list {
|
54
58
|
// Transparent border so metrics get written by default.
|
55
59
|
border: 0 solid transparent;
|
56
60
|
// Write width overrides:
|
57
|
-
border-width: rwdcalc($
|
61
|
+
border-width: rwdcalc($border, $target);
|
58
62
|
}
|
59
63
|
@else {
|
60
|
-
border: rwdcalc($
|
64
|
+
border: rwdcalc($border, $target) solid transparent;
|
61
65
|
}
|
62
66
|
}
|
63
67
|
}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rwdcalc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2013-01-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: sass
|