sass-aleksi 0.2.1 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 83216fd754d48f2ec46e12d93615f9de9d0fa14c
4
- data.tar.gz: 175cea34f5c09d95b63afcd8a4b6b83342a46686
3
+ metadata.gz: 4ecc2f15eaeaa381a0e4df10ed8fcfa7807b447f
4
+ data.tar.gz: 597d671e737e9e7eed2f2e30f91f75669912feb2
5
5
  SHA512:
6
- metadata.gz: 8ca2fb411c78025b29ad0db7437bcc8bcf76937565a77d55ea17ff10c9612534dabda7717f22474bc91b3b42f2163988b11f3a7190e87596624b02ce937472cc
7
- data.tar.gz: acb8a36fdc3af8b6149a04f942c0df9988f1cf09a7fabadd8a09a977d374c6de3ca21886f4955045251c565272ff75daa72787a5438ef22f5067a473fa8ff3c6
6
+ metadata.gz: c70dfea266ad88805b60cac835fdcf3315fb2ab62e98054fdb98253deb28b6566a3c717ceb674ef9d481ebca7f0ecaae94403a376d7ac7f429f45dbf224366af
7
+ data.tar.gz: 8351c0729ea4f9e34a50ac18975b251e0f1b757291adb8f034417763ff871f0b09696c46b2470e08863ae7b8cbaa751f5fa9f71bea377d471f90f72042203851
data/lib/sass-aleksi.rb CHANGED
@@ -26,6 +26,6 @@ end
26
26
  # Version is a number. If a version contains alphas, it will be created as a prerelease version
27
27
  # Date is in the form of YYYY-MM-DD
28
28
  module SassAleksi
29
- VERSION = "0.2.1"
30
- DATE = "2015-08-26"
29
+ VERSION = "0.2.2"
30
+ DATE = "2015-10-26"
31
31
  end
@@ -69,7 +69,7 @@ $CONSTANTS: () !default;
69
69
  @include throw-error('const():: Constant name #{inspect($name)} is not valid. Must be upper-case and without hyphens.');
70
70
  }
71
71
 
72
- @else if map-has-key($CONSTANTS, $name) and map-get($CONSANTS, $name) != $value {
72
+ @else if map-has-key($CONSTANTS, $name) and map-get($CONSTANTS, $name) != $value {
73
73
  @include throw-error('Constant #{inspect($name)} can not be redefined.');
74
74
  }
75
75
 
@@ -4,10 +4,49 @@
4
4
  //// @group aleksi-lengths
5
5
  //// @author [Chris Eppstein](http://chriseppstein.github.io/)
6
6
 
7
+ @import "aleksi/lengths/strip-unit";
8
+
9
+ // =default globals
10
+ // -----------------------------------------------------------------------------
11
+
7
12
  // Base font size in pixels, if not already defined.
8
- // Should be the same as the font-size of the html element.
13
+ // Should be the same as the font-size of the body element.
9
14
  $base-font-size: 16px !default;
10
15
 
16
+ // Root font size in pixels, if not already defined
17
+ // Should be the same as the font-size of the html element.
18
+ $root-font-size: $base-font-size !default;
19
+
20
+ // =convert-lengths( $values, $to-unit[, $from-context, $to-context ])
21
+ // -----------------------------------------------------------------------------
22
+ // Convert all lengths in given list or map. Doesn't try to convert none-number
23
+ // values in the list/map.
24
+ ///
25
+ /// @param {list|map} $values - A css list or map with lengths to convert
26
+ /// @param {string} $to-unit - A css unit keyword, e.g. 'em', '%', 'px', etc.
27
+ /// @param {number} $from-context [$base-font-size] - The absolute length (in px) to which `$length` refers
28
+ /// @param {number} $to-context [$from-context] - the absolute length in px to which the output value will refer.
29
+ ///
30
+ /// @access public
31
+ /// @since 0.2.2
32
+
33
+ @function convert-lengths($values, $to-unit, $from-context: $base-font-size, $to-context: $from-context)
34
+ {
35
+ $res: ();
36
+
37
+ @each $value in $values
38
+ {
39
+ // convert length values
40
+ @if type-of($value) == number {
41
+ $value: convert-length($value, $to-unit, $from-context, $to-context);
42
+ }
43
+
44
+ $res: append($res, $value);
45
+ }
46
+
47
+ @return $res;
48
+ }
49
+
11
50
  // =convert-length( $length, $to-unit[, $from-context, $to-context ])
12
51
  // -----------------------------------------------------------------------------
13
52
  /// Convert any CSS <length> or <percentage> value to any another.
@@ -31,9 +70,12 @@ $base-font-size: 16px !default;
31
70
  ) {
32
71
  $from-unit: unit($length);
33
72
 
34
- // Optimize for cases where `from` and `to` units are accidentally the same.
73
+ // Optimize for cases where `from` and `to` units are the same.
35
74
  @if $from-unit == $to-unit { @return $length; }
36
75
 
76
+ // 0 is always 0
77
+ @if (strip-unit($length) == 0) { @return 0; }
78
+
37
79
  // Context values must be in px so we can determine a conversion ratio for
38
80
  // relative units.
39
81
  @if unit($from-context) != 'px' { @warn "Paremeter $from-context must resolve to a value in pixel units."; }
@@ -45,7 +87,7 @@ $base-font-size: 16px !default;
45
87
  @if $from-unit != 'px' {
46
88
  // Convert relative units using the from-context parameter.
47
89
  @if $from-unit == 'em' { $px-length: $length * $from-context / 1em }
48
- @else if $from-unit == 'rem' { $px-length: $length * $base-font-size / 1rem }
90
+ @else if $from-unit == 'rem' { $px-length: $length * $root-font-size / 1rem }
49
91
  @else if $from-unit == '%' { $px-length: $length * $from-context / 100% }
50
92
  @else if $from-unit == 'ex' { $px-length: $length * $from-context / 2ex }
51
93
  // Convert absolute units using Sass' conversion table.
@@ -73,7 +115,7 @@ $base-font-size: 16px !default;
73
115
  @if $to-unit != 'px' {
74
116
  // Relative units
75
117
  @if $to-unit == 'em' { $output-length: $px-length * 1em / $to-context }
76
- @else if $to-unit == 'rem' { $output-length: $px-length * 1rem / $base-font-size }
118
+ @else if $to-unit == 'rem' { $output-length: $px-length * 1rem / $root-font-size }
77
119
  @else if $to-unit == '%' { $output-length: $px-length * 100% / $to-context }
78
120
  @else if $to-unit == 'ex' { $output-length: $px-length * 2ex / $to-context }
79
121
  // Absolute units
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sass-aleksi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoannis Jamar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-26 00:00:00.000000000 Z
11
+ date: 2015-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sass