typey 1.0.0.beta.5 → 1.0.0.beta.6

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.
@@ -1,25 +1,3 @@
1
- // Generate a value to be used as margin from either:
2
- // a) a multiple of $base-line-height
3
- // b) a static px or pt value
4
- //
5
- // Example usage with multiple:
6
- // margin: margin(2);
7
- // Example usage with static value:
8
- // margin: margin(18px);
9
- //
10
- // @param number $x
11
- // Multiple of line height to be used or px value to be converted.
12
- // @param number|string $context
13
- // (optional) Only used if em is the $base-unit. The value of the elements/parents
14
- // font-size if it differs from $base-font-size. Specified as a t-shirt size or
15
- // value in px.
16
- //
17
- // @return number
18
- // The calculated height in $base-unit.
19
- @function margin($x, $context: $base-font-size) {
20
- @return line-height($x, $context);
21
- }
22
-
23
1
  // Define margin (with fallback).
24
2
  // This is only necessary to use if you want to provide fallbacks when you are
25
3
  // using rem as $base-unit.
@@ -33,21 +11,28 @@
33
11
  // font-size if it differs from $base-font-size. Specified as a t-shirt size or
34
12
  // value in px.
35
13
  @mixin margin($list, $context: $base-font-size) {
14
+ $allowed-types: "multiplier", "px", "list";
15
+ $type: typey-validator($list, $allowed-types);
16
+
36
17
  $px-list: ();
37
18
  $converted-list: ();
19
+
38
20
  @each $x in $list {
39
21
  @if $base-unit == rem {
40
- @if type-of($x) == "number" and unitless($x) {
22
+ $allowed-types: "multiplier", "px";
23
+ $type: typey-validator($x, $allowed-types);
24
+ @if $type == "multiplier" {
41
25
  $margin: $x * $base-line-height;
42
26
  $px-list: join($px-list, $margin, $separator: space);
43
27
  }
44
- @if type-of($x) == "number" and not unitless($x) {
28
+ @if $type == "px" {
45
29
  $px-list: join($px-list, $x, $separator: space);
46
30
  }
47
31
  }
48
- $margin: line-height($x, $context);
32
+ $margin: margin($x, $context);
49
33
  $converted-list: join($converted-list, $margin, $separator: space);
50
34
  }
35
+
51
36
  @if $base-unit == rem {
52
37
  @if $rem-fallback == true {
53
38
  margin: $px-list;
@@ -67,17 +52,19 @@
67
52
  // font-size if it differs from $base-font-size. Specified as a t-shirt size or
68
53
  // value in px.
69
54
  @mixin margin-top($x, $context: $base-font-size) {
55
+ $allowed-types: "multiplier", "px";
56
+ $type: typey-validator($x, $allowed-types);
70
57
  @if $base-unit == rem {
71
58
  @if $rem-fallback == true {
72
- @if type-of($x) == "number" and unitless($x) {
59
+ @if $type == "multiplier" {
73
60
  margin-top: $x * $base-line-height;
74
61
  }
75
- @if type-of($x) == "number" and not unitless($x) {
62
+ @if $type == "px" {
76
63
  margin-top: $x;
77
64
  }
78
65
  }
79
66
  }
80
- margin-top: line-height($x, $context);
67
+ margin-top: margin($x, $context);
81
68
  }
82
69
 
83
70
  // Define margin-bottom (with fallback).
@@ -91,17 +78,19 @@
91
78
  // font-size if it differs from $base-font-size. Specified as a t-shirt size or
92
79
  // value in px.
93
80
  @mixin margin-bottom($x, $context: $base-font-size) {
81
+ $allowed-types: "multiplier", "px";
82
+ $type: typey-validator($x, $allowed-types);
94
83
  @if $base-unit == rem {
95
84
  @if $rem-fallback == true {
96
- @if type-of($x) == "number" and unitless($x) {
85
+ @if $type == "multiplier" {
97
86
  margin-bottom: $x * $base-line-height;
98
87
  }
99
- @if type-of($x) == "number" and not unitless($x) {
88
+ @if $type == "px" {
100
89
  margin-bottom: $x;
101
90
  }
102
91
  }
103
92
  }
104
- margin-bottom: line-height($x, $context);
93
+ margin-bottom: margin($x, $context);
105
94
  }
106
95
 
107
96
  // Define margin-left (with fallback).
@@ -115,17 +104,19 @@
115
104
  // font-size if it differs from $base-font-size. Specified as a t-shirt size or
116
105
  // value in px.
117
106
  @mixin margin-left($x, $context: $base-font-size) {
107
+ $allowed-types: "multiplier", "px";
108
+ $type: typey-validator($x, $allowed-types);
118
109
  @if $base-unit == rem {
119
110
  @if $rem-fallback == true {
120
- @if type-of($x) == "number" and unitless($x) {
111
+ @if $type == "multiplier" {
121
112
  margin-left: $x * $base-line-height;
122
113
  }
123
- @if type-of($x) == "number" and not unitless($x) {
114
+ @if $type == "px" {
124
115
  margin-left: $x;
125
116
  }
126
117
  }
127
118
  }
128
- margin-left: line-height($x, $context);
119
+ margin-left: margin($x, $context);
129
120
  }
130
121
 
131
122
  // Define margin-right (with fallback).
@@ -139,15 +130,17 @@
139
130
  // font-size if it differs from $base-font-size. Specified as a t-shirt size or
140
131
  // value in px.
141
132
  @mixin margin-right($x, $context: $base-font-size) {
133
+ $allowed-types: "multiplier", "px";
134
+ $type: typey-validator($x, $allowed-types);
142
135
  @if $base-unit == rem {
143
136
  @if $rem-fallback == true {
144
- @if type-of($x) == "number" and unitless($x) {
137
+ @if $type == "multiplier" {
145
138
  margin-right: $x * $base-line-height;
146
139
  }
147
- @if type-of($x) == "number" and not unitless($x) {
140
+ @if $type == "px" {
148
141
  margin-right: $x;
149
142
  }
150
143
  }
151
144
  }
152
- margin-right: line-height($x, $context);
145
+ margin-right: margin($x, $context);
153
146
  }
@@ -1,25 +1,3 @@
1
- // Generate a value to be used as padding from either:
2
- // a) a multiple of $base-line-height
3
- // b) a static px or pt value
4
- //
5
- // Example usage with multiple:
6
- // padding: padding(2);
7
- // Example usage with static value:
8
- // padding: padding(18px);
9
- //
10
- // @param number $x
11
- // Multiple of line height to be used or px value to be converted.
12
- // @param number|string $context
13
- // (optional) Only used if em is the $base-unit. The value of the elements/parents
14
- // font-size if it differs from $base-font-size. Specified as a t-shirt size or
15
- // value in px.
16
- //
17
- // @return number
18
- // The calculated height in $base-unit.
19
- @function padding($x, $context: $base-font-size) {
20
- @return line-height($x, $context);
21
- }
22
-
23
1
  // Define padding (with fallback).
24
2
  // This is only necessary to use if you want to provide fallbacks when you are
25
3
  // using rem as $base-unit.
@@ -33,21 +11,28 @@
33
11
  // font-size if it differs from $base-font-size. Specified as a t-shirt size or
34
12
  // value in px.
35
13
  @mixin padding($list, $context: $base-font-size) {
14
+ $allowed-types: "multiplier", "px", "list";
15
+ $type: typey-validator($list, $allowed-types);
16
+
36
17
  $px-list: ();
37
18
  $converted-list: ();
19
+
38
20
  @each $x in $list {
39
21
  @if $base-unit == rem {
40
- @if type-of($x) == "number" and unitless($x) {
22
+ $allowed-types: "multiplier", "px";
23
+ $type: typey-validator($x, $allowed-types);
24
+ @if $type == "multiplier" {
41
25
  $padding: $x * $base-line-height;
42
26
  $px-list: join($px-list, $padding, $separator: space);
43
27
  }
44
- @if type-of($x) == "number" and not unitless($x) {
28
+ @if $type == "px" {
45
29
  $px-list: join($px-list, $x, $separator: space);
46
30
  }
47
31
  }
48
- $padding: line-height($x, $context);
32
+ $padding: padding($x, $context);
49
33
  $converted-list: join($converted-list, $padding, $separator: space);
50
34
  }
35
+
51
36
  @if $base-unit == rem {
52
37
  @if $rem-fallback == true {
53
38
  padding: $px-list;
@@ -67,17 +52,19 @@
67
52
  // font-size if it differs from $base-font-size. Specified as a t-shirt size or
68
53
  // value in px.
69
54
  @mixin padding-top($x, $context: $base-font-size) {
55
+ $allowed-types: "multiplier", "px";
56
+ $type: typey-validator($x, $allowed-types);
70
57
  @if $base-unit == rem {
71
58
  @if $rem-fallback == true {
72
- @if type-of($x) == "number" and unitless($x) {
59
+ @if $type == "multiplier" {
73
60
  padding-top: $x * $base-line-height;
74
61
  }
75
- @if type-of($x) == "number" and not unitless($x) {
62
+ @if $type == "px" {
76
63
  padding-top: $x;
77
64
  }
78
65
  }
79
66
  }
80
- padding-top: line-height($x, $context);
67
+ padding-top: padding($x, $context);
81
68
  }
82
69
 
83
70
  // Define padding-bottom (with fallback).
@@ -91,17 +78,19 @@
91
78
  // font-size if it differs from $base-font-size. Specified as a t-shirt size or
92
79
  // value in px.
93
80
  @mixin padding-bottom($x, $context: $base-font-size) {
81
+ $allowed-types: "multiplier", "px";
82
+ $type: typey-validator($x, $allowed-types);
94
83
  @if $base-unit == rem {
95
84
  @if $rem-fallback == true {
96
- @if type-of($x) == "number" and unitless($x) {
85
+ @if $type == "multiplier" {
97
86
  padding-bottom: $x * $base-line-height;
98
87
  }
99
- @if type-of($x) == "number" and not unitless($x) {
88
+ @if $type == "px" {
100
89
  padding-bottom: $x;
101
90
  }
102
91
  }
103
92
  }
104
- padding-bottom: line-height($x, $context);
93
+ padding-bottom: padding($x, $context);
105
94
  }
106
95
 
107
96
  // Define padding-left (with fallback).
@@ -115,17 +104,19 @@
115
104
  // font-size if it differs from $base-font-size. Specified as a t-shirt size or
116
105
  // value in px.
117
106
  @mixin padding-left($x, $context: $base-font-size) {
107
+ $allowed-types: "multiplier", "px";
108
+ $type: typey-validator($x, $allowed-types);
118
109
  @if $base-unit == rem {
119
110
  @if $rem-fallback == true {
120
- @if type-of($x) == "number" and unitless($x) {
111
+ @if $type == "multiplier" {
121
112
  padding-left: $x * $base-line-height;
122
113
  }
123
- @if type-of($x) == "number" and not unitless($x) {
114
+ @if $type == "px" {
124
115
  padding-left: $x;
125
116
  }
126
117
  }
127
118
  }
128
- padding-left: line-height($x, $context);
119
+ padding-left: padding($x, $context);
129
120
  }
130
121
 
131
122
  // Define padding-right (with fallback).
@@ -139,15 +130,17 @@
139
130
  // font-size if it differs from $base-font-size. Specified as a t-shirt size or
140
131
  // value in px.
141
132
  @mixin padding-right($x, $context: $base-font-size) {
133
+ $allowed-types: "multiplier", "px";
134
+ $type: typey-validator($x, $allowed-types);
142
135
  @if $base-unit == rem {
143
136
  @if $rem-fallback == true {
144
- @if type-of($x) == "number" and unitless($x) {
137
+ @if $type == "multiplier" {
145
138
  padding-right: $x * $base-line-height;
146
139
  }
147
- @if type-of($x) == "number" and not unitless($x) {
140
+ @if $type == "px" {
148
141
  padding-right: $x;
149
142
  }
150
143
  }
151
144
  }
152
- padding-right: line-height($x, $context);
145
+ padding-right: padding($x, $context);
153
146
  }
@@ -0,0 +1,53 @@
1
+ // Define a type layout (font-size and line-height).
2
+ //
3
+ // @param number|string $size
4
+ // A size from the $font-size map or a px value.
5
+ // @param number $line-height
6
+ // Multiple of line height to be used or px value to be converted.
7
+ // @param number|string $context
8
+ // (optional) Only used if em is the $base-unit. The value of the
9
+ // elements/parents font-size if it differs from $base-font-size.
10
+ // Specified as a t-shirt size or value in px.
11
+ @mixin type-layout($size, $line-height: $base-line-height-ratio, $context: $size) {
12
+ $allowed-types-size: "font-size", "px";
13
+ $type-size: typey-validator($size, $allowed-types-size);
14
+
15
+ $allowed-types-lh: "multiplier", "px";
16
+ $type-lh: typey-validator($line-height, $allowed-types-lh);
17
+
18
+ @if $base-unit == rem {
19
+ @if $rem-fallback == true {
20
+ @if $type-size == "font-size" {
21
+ $map-size: map-get($font-size, $size);
22
+ font-size: $map-size;
23
+ }
24
+ @if $type-size == "px" {
25
+ font-size: $size;
26
+ }
27
+ }
28
+ @if $rem-fallback {
29
+ @if $type-lh == "multiplier" and $line-height-method == "rhythm" {
30
+ line-height: $line-height * $base-line-height;
31
+ }
32
+ @if $type-lh == "px" {
33
+ line-height: $line-height;
34
+ }
35
+ }
36
+ }
37
+
38
+ @if $base-unit == rem or $base-unit == px {
39
+ font-size: font-size($size);
40
+ line-height: line-height($line-height, $context);
41
+ }
42
+
43
+ @if $base-unit == em {
44
+ @if $size == $context {
45
+ font-size: font-size($size, $base-font-size);
46
+ line-height: line-height($line-height, $size);
47
+ }
48
+ @else {
49
+ font-size: font-size($size, $context);
50
+ line-height: line-height($line-height, $size);
51
+ }
52
+ }
53
+ }
data/typey.gemspec CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.homepage = 'http://github.com/jptaranto/typey'
9
9
  spec.rubyforge_project =
10
10
 
11
- spec.version = '1.0.0.beta.5'
12
- spec.date = '2015-07-06'
11
+ spec.version = '1.0.0.beta.6'
12
+ spec.date = '2015-08-05'
13
13
  spec.licenses = ['GPL-2']
14
14
 
15
15
  spec.authors = ['Jack Taranto']
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typey
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta.5
4
+ version: 1.0.0.beta.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jack Taranto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-06 00:00:00.000000000 Z
11
+ date: 2015-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sass
@@ -36,14 +36,20 @@ files:
36
36
  - stylesheets/_typey.scss
37
37
  - stylesheets/config.codekit
38
38
  - stylesheets/typey/_defaults.scss
39
- - stylesheets/typey/_font-size.scss
40
39
  - stylesheets/typey/_font-stacks.scss
41
- - stylesheets/typey/_helpers.scss
42
- - stylesheets/typey/_line-height.scss
43
- - stylesheets/typey/_margin.scss
44
- - stylesheets/typey/_padding.scss
45
- - stylesheets/typey/_type-layout.scss
46
- - stylesheets/typey/_weight.scss
40
+ - stylesheets/typey/functions/_depreciated.scss
41
+ - stylesheets/typey/functions/_em-calculators.scss
42
+ - stylesheets/typey/functions/_extras.scss
43
+ - stylesheets/typey/functions/_helpers.scss
44
+ - stylesheets/typey/functions/_outputters.scss
45
+ - stylesheets/typey/functions/_sizers.scss
46
+ - stylesheets/typey/functions/_validators.scss
47
+ - stylesheets/typey/mixins/_define-type-sizing.scss
48
+ - stylesheets/typey/mixins/_font-size.scss
49
+ - stylesheets/typey/mixins/_line-height.scss
50
+ - stylesheets/typey/mixins/_margin.scss
51
+ - stylesheets/typey/mixins/_padding.scss
52
+ - stylesheets/typey/mixins/_type-layout.scss
47
53
  - typey.gemspec
48
54
  homepage: http://github.com/jptaranto/typey
49
55
  licenses:
@@ -64,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
70
  - !ruby/object:Gem::Version
65
71
  version: 1.3.1
66
72
  requirements: []
67
- rubyforge_project: 1.0.0.beta.5
73
+ rubyforge_project: 1.0.0.beta.6
68
74
  rubygems_version: 2.4.6
69
75
  signing_key:
70
76
  specification_version: 4
@@ -1,56 +0,0 @@
1
- // Takes a sizing from the $font-size map (m, xl, xxl, etc) and convert it to
2
- // the base unit. Alternatively convert a px font-size into the base unit.
3
- //
4
- // @param number|string $size
5
- // A size from the $font-size map or px value to be converted
6
- // @param number|string $context
7
- // (optional) Only used if em is the $base-unit. The value of the parent
8
- // font-size if it differs from $base-font-size. Specified as a t-shirt size or
9
- // value in px.
10
- //
11
- // @return number
12
- // The selected font-size in $base-unit.
13
- @function font-size($size, $context: $base-font-size) {
14
- @if type-of($size) == "string" {
15
- @return output-from-font-size-map($size, $context);
16
- }
17
- @if type-of($size) == "number" and not unitless($size) {
18
- @if unit($size) == px {
19
- @return convert-unit($size, $context);
20
- }
21
- @else {
22
- @error "font-size() only accepts keys from the $font-size map or values in px";
23
- }
24
- }
25
- @else {
26
- @error "font-size() only accepts keys from the $font-size map or values in px";
27
- }
28
- }
29
-
30
- // Define font-size (with fallback)
31
- //
32
- // @param number|string $size
33
- // A size from the $font-size map or px value to be converted
34
- // @param number|string $context
35
- // (optional) Only used if em is the $base-unit. The value of the elements/parents
36
- // font-size if it differs from $base-font-size. Specified as a t-shirt size or
37
- // value in px.
38
- @mixin font-size($size, $context: $base-font-size) {
39
- @if $base-unit == rem {
40
- @if $rem-fallback == true {
41
- @if type-of($size) == "string" {
42
- $map-size: map-get($font-size, $size);
43
- font-size: $map-size;
44
- }
45
- @if type-of($size) == "number" and not unitless($size) {
46
- @if unit($size) == px {
47
- font-size: $size;
48
- }
49
- @else {
50
- @error "font-size() only accepts keys from the $font-size map or values in px";
51
- }
52
- }
53
- }
54
- }
55
- font-size: font-size($size, $context);
56
- }
@@ -1,171 +0,0 @@
1
- // Output a number in the $base-unit.
2
- //
3
- // @param number $number
4
- // The number (without unit) to output.
5
- //
6
- // @return number
7
- // The number with the base unit
8
- @function output-unit($number) {
9
- @if $base-unit == rem {
10
- @return $number * 1rem;
11
- }
12
- @if $base-unit == px {
13
- @return $number * 1px;
14
- }
15
- @if $base-unit == em {
16
- @return $number * 1em;
17
- }
18
- }
19
-
20
- // Remove the unit from a number.
21
- //
22
- // @param number $number
23
- // The number (with unit) to convert. Allowed units: any
24
- //
25
- // @return number
26
- // The number without the unit.
27
- @function strip-unit($number) {
28
- @if type-of($number) == "number" and not unitless($number) {
29
- @return $number / ($number * 0 + 1);
30
- }
31
- @return $number;
32
- }
33
-
34
- // Convert px to the $base-unit.
35
- //
36
- // @param number $number
37
- // The number (with unit) to convert. Allowed units: px
38
- // @param number|string $context
39
- // (optional) Only used if em is the $base-unit. The value of the elements/parents
40
- // font-size if it differs from $base-font-size. Specified as a t-shirt size or
41
- // value in px.
42
- //
43
- // @return number
44
- // The number converted to the base unit.
45
- @function convert-unit($number, $context: $base-font-size) {
46
- @if type-of($number) == "number" and not unitless($number) {
47
- $unit: unit($number);
48
- @if $unit == px {
49
- @if $base-unit == rem {
50
- @return output-unit(($number / $base-font-size));
51
- }
52
- @if $base-unit == px {
53
- @return output-unit(strip-unit($number));
54
- }
55
- @if $base-unit == em {
56
- @if type-of($context) == "string" {
57
- @if map-has-key($font-size, $context) {
58
- $context-map-size: map-get($font-size, $context);
59
- @return output-unit(($number / $context-map-size));
60
- }
61
- @else {
62
- @error "'#{$context}' not found in $font-size map";
63
- }
64
- }
65
- @if type-of($context) == "number" and not unitless($number) {
66
- @if unit($context) == px {
67
- @return output-unit(($number / $context));
68
- }
69
- @else {
70
- @error "The unit used for $context must be px";
71
- }
72
- }
73
- }
74
- }
75
- @else {
76
- @error "convert-unit() only accepts values in px";
77
- }
78
- }
79
- }
80
-
81
- // Take a line-height multipler and output converted value.
82
- //
83
- // @param number $number
84
- // Multiple of line height to be used
85
- // @param number|string $context
86
- // (optional) Only used if em is the $base-unit. The value of the elements/parents
87
- // font-size if it differs from $base-font-size. Specified as a t-shirt size or
88
- // value in px.
89
- //
90
- // @return number
91
- // The value of the line-height multiple converted to the base unit.
92
- @function output-from-multiplier($x, $context: $base-font-size) {
93
- @if $base-unit == rem {
94
- @return output-unit(($x * $base-line-height) / $base-font-size);
95
- }
96
- @if $base-unit == px {
97
- @return output-unit(strip-unit($x * $base-line-height));
98
- }
99
- @if $base-unit == em {
100
- @if type-of($context) == "number" {
101
- @if unit($context) == px {
102
- @return output-unit(($x * $base-line-height) / $context);
103
- }
104
- @else {
105
- @error "The unit used for $context must be px";
106
- }
107
- }
108
- @if type-of($context) == "string" {
109
- @if map-has-key($font-size, $context) {
110
- $context-map-size: map-get($font-size, $context);
111
- @return output-unit(($x * $base-line-height) / $context-map-size);
112
- }
113
- @else {
114
- @error "'#{$context}' not found in $font-size map";
115
- }
116
- }
117
- @else {
118
- @error "$context must be a px value or a key from the $font-size map";
119
- }
120
- }
121
- }
122
-
123
-
124
- // Takes a sizing from the $font-size map (m, xl, xxl, etc) and convert it to
125
- // the base unit.
126
- //
127
- // @param string $size
128
- // A size from the $font-size map.
129
- // @param number|string $context
130
- // (optional) Only used if em is the $base-unit. The value of the parent
131
- // font-size if it differs from $base-font-size. Specified as a t-shirt size or
132
- // value in px.
133
- //
134
- // @return number
135
- // The selected font-size in $base-unit.
136
- @function output-from-font-size-map($size, $context: $base-font-size) {
137
- @if map-has-key($font-size, $size) {
138
- $map-size: map-get($font-size, $size);
139
- @if $base-unit == rem {
140
- @return output-unit(($map-size / $base-font-size));
141
- }
142
- @if $base-unit == px or $base-unit == pt {
143
- @return output-unit(strip-unit($map-size));
144
- }
145
- @if $base-unit == em {
146
- @if type-of($context) == "string" {
147
- @if map-has-key($font-size, $context) {
148
- $context-map-size: map-get($font-size, $context);
149
- @return output-unit(($map-size / $context-map-size));
150
- }
151
- @else {
152
- @error "'#{$context}' not found in $font-size map";
153
- }
154
- }
155
- @if type-of($context) == "number" {
156
- @if unit($context) == px {
157
- @return output-unit(($map-size / $context));
158
- }
159
- @else {
160
- @error "The unit used for $context must be px";
161
- }
162
- }
163
- @else {
164
- @error "$context must be a px value or a key from the $font-size map";
165
- }
166
- }
167
- }
168
- @else {
169
- @error "'#{$size}' not found in $font-size map";
170
- }
171
- }