type-heading 0.0.13 → 0.0.14

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: baff6ecab89578b4bf058a21e8769b0addcf3e54
4
- data.tar.gz: cd43b78e2651ee84c5611bc32b77f89b1dadf519
3
+ metadata.gz: ba4a423c88bb3a9181e6f699b9ba8ee5be9a92bf
4
+ data.tar.gz: a203207d96590ba085502dba03a7c0c1fdb2bffa
5
5
  SHA512:
6
- metadata.gz: 066ba92a26378c2de1d4f56925634d2ace28be17793c26f4444fe152d10104fe553be0bc9b64588893857a1d190048eb9dca577b2b2f5d72fc40b3dd1ea95ee9
7
- data.tar.gz: 6fed2c309e2797103f11d634342d1ad017b7829d7c3fda0811cb3e0c4c01ef9c0da36e3be41b050aa9e64fc2caa18b4612bea5e09779bca48058447dda7e9224
6
+ metadata.gz: 3cafac27b260505b72a2f3e31497fdc1326687c819c1460b0e414bb2eaf67105be6f35125c75b9645f2ea825839b3bb574e47158b227167fa9d59d47051a3f2c
7
+ data.tar.gz: cbfff014a83078b8ea361b94f5f944e0c19de38b4adbffb3f294b763ffa672795e30a3f39569f0ad82dbd73ba1a37859828ba9ea406434026212f2c3d18269e6
data/README.md CHANGED
@@ -1,21 +1,37 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/type-heading.svg)](http://badge.fury.io/rb/type-heading)
2
2
 
3
- # Type Heading - BETA
3
+ # Type Heading
4
4
 
5
- A responsive typography tool.
5
+ Type Heading is a lightweight Compass Extension that lets you easily manage
6
+ responsive typographic sizing.
6
7
 
7
- Type heading is currently in **BETA**. It should only be used for testing and/or
8
- development, not production work.
8
+ ## Libsass Compatible
9
9
 
10
- ## Requirements
10
+ Ruby is fucking slow as fuck and I hate it. Type heading is 100% (or will try to
11
+ be) compatible with Libsass.
11
12
 
12
- To use Type Heading, you will need at least:
13
+ ## Organised & Maintainable
13
14
 
14
- - Ruby: 2.1.5
15
- - Sass 3.3.13
16
- - Compass 1.0.1
15
+ Reference or change any heading size throughout your stylesheets from a single
16
+ variable. Now you don't have to try and remember what the font size of your h3 is!
17
17
 
18
- ## Get Started
18
+ ## Reponsive Typography Made Easy
19
19
 
20
- * [Github](https://github.com/ellioseven/type-heading)
21
- * [Documentation](http://ellioseven.github.io/type-heading/)
20
+ Headings are stuctured by breakpoint, giving you the power to quickly find the
21
+ right heading size for the right media query.
22
+
23
+ ## Simple Unit Conversion
24
+
25
+ Working with relative units can be tricky. Fortunately Type Heading can convert
26
+ px values into relative units, so you can stay you away from any tricky math.
27
+
28
+ ## License
29
+
30
+ Type Heading uses the [MIT license](http://en.wikipedia.org/wiki/MIT_License)
31
+ and always will.
32
+
33
+ ## Contributing
34
+
35
+ You can make Type Heading better! If you find a bug, please [create an
36
+ issue](https://github.com/ellioseven/type-heading/issues) or
37
+ [provide a pull request](https://github.com/ellioseven/type-heading/pulls).
@@ -1,29 +1,49 @@
1
- // Settings
2
- //
3
- // @group Settings
4
- // @author Elliot Mitchum
1
+ ////
2
+ /// Settings
3
+ /// @group Config
4
+ ////
5
5
 
6
- // th-base-font-size
7
- // Font size used for relative calculations.
8
- //
9
- // @since 0.0.10
10
- // @type string
6
+ // $th-base-font-size
7
+ /// Font size used for relative calculations.
8
+ ///
9
+ /// @since 0.0.10
10
+ /// @type Number
11
11
 
12
12
  $th-base-font-size: 16px !default;
13
13
 
14
- // th-headings
15
- // Define headings and their values.
16
- //
17
- // @since 0.0.10
18
- // @type map
14
+ // $th-rem-base
15
+ /// Font size base for calculating rem units.
16
+ ///
17
+ /// @since 0.0.14
18
+ /// @type Number
19
+
20
+ $th-rem-base: $th-base-font-size !default;
21
+
22
+ // $th-headings
23
+ /// Sets of headings.
24
+ ///
25
+ /// @since 0.0.10
26
+ /// @type Map
27
+ ///
28
+ /// @example scss - Defining a few sets of headings.
29
+ /// $th-headings: (
30
+ /// h1: (32px 38px 20px, 38px 42px 30px 768px),
31
+ /// h2: (24px 30px, 32px 36px default 768px),
32
+ /// h3: (18px 24px (10px 20px), 21px 26px 30px 768px)
33
+ /// );
19
34
 
20
35
  $th-headings: () !default;
21
36
 
22
- // th-property-defaults
23
- // Define default property values.
24
- //
25
- // @since 0.0.10
26
- // @type map
37
+ // $th-property-defaults
38
+ /// Default property values for headings.
39
+ ///
40
+ /// @since 0.0.10
41
+ /// @type Map
42
+ ///
43
+ /// @prop {number} font-size [16px] - Default font size for headings
44
+ /// @prop {number} line-height [24px] - Default line height for headings
45
+ /// @prop {number} margin-top [20px] - Default margin top for headings
46
+ /// @prop {number} margin-bottom [20px] - Default margin bottom for headings
27
47
 
28
48
  $th-property-defaults: (
29
49
  font-size: 16px,
@@ -32,11 +52,24 @@ $th-property-defaults: (
32
52
  margin-bottom: 20px
33
53
  ) !default;
34
54
 
35
- // th-property-defaults
36
- // Define units for heading properties.
37
- //
38
- // @since 0.0.11
39
- // @type map
55
+ // $th-property-defaults
56
+ /// Units for heading properties.
57
+ ///
58
+ /// @since 0.0.11
59
+ /// @type Map
60
+ ///
61
+ /// @prop {boolean | string} font-size [false] - (px | em | rem | rel | percent) - Unit conversion for font sizes.
62
+ /// @prop {boolean | string} line-height [false] - (px | em | rem | rel | percent) - Unit conversion for line heights.
63
+ /// @prop {boolean | string} margin-top [false] - (px | em | rem | rel | percent) - Unit conversion for top margins.
64
+ /// @prop {boolean | string} margin-bottom [false] - (px | em | rem | rel | percent) - Unit conversion for bottom margins.
65
+ ///
66
+ /// @example scss - Defining units for heading properties.
67
+ /// $th-property-units: (
68
+ /// font-size: percent,
69
+ /// line-height: rel,
70
+ /// margin-top: em,
71
+ /// margin-bottom: em
72
+ /// )
40
73
 
41
74
  $th-property-units: (
42
75
  font-size: false,
@@ -1,38 +1,73 @@
1
- // Breakpoint
2
- //
3
- // @group Functions / Core
4
- // @author Elliot Mitchum
5
-
6
- // _th-core-global-breakpoint
7
- // Allows breakpoint override for sections of code.
8
- //
9
- // @since 0.0.12
10
- // @type Number
11
- // @access private
12
-
13
- $_th-core-global-breakpoint: false !default;
14
-
15
- // _th-core-global-breakpoint
16
- // Returns global breakpoint property.
17
- //
18
- // @since 0.0.12
19
- // @type function
20
- // @access private
21
- // @group breakpoint
22
- //
23
- // @param {number} $breakpoint A heading list breakpoint (required).
24
- //
25
- // @returns {Number} The breakpoint parameter.
26
- //
27
- // @example scss Return $th-breakpoint-global parameter.
28
- // // $breakpoint: _th-core-global-breakpoint($breakpoint);
29
-
30
- @function _th-core-global-breakpoint(
1
+ ////
2
+ /// Core
3
+ /// @group Core
4
+ ////
5
+
6
+ // $_th-core-breakpoint-context
7
+ /// Global breakpoint variable for various mixins and functions.
8
+ ///
9
+ /// @since 0.0.12
10
+ /// @type Bool | Number
11
+ /// @access private
12
+
13
+ $_th-core-breakpoint-context: false !default;
14
+
15
+ // $_th-core-with
16
+ /// Map of heading property values within a th-with loop.
17
+ ///
18
+ /// @since 0.0.14
19
+ /// @see {function} th-with
20
+ /// @type Map
21
+ /// @access private
22
+
23
+ $_th-core-with: () !default;
24
+
25
+ // $_th-core-properties
26
+ /// List of available heading property names.
27
+ ///
28
+ /// @since 0.0.14
29
+ /// @type List
30
+ /// @access private
31
+
32
+ $_th-core-properties: (margin-top margin-bottom font-size line-height);
33
+
34
+ // _th-core-breakpoint-context()
35
+ /// Return either contextual breakpoint if set or current breakpoint value.
36
+ ///
37
+ /// @since 0.0.12
38
+ /// @return {number} Current or contextual breakpoint.
39
+ ///
40
+ /// @param {number} $breakpoint - A heading breakpoint.
41
+
42
+ @function _th-core-breakpoint-context(
31
43
  $breakpoint
32
44
  ){
33
- @if global-variable-exists('_th-core-global-breakpoint') and $_th-core-global-breakpoint {
34
- @return $_th-core-global-breakpoint;
45
+ @if global-variable-exists('_th-core-breakpoint-context') and $_th-core-breakpoint-context {
46
+ @return $_th-core-breakpoint-context;
35
47
  } @else {
36
48
  @return $breakpoint;
37
49
  }
50
+ }
51
+
52
+ // th-with-get()
53
+ /// Return a heading property value within a th-with loop.
54
+ ///
55
+ /// @since 0.0.14
56
+ /// @see {mixin} th-with
57
+ /// @return {number} Heading property value.
58
+ ///
59
+ /// @param {string} $property-name - Name of the heading property to return.
60
+ ///
61
+ /// @example scss - Return font size from within a th-with loop.
62
+ /// @include th-with(h1) {
63
+ /// font-size: th-with-get(font-size);
64
+ /// }
65
+ /// // font-size: 18px;
66
+
67
+ @function th-with-get(
68
+ $property-name
69
+ ){
70
+ @if $_th-core-with {
71
+ @return map-get($_th-core-with, $property-name);
72
+ }
38
73
  }
@@ -1,131 +1,108 @@
1
- // Heading
2
- //
3
- // @group Functions / Heading
4
- // @author Elliot Mitchum
1
+ ////
2
+ /// Heading
3
+ /// @group Heading
4
+ ////
5
5
 
6
- // th-heading
7
- // Return a heading list.
8
- //
9
- // @since 0.0.10
10
- // @type function
11
- //
12
- // @requires {function} th-heading-get-map
13
- // @requires {function} _th-heading-has-next
14
- // @requires {function} _th-heading-get-next
15
- // @requires {function} _th-core-global-breakpoint
16
- //
17
- // @param {list | string} $heading A heading map key or list (required).
18
- // @param {number} $breakpoint A heading list breakpoint.
19
- //
20
- // @returns {list} A heading list.
21
- //
22
- // @example scss Return a heading list.
23
- // // // h1: (10px 20px (30px 40px), 50px 60px (70px 80px) 768px)
24
- // // th-heading(h1)
25
- // // // 10px 20px (30px 40px)
26
- // // @example scss Return a heading list with breakpoint.
27
- // // // h1: (10px 20px (30px 40px), 50px 60px (70px 80px) 768px)
28
- // // th-heading(h1, 768px)
29
- // // // 50px 60px (70px 80px) 768px
6
+ // th-heading()
7
+ /// Return a heading list. The first heading list will be returned
8
+ /// if no breakpoint is specified.
9
+ ///
10
+ /// @since 0.0.10
11
+ /// @return {list} A heading list.
12
+ ///
13
+ /// @param {list | string} $heading - A heading map key or list.
14
+ /// @param {number} $breakpoint [false] - A heading list breakpoint.
15
+ ///
16
+ /// @example scss Return a heading list.
17
+ /// th-heading(h1)
18
+ /// // (10px 20px (30px 40px)
19
+ /// @example scss Return a heading list with breakpoint.
20
+ /// th-heading(h1, 768px)
21
+ /// // 50px 60px (70px 80px) 768px
30
22
 
31
23
  @function th-heading(
32
24
  $heading,
33
25
  $breakpoint: false
34
26
  ){
35
- $_return: $heading;
36
- $breakpoint: _th-core-global-breakpoint($breakpoint);
37
- @if string == type-of($heading) {
38
- $_return: th-heading-get-map($heading);
39
- @if _th-heading-has-next($_return) {
40
- $_return: _th-heading-get-next($_return, $breakpoint);
41
- }
42
- }
43
- @return $_return;
27
+ $breakpoint: _th-core-breakpoint-context($breakpoint);
28
+ $heading: th-heading-get-map($heading);
29
+ $heading: _th-heading-maybe-next($heading, $breakpoint);
30
+ @return $heading;
44
31
  }
45
32
 
46
- // th-heading-get-map
47
- // Return a heading map.
48
- //
49
- // @since 0.0.10
50
- // @type function
51
- //
52
- // @param {string} $heading A heading map key (required).
53
- //
54
- // @returns {list} A heading map.
55
- //
56
- // @example scss Return h1 heading map.
57
- // // // h1: (10px 20px (30px 40px), 50px 60px (70px 80px) 768px)
58
- // // th-heading-get-map(h1)
59
- // // // 10px 20px (30px 40px), 50px 60px (70px 80px) 768px
33
+ // th-heading-get-map()
34
+ /// Return a heading map.
35
+ ///
36
+ /// @since 0.0.10
37
+ /// @return {list} A heading map.
38
+ ///
39
+ /// @param {string} $heading - A heading map key.
40
+ ///
41
+ /// @example scss - Return h1 heading map.
42
+ /// th-heading-get-map(h1)
43
+ /// // 10px 20px (30px 40px), 50px 60px (70px 80px) 768px
60
44
 
61
45
  @function th-heading-get-map(
62
46
  $heading
63
47
  ){
64
- $_return: $heading;
65
48
  @if string == type-of($heading) and map-has-key($th-headings, $heading) {
66
- $_return: map-get($th-headings, $heading);
49
+ $heading: map-get($th-headings, $heading);
67
50
  }
68
- @return $_return;
51
+ @return $heading;
69
52
  }
70
53
 
71
- // _th-heading-has-next
72
- // Check a for multiple heading lists.
73
- //
74
- // @since 0.0.10
75
- // @type function
76
- // @access private
77
- //
78
- // @requires {function} th-heading-get-map
79
- //
80
- // @param {list | string} $heading A heading map key or list (required).
81
- //
82
- // @returns {boolean} If heading map contains multiple lists.
83
- //
84
- // @example scss Check heading with next.
85
- // // // h1: (10px 20px (30px 40px), 50px 60px (70px 80px) 768px)
86
- // // _th-heading-has-next(h1)
87
- // // // true
88
- // @example scss Check heading without next.
89
- // // // h5: (10px 20px (30px 40px))
90
- // // _th-heading-has-next(h5)
91
- // // // false
54
+ // _th-heading-has-next()
55
+ /// Check a for multiple heading lists.
56
+ ///
57
+ /// @since 0.0.10
58
+ /// @access private
59
+ /// @return {boolean} If heading has next or not.
60
+ ///
61
+ /// @param {list | string} $heading - A heading map key or list.
62
+ ///
63
+ /// @example
64
+ /// 4 + 2 = 8
65
+ /// 4 / 2 = 2
66
+ ///
67
+ /// @example scss - Check heading with next.
68
+ /// // h1: (10px 20px (30px 40px), 50px 60px (70px 80px) 768px)
69
+ /// _th-heading-has-next(h1)
70
+ /// // true
71
+ /// @example scss - Check heading without next.
72
+ /// // h2: (10px 20px (30px 40px))
73
+ /// _th-heading-has-next(h2)
74
+ /// // false
92
75
 
93
76
  @function _th-heading-has-next(
94
77
  $heading
95
78
  ){
96
- $_return: false;
97
79
  $heading: th-heading-get-map($heading);
98
- @if list-separator($heading) == comma {
99
- $_return: true;
80
+ @if list-separator($heading) == comma {
81
+ @return true;
82
+ } @else {
83
+ @return false;
100
84
  }
101
- @return $_return;
102
85
  }
103
86
 
104
- // _th-heading-get-next
105
- // Return a heading list by breakpoint.
106
- //
107
- // @since 0.0.10
108
- // @type function
109
- // @access private
110
- //
111
- // @requires {function} th-heading-get-map
112
- // @requires {function} th-property
113
- //
114
- // @param {list | string} $heading A heading map key or list (required).
115
- // @param {boolean | number} $breakpoint (false) A heading list breakpoint.
116
- //
117
- // @returns {list} Heading list.
118
- //
119
- // @example scss Return h1 heading map.
120
- // // // h1: (10px 20px (30px 40px), 50px 60px (70px 80px) 768px)
121
- // // _th-heading-get-next(h1, 768px)
122
- // // // 50px 60px (70px 80px) 768px
87
+ // _th-heading-get-next()
88
+ /// Return a heading list by breakpoint.
89
+ ///
90
+ /// @since 0.0.10
91
+ /// @access private
92
+ /// @return {list} A heading list.
93
+ ///
94
+ /// @param {list | string} $heading - A heading map key or list.
95
+ /// @param {number} $breakpoint [false] - A heading list breakpoint.
96
+ ///
97
+ /// @example scss - Return h1 heading map.
98
+ /// // h1: (10px 20px (30px 40px), 50px 60px (70px 80px) 768px)
99
+ /// _th-heading-get-next(h1, 768px)
100
+ /// // 50px 60px (70px 80px) 768px
123
101
 
124
102
  @function _th-heading-get-next(
125
103
  $heading,
126
104
  $breakpoint: false
127
105
  ){
128
- $_return: $heading;
129
106
  $heading: th-heading-get-map($heading);
130
107
  @if $breakpoint {
131
108
  @each $heading-list in $heading {
@@ -133,11 +110,31 @@
133
110
  $heading: $heading-list,
134
111
  $property-name: breakpoint,
135
112
  $convert: false) == $breakpoint {
136
- $_return: $heading-list;
113
+ $heading: $heading-list;
137
114
  }
138
115
  }
139
116
  } @else {
140
- $_return: nth($heading, 1);
117
+ $heading: nth($heading, 1);
118
+ }
119
+ @return $heading;
120
+ }
121
+
122
+ // _th-heading-maybe-next()
123
+ /// Check and get a heading list from a heading map key.
124
+ ///
125
+ /// @since 0.0.14
126
+ /// @access private
127
+ /// @return {mixed} Returns heading list if available.
128
+ ///
129
+ /// @param {list | string} $heading - A heading map key or list.
130
+ /// @param {number} $breakpoint [false] - A heading list breakpoint.
131
+
132
+ @function _th-heading-maybe-next(
133
+ $heading,
134
+ $breakpoint: false
135
+ ){
136
+ @if _th-heading-has-next($heading) {
137
+ $heading: _th-heading-get-next($heading, $breakpoint);
141
138
  }
142
- @return $_return;
139
+ @return $heading;
143
140
  }