rwdcalc 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/rwdcalc.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  Compass::Frameworks.register("rwdcalc", :path => "#{File.dirname(__FILE__)}/..")
2
2
 
3
3
  module RWDcalc
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.2"
5
5
  DATE = "2012-10-26"
6
6
  end
data/rwdcalc.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "rwdcalc"
5
- s.version = "0.0.1"
5
+ s.version = "0.0.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.3.5")
8
8
  s.authors = ["Stuart Robson", "Scott Kellum"]
@@ -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($target: $target, $values: 0) {
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 / $target), space);
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: $target, $context: $context, $margin: false, $padding: false, $border: false) {
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: percentage($target / $context);
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($target, $margin);
51
+ margin: rwdcalc($margin, $target);
48
52
  }
49
53
  @if $padding != false {
50
- padding: rwdcalc($target, $padding);
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($target, $border);
61
+ border-width: rwdcalc($border, $target);
58
62
  }
59
63
  @else {
60
- border: rwdcalc($target, $border) solid transparent;
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.1
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: 2012-10-26 00:00:00.000000000 Z
13
+ date: 2013-01-23 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: sass