modular-scale 2.1.1 → 3.0.0.alpha1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,29 @@
1
+ @function ms-pow($b,$e) {
2
+ @if function-exists('pow') {
3
+ @return pow($b,$e);
4
+ }
5
+
6
+ @if (floor($e) != $e) {
7
+ @error '
8
+ ======================================================================
9
+ Non-integer values are not supported in modularscale by default.
10
+
11
+ Try using mathsass in your project to add non-integer scale support.
12
+ https://github.com/terkel/mathsass
13
+ ======================================================================
14
+ '
15
+ }
16
+
17
+ $ms-return: $b;
18
+ @if $e > 0 {
19
+ @for $i from 1 to $e {
20
+ $ms-return: $ms-return * $b;
21
+ }
22
+ }
23
+ @if $e < 0 {
24
+ @for $i from $e through 0 {
25
+ $ms-return: $ms-return / $b;
26
+ }
27
+ }
28
+ @return $ms-return;
29
+ }
@@ -0,0 +1,41 @@
1
+ // Generate calc() function
2
+ @function ms-fluid($val1: 1em, $val2: 1em, $break1: 0, $break2: 0) {
3
+ $diff: ms-unitless($val2) - ms-unitless($val1);
4
+ @return calc( #{$val1} + #{ms-unitless($val2) - ms-unitless($val1)} * ( ( 100vw - #{$break1}) / #{ms-unitless($break2) - ms-unitless($break1)} ) );
5
+ }
6
+
7
+ // Main responsive mixin
8
+ @mixin ms-respond($prop, $val, $map: $modularscale) {
9
+ $base: $ms-base;
10
+ $ratio: $ms-ratio;
11
+
12
+ $first-write: true;
13
+ $last-break: null;
14
+
15
+ // loop through all settings with a breakpoint type value
16
+ @each $v, $s in $map {
17
+ @if type-of($v) == number {
18
+ @if unit($v) != '' {
19
+
20
+ @if $first-write {
21
+ #{$prop}: ms-function($val, $thread: $v, $settings: $map);
22
+ $first-write: false;
23
+ $last-break: $v;
24
+ }
25
+ @else {
26
+ @media (min-width: $last-break) and (max-width: $v) {
27
+ $val1: ms-function($val, $thread: $last-break, $settings: $map);
28
+ $val2: ms-function($val, $thread: $v, $settings: $map);
29
+ #{$prop}: ms-fluid($val1,$val2,$last-break,$v);
30
+ }
31
+ $last-break: $v;
32
+ }
33
+ }
34
+ }
35
+ }
36
+ @if $last-break {
37
+ @media (min-width: $last-break) {
38
+ #{$prop}: ms-function($val, $thread: $last-break, $settings: $map);
39
+ }
40
+ }
41
+ }
@@ -0,0 +1,6 @@
1
+ @function ms-round-px($r) {
2
+ @if unit($r) == 'px' {
3
+ @return round($r);
4
+ }
5
+ @return $r;
6
+ }
@@ -0,0 +1,33 @@
1
+ @function ms-settings($b: false, $r: false, $t: false, $m: $modularscale) {
2
+ $base: $ms-base;
3
+ $ratio: $ms-ratio;
4
+ $thread: map-get($m, $t);
5
+
6
+ // Override with user settings
7
+ @if map-get($m, base) {
8
+ $base: map-get($m, base);
9
+ }
10
+ @if map-get($m, ratio) {
11
+ $ratio: map-get($m, ratio);
12
+ }
13
+
14
+ // Override with thread settings
15
+ @if $thread {
16
+ @if map-get($thread, base) {
17
+ $base: map-get($thread, base);
18
+ }
19
+ @if map-get($thread, ratio) {
20
+ $ratio: map-get($thread, ratio);
21
+ }
22
+ }
23
+
24
+ // Override with inline settings
25
+ @if $b {
26
+ $base: $b;
27
+ }
28
+ @if $r {
29
+ $ratio: $r;
30
+ }
31
+
32
+ @return $base $ratio;
33
+ }
@@ -0,0 +1,18 @@
1
+ @function ms-sort($l) {
2
+
3
+ $sorted: false;
4
+ @while $sorted == false {
5
+ $sorted: true;
6
+ @for $i from 2 through length($l) {
7
+ $n1: nth($l,$i - 1);
8
+ $n2: nth($l,$i);
9
+ @if $n1 > $n2 {
10
+ $l: set-nth($l, $i, $n1);
11
+ $l: set-nth($l, $i - 1, $n2);
12
+ $sorted: false;
13
+ }
14
+ }
15
+ }
16
+
17
+ @return $l;
18
+ }
@@ -0,0 +1,8 @@
1
+ // Stripping units is not a best practice
2
+ // This function should not be used elsewhere
3
+ // It is used here because calc() doesn't do unit logic
4
+ // AND target ratios use units as a hack to get a number.
5
+ @function ms-unitless($val) {
6
+ $val: $val / ($val - $val + 1);
7
+ @return $val;
8
+ }
@@ -0,0 +1,3 @@
1
+ @function ms($v: 0, $base: false, $ratio: false, $thread: false, $settings: $modularscale) {
2
+ @return ms-function($v, $base, $ratio, $thread, $settings);
3
+ }
@@ -0,0 +1,37 @@
1
+ @function ms-target($t,$b) {
2
+
3
+ @if type-of($b) == 'list' {
4
+ @error 'Target ratios don’t work with multi-stranded modular scales.'
5
+ }
6
+
7
+ // target value
8
+ $v: ms-unitless($t);
9
+ // base
10
+ $b: ms-unitless($b);
11
+ // Target place on the scale the value should match
12
+ $t: str-slice(unit($t), 3);
13
+
14
+ // Convert strings into numbers...
15
+ @if $t == '0' { $t: 0; }
16
+ @if $t == '1' { $t: 1; }
17
+ @if $t == '2' { $t: 2; }
18
+ @if $t == '3' { $t: 3; }
19
+ @if $t == '4' { $t: 4; }
20
+ @if $t == '5' { $t: 5; }
21
+ @if $t == '6' { $t: 6; }
22
+ @if $t == '7' { $t: 7; }
23
+ @if $t == '8' { $t: 8; }
24
+ @if $t == '9' { $t: 9; }
25
+ @if $t == '10' { $t: 10; }
26
+ @if $t == '11' { $t: 11; }
27
+ @if $t == '12' { $t: 12; }
28
+ @if $t == '13' { $t: 13; }
29
+ @if $t == '14' { $t: 14; }
30
+
31
+ @if type-of($t) == 'string' {
32
+ @error 'Please select an integer between 0 and 14 for a target value in modular scale.'
33
+ }
34
+
35
+ // todo make this n root with n being $t
36
+ @return pow(($v/$b),(1/$t));
37
+ }
@@ -0,0 +1,12 @@
1
+ // Feature testing
2
+
3
+
4
+ // Test if the pow() function exists
5
+ @function ms-pow-exists() {
6
+ @if pow(4, 2) == 16 {
7
+ @return true;
8
+ }
9
+ @return false;
10
+ }
11
+
12
+ $ms-pow-exists: ms-pow-exists();
@@ -1,8 +1,6 @@
1
- // Golden ratio
2
- $phi : 1.618034 ;
3
- $golden : $phi ;
4
-
1
+ // Ratios
5
2
  $double-octave : 4 ;
3
+ $pi : 3.14159265359 ;
6
4
  $major-twelfth : 3 ;
7
5
  $major-eleventh : 2.666666667 ;
8
6
  $major-tenth : 2.5 ;
@@ -10,6 +8,8 @@ $octave : 2 ;
10
8
  $major-seventh : 1.875 ;
11
9
  $minor-seventh : 1.777777778 ;
12
10
  $major-sixth : 1.666666667 ;
11
+ $phi : 1.618034 ;
12
+ $golden : $phi ;
13
13
  $minor-sixth : 1.6 ;
14
14
  $fifth : 1.5 ;
15
15
  $augmented-fourth : 1.41421 ;
@@ -17,4 +17,9 @@ $fourth : 1.333333333 ;
17
17
  $major-third : 1.25 ;
18
18
  $minor-third : 1.2 ;
19
19
  $major-second : 1.125 ;
20
- $minor-second : 1.066666667 ;
20
+ $minor-second : 1.066666667 ;
21
+
22
+ // Base config
23
+ $ms-base : 1em !default;
24
+ $ms-ratio : $fifth !default;
25
+ $modularscale : () !default;
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: modular-scale
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 3.0.0.alpha1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Kellum
@@ -10,22 +10,22 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-12-20 00:00:00.000000000 Z
13
+ date: 2015-11-08 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: compass
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - '>='
19
+ - - ">="
20
20
  - !ruby/object:Gem::Version
21
- version: 0.12.0
21
+ version: 1.0.0
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
- - - '>='
26
+ - - ">="
27
27
  - !ruby/object:Gem::Version
28
- version: 0.12.0
28
+ version: 1.0.0
29
29
  description: |-
30
30
  A modular scale is a list of values that share the same relationship. These
31
31
  values are often used to size type and create a sense of harmony in a design. Proportions within
@@ -43,23 +43,22 @@ extra_rdoc_files:
43
43
  - license.md
44
44
  - readme.md
45
45
  files:
46
- - lib/modular-scale.rb
47
- - stylesheets/_modular-scale-tests.scss
48
- - stylesheets/_modular-scale.scss
49
- - stylesheets/modular-scale/_calc.scss
50
- - stylesheets/modular-scale/_function-list.scss
51
- - stylesheets/modular-scale/_function.scss
52
- - stylesheets/modular-scale/_generate-list.scss
53
- - stylesheets/modular-scale/_pow.scss
54
- - stylesheets/modular-scale/_ratios.scss
55
- - stylesheets/modular-scale/_respond.scss
56
- - stylesheets/modular-scale/_round-px.scss
57
- - stylesheets/modular-scale/_sort-list.scss
58
- - stylesheets/modular-scale/_tests.scss
59
- - stylesheets/modular-scale.zip
60
46
  - changelog.md
47
+ - lib/modular-scale.rb
61
48
  - license.md
62
49
  - readme.md
50
+ - stylesheets/_modularscale.scss
51
+ - stylesheets/modularscale/_function.scss
52
+ - stylesheets/modularscale/_pow.scss
53
+ - stylesheets/modularscale/_respond.scss
54
+ - stylesheets/modularscale/_round-px.scss
55
+ - stylesheets/modularscale/_settings.scss
56
+ - stylesheets/modularscale/_sort.scss
57
+ - stylesheets/modularscale/_strip-units.scss
58
+ - stylesheets/modularscale/_sugar.scss
59
+ - stylesheets/modularscale/_target.scss
60
+ - stylesheets/modularscale/_tests.scss
61
+ - stylesheets/modularscale/_vars.scss
63
62
  homepage: http://modularscale.com
64
63
  licenses:
65
64
  - MIT
@@ -70,17 +69,17 @@ require_paths:
70
69
  - lib
71
70
  required_ruby_version: !ruby/object:Gem::Requirement
72
71
  requirements:
73
- - - '>='
72
+ - - ">="
74
73
  - !ruby/object:Gem::Version
75
74
  version: '0'
76
75
  required_rubygems_version: !ruby/object:Gem::Requirement
77
76
  requirements:
78
- - - '>='
77
+ - - ">="
79
78
  - !ruby/object:Gem::Version
80
79
  version: 1.3.6
81
80
  requirements: []
82
81
  rubyforge_project:
83
- rubygems_version: 2.0.14
82
+ rubygems_version: 2.4.5
84
83
  signing_key:
85
84
  specification_version: 4
86
85
  summary: Modular scale calculator built into your Sass.
@@ -1,74 +0,0 @@
1
- @if "#{ms(2, 16, $minor-sixth)}" != "40.96" {
2
- @debug "";
3
- @warn "function ms(): FAIL!";
4
- @debug "function ms(2, 16, $minor-sixth)";
5
- @debug "Result: #{ms(2, 16, $minor-sixth)}";
6
- @debug "Intended: 40.96";
7
- @debug "";
8
- }@else {
9
- @warn "function ms(+): pass";
10
- }
11
-
12
- @if "#{ms(-2, 16, $minor-sixth)}" != "6.25" {
13
- @debug "";
14
- @warn "function ms(): FAIL!";
15
- @debug "function ms(-2, 16, $minor-sixth)";
16
- @debug "Result: #{ms(-2, 16, $minor-sixth)}";
17
- @debug "Intended: 6.25";
18
- @debug "";
19
- }@else {
20
- @warn "function ms(-): pass";
21
- }
22
-
23
- @if ms(2, 14 18, $major-second) != 15.75 {
24
- @debug "";
25
- @warn "function ms() multi-base: FAIL!";
26
- @debug "function ms(2, 14 18, $major-second)";
27
- @debug "Result: #{ms(2, 14 18, $major-second)}";
28
- @debug "Intended: 15.75";
29
- @debug "";
30
- }@else {
31
- @warn "function ms(+) multi-base: pass";
32
- }
33
-
34
- @if ms(-1, 14 18, $major-third) != 11.52 {
35
- @debug "";
36
- @warn "function ms() multi-base: FAIL!";
37
- @debug "function ms(-1, 14 18, $major-third)";
38
- @debug "Result: #{ms(-1, 14 18, $major-third)}";
39
- @debug "Intended: 11.52";
40
- @debug "";
41
- }@else {
42
- @warn "function ms(-) multi-base: pass";
43
- }
44
-
45
- @if "#{ms(-4, 12, $major-tenth $octave)}" != "1.92" {
46
- @debug "";
47
- @warn "function ms() multi-ratio: FAIL!";
48
- @debug "function ms(-4, 12, $major-tenth $octave)";
49
- @debug "Result: #{ms(-4, 12, $major-tenth $octave)}";
50
- @debug "Intended: 1.92";
51
- @debug "";
52
- }@else {
53
- @warn "function ms(+) multi-ratio: pass";
54
- }
55
-
56
- @if ms(-4, 12, $major-tenth $octave) != 1.92 {
57
- @debug "";
58
- @warn "function ms() multi-ratio: FAIL!";
59
- @debug "function ms(-4, 12, $major-tenth $octave)";
60
- @debug "Result: #{ms(-4, 12, $major-tenth $octave)}";
61
- @debug "Intended: 1.92";
62
- @debug "";
63
- }@else {
64
- @warn "function ms(-) multi-ratio: pass";
65
- }
66
-
67
- @if ms-list(-3, 3, 10 16, $major-third) != (6.5536 8 8.192 10 10.24 12.5 12.8) {
68
- @debug "function ms-list(): FAIL!";
69
- @warn "function ms-list(-3, 3, 10 16, $major-third)";
70
- @debug "Result: (#{ms-list(-3, 3, 10 16, $major-third)})";
71
- @debug "Intended: (6.5536 8 8.192 10 10.24 12.5 12.8)";
72
- }@else {
73
- @warn "function ms-list(): pass";
74
- }
@@ -1,18 +0,0 @@
1
- @import "modular-scale/ratios";
2
-
3
- $ms-base: 1em !default;
4
- $ms-ratio: $golden !default;
5
- $ms-range: null !default;
6
- $ms-fluid: true !default;
7
-
8
- @import "modular-scale/tests";
9
-
10
- @import "modular-scale/pow";
11
- @import "modular-scale/calc";
12
- @import "modular-scale/generate-list";
13
- @import "modular-scale/sort-list";
14
- @import "modular-scale/round-px";
15
- @import "modular-scale/function";
16
- @import "modular-scale/function-list";
17
-
18
- @import "modular-scale/respond";
Binary file
@@ -1,17 +0,0 @@
1
- @function ms-calc($Value, $Base: $ms-base, $Ratio: $ms-ratio) {
2
-
3
- // If pow exists use it.
4
- // It supports non-interger values!
5
- @if $MS-pow-exists {
6
-
7
- // The formula for figuring out modular scales is:
8
- // (r^v)*b
9
- @return pow($Ratio, $Value) * $Base;
10
- }
11
-
12
- // If not, use ms-pow().
13
- // Not as fast or capable of non-integer exponents.
14
- @else {
15
- @return ms-pow($Ratio, $Value) * $Base;
16
- }
17
- }