type-heading 0.0.14 → 0.0.16
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 +4 -4
- data/README.md +73 -2
- data/stylesheets/_type-heading.scss +4 -4
- data/stylesheets/type-heading/api/_core.scss +72 -0
- data/stylesheets/type-heading/api/_deprecated.scss +136 -0
- data/stylesheets/type-heading/{functions → api}/_helpers.scss +71 -0
- data/stylesheets/type-heading/functions/_heading.scss +13 -16
- data/stylesheets/type-heading/functions/_property.scss +35 -219
- data/stylesheets/type-heading/mixins/_breakpoint.scss +28 -5
- data/stylesheets/type-heading/mixins/_heading.scss +128 -18
- data/stylesheets/type-heading/mixins/_property.scss +13 -185
- metadata +5 -5
- data/stylesheets/type-heading/functions/_core.scss +0 -73
- data/stylesheets/type-heading/mixins/_core.scss +0 -154
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33d892948aa82bbbbd404f813ee2ed00b32f692a
|
4
|
+
data.tar.gz: d2eaa745522f8bba1f82a7569363a3844dc75fbc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9dc900247f490a30d084486d845eef0f304f72393f396b65b0386868e81568331acf3916045b1e613ba748ae304ef50b935c52cb836e3caceba8c4cf60b3375e
|
7
|
+
data.tar.gz: c4d382587e1a8ae5f2b01fef9356634bffbbd6f441d78ccce3f3b129b45f74479b16adebd7a52ef497e6bef3341fd12b415e55e97ad2bbaf158b8d7c1cbae21e
|
data/README.md
CHANGED
@@ -5,6 +5,77 @@
|
|
5
5
|
Type Heading is a lightweight Compass Extension that lets you easily manage
|
6
6
|
responsive typographic sizing.
|
7
7
|
|
8
|
+
```sass
|
9
|
+
// Define Headings
|
10
|
+
$th-headings: (
|
11
|
+
h1: (32px 36px, 36px 42px default 768px),
|
12
|
+
h2: (28px 32px, 30px 34px default 768px),
|
13
|
+
h3: (24px 30px)
|
14
|
+
);
|
15
|
+
|
16
|
+
// Output Headings
|
17
|
+
h1 { @include th-headings(h1); }
|
18
|
+
|
19
|
+
// h1 {
|
20
|
+
// margin-top: 20px;
|
21
|
+
// margin-bottom: 20px;
|
22
|
+
// font-size: 32px;
|
23
|
+
// line-height: 36px;
|
24
|
+
// }
|
25
|
+
//
|
26
|
+
// @media (min-width: 768px) {
|
27
|
+
// h1 {
|
28
|
+
// margin-top: 20px;
|
29
|
+
// margin-bottom: 20px;
|
30
|
+
// font-size: 36px;
|
31
|
+
// line-height: 42px;
|
32
|
+
// }
|
33
|
+
// }
|
34
|
+
|
35
|
+
// Return properties
|
36
|
+
$font-size-tablet: th-property(font-size, h1, 768px);
|
37
|
+
// 36px
|
38
|
+
|
39
|
+
// Output properties
|
40
|
+
.my-component { @include th-property(font-size, h1); }
|
41
|
+
|
42
|
+
// .my-component {
|
43
|
+
// font-size: 32px
|
44
|
+
// }
|
45
|
+
|
46
|
+
// Unit Conversion
|
47
|
+
$th-property-units: (
|
48
|
+
font-size: percent,
|
49
|
+
line-height: rel,
|
50
|
+
margin-top: em,
|
51
|
+
margin-bottom: em
|
52
|
+
);
|
53
|
+
|
54
|
+
h3 { @include th-headings(h3); }
|
55
|
+
|
56
|
+
// h3 {
|
57
|
+
// margin-top: 0.83333em;
|
58
|
+
// margin-bottom: 0.83333em;
|
59
|
+
// font-size: 150%;
|
60
|
+
// line-height: 1.25;
|
61
|
+
// }
|
62
|
+
|
63
|
+
// Advanced:
|
64
|
+
// Using contextual properties:
|
65
|
+
|
66
|
+
h1 {
|
67
|
+
@include th-heading-context(h1) {
|
68
|
+
$heading: th-core-context-get(heading);
|
69
|
+
font-size: th-property(font-size, $heading);
|
70
|
+
}
|
71
|
+
}
|
72
|
+
|
73
|
+
// h1 {
|
74
|
+
// font-size: 32px;
|
75
|
+
// font-size: 36px
|
76
|
+
// }
|
77
|
+
```
|
78
|
+
|
8
79
|
## Libsass Compatible
|
9
80
|
|
10
81
|
Ruby is fucking slow as fuck and I hate it. Type heading is 100% (or will try to
|
@@ -15,9 +86,9 @@ be) compatible with Libsass.
|
|
15
86
|
Reference or change any heading size throughout your stylesheets from a single
|
16
87
|
variable. Now you don't have to try and remember what the font size of your h3 is!
|
17
88
|
|
18
|
-
##
|
89
|
+
## Responsive Typography Made Easy
|
19
90
|
|
20
|
-
Headings are
|
91
|
+
Headings are structured by breakpoint, giving you the power to quickly find the
|
21
92
|
right heading size for the right media query.
|
22
93
|
|
23
94
|
## Simple Unit Conversion
|
@@ -4,11 +4,11 @@
|
|
4
4
|
// ------------------------------
|
5
5
|
|
6
6
|
@import "type-heading/settings";
|
7
|
-
@import "type-heading/
|
8
|
-
@import "type-heading/
|
9
|
-
@import "type-heading/mixins/core";
|
7
|
+
@import "type-heading/api/helpers";
|
8
|
+
@import "type-heading/api/core";
|
10
9
|
@import "type-heading/functions/heading";
|
11
10
|
@import "type-heading/functions/property";
|
12
11
|
@import "type-heading/mixins/breakpoint";
|
13
12
|
@import "type-heading/mixins/property";
|
14
|
-
@import "type-heading/mixins/heading";
|
13
|
+
@import "type-heading/mixins/heading";
|
14
|
+
@import "type-heading/api/deprecated";
|
@@ -0,0 +1,72 @@
|
|
1
|
+
////
|
2
|
+
/// Core
|
3
|
+
/// @group Core
|
4
|
+
////
|
5
|
+
|
6
|
+
$_th-core-heading-structure: (
|
7
|
+
font-size,
|
8
|
+
line-height,
|
9
|
+
(margin-top margin-bottom),
|
10
|
+
breakpoint
|
11
|
+
);
|
12
|
+
|
13
|
+
// $_th-core-contexts
|
14
|
+
/// Global values to keep track of contexts.
|
15
|
+
///
|
16
|
+
/// @since 0.0.15
|
17
|
+
/// @type map
|
18
|
+
/// @access private
|
19
|
+
///
|
20
|
+
/// @prop {boolean | list} base.heading [false] - Contextual heading list
|
21
|
+
/// @prop {boolean \ number} base.heading [false] - Contextual breakpoint
|
22
|
+
|
23
|
+
$_th-core-contexts: (
|
24
|
+
heading: false,
|
25
|
+
breakpoint: false
|
26
|
+
);
|
27
|
+
|
28
|
+
// th-core-context-get()
|
29
|
+
/// Check and get contextual value from globals.
|
30
|
+
///
|
31
|
+
/// @since 0.0.15
|
32
|
+
/// @return {mixed} Contextual value from globals or passed value.
|
33
|
+
///
|
34
|
+
/// @param {string} $context - [heading | breakpoint] Context property.
|
35
|
+
/// @param {mixed} $value - The original value of the context property.
|
36
|
+
///
|
37
|
+
/// @example scss - Return contextual breakpoint value.
|
38
|
+
/// _th-core-context-get(breakpoint, 768px)
|
39
|
+
/// // 1024px
|
40
|
+
|
41
|
+
@function th-core-context-get(
|
42
|
+
$context,
|
43
|
+
$value: false
|
44
|
+
){
|
45
|
+
@if global_variable_exists('_th-core-contexts') and map-get($_th-core-contexts, $context) {
|
46
|
+
@return map-get($_th-core-contexts, $context);
|
47
|
+
} @else {
|
48
|
+
@return $value;
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
// th-core-context-set()
|
53
|
+
/// Set contextual value to globals.
|
54
|
+
///
|
55
|
+
/// @since 0.0.15
|
56
|
+
/// @content [Output with context]
|
57
|
+
///
|
58
|
+
/// @param {string} $context - [heading | breakpoint] Context property.
|
59
|
+
/// @param {mixed} $value - The new value of the context property.
|
60
|
+
///
|
61
|
+
/// @example scss - Set contextual breakpoint value.
|
62
|
+
/// _th-core-context-set(breakpoint, 768px)
|
63
|
+
|
64
|
+
@mixin th-core-context-set(
|
65
|
+
$context,
|
66
|
+
$value
|
67
|
+
){
|
68
|
+
$cache: $_th-core-contexts;
|
69
|
+
$_th-core-contexts: th-map-set($_th-core-contexts, $context, $value) !global;
|
70
|
+
@content;
|
71
|
+
$_th-core-contexts: $cache !global;
|
72
|
+
}
|
@@ -0,0 +1,136 @@
|
|
1
|
+
////
|
2
|
+
/// Deprecated API.
|
3
|
+
/// @group Deprecated
|
4
|
+
/// @access private
|
5
|
+
////
|
6
|
+
|
7
|
+
@function th-property-font-size(
|
8
|
+
$heading,
|
9
|
+
$breakpoint: false,
|
10
|
+
$convert: true,
|
11
|
+
$base-font-size: $th-base-font-size
|
12
|
+
){
|
13
|
+
@warn "th-property-font-size() will be removed in next major release. Use th-property() instead.";
|
14
|
+
@return th-property(
|
15
|
+
$heading: $heading,
|
16
|
+
$property-name: font-size,
|
17
|
+
$breakpoint: $breakpoint,
|
18
|
+
$convert: $convert,
|
19
|
+
$base-font-size: $base-font-size
|
20
|
+
);
|
21
|
+
}
|
22
|
+
|
23
|
+
@function th-property-line-height(
|
24
|
+
$heading,
|
25
|
+
$breakpoint: false,
|
26
|
+
$base-font-size: th-property-font-size($heading, $breakpoint, false),
|
27
|
+
$convert: true
|
28
|
+
){
|
29
|
+
@warn "th-property-line-height() will be removed in next major release. Use th-property() instead.";
|
30
|
+
@return th-property(
|
31
|
+
$heading: $heading,
|
32
|
+
$property-name: line-height,
|
33
|
+
$breakpoint: $breakpoint,
|
34
|
+
$convert: $convert,
|
35
|
+
$base-font-size: _th-property-base($heading, $breakpoint, $base-font-size)
|
36
|
+
);
|
37
|
+
}
|
38
|
+
|
39
|
+
@function th-property-margin-top(
|
40
|
+
$heading,
|
41
|
+
$breakpoint: false,
|
42
|
+
$base-font-size: th-property-font-size($heading, $breakpoint, false),
|
43
|
+
$convert: true
|
44
|
+
){
|
45
|
+
@warn "th-property-margin-top() will be removed in next major release. Use th-property() instead.";
|
46
|
+
@return th-property(
|
47
|
+
$heading: $heading,
|
48
|
+
$property-name: margin-top,
|
49
|
+
$breakpoint: $breakpoint,
|
50
|
+
$convert: $convert,
|
51
|
+
$base-font-size: _th-property-base($heading, $breakpoint, $base-font-size)
|
52
|
+
);
|
53
|
+
}
|
54
|
+
|
55
|
+
@function th-property-margin-bottom(
|
56
|
+
$heading,
|
57
|
+
$breakpoint: false,
|
58
|
+
$base-font-size: th-property-font-size($heading, $breakpoint, false),
|
59
|
+
$convert: true
|
60
|
+
){
|
61
|
+
@warn "th-property-margin-bottom() will be removed in next major release. Use th-property() instead.";
|
62
|
+
@return th-property(
|
63
|
+
$heading: $heading,
|
64
|
+
$property-name: margin-bottom,
|
65
|
+
$breakpoint: $breakpoint,
|
66
|
+
$convert: $convert,
|
67
|
+
$base-font-size: _th-property-base($heading, $breakpoint, $base-font-size)
|
68
|
+
);
|
69
|
+
}
|
70
|
+
|
71
|
+
@mixin th-property-font-size(
|
72
|
+
$heading,
|
73
|
+
$breakpoint: false,
|
74
|
+
$convert: true,
|
75
|
+
$base-font-size: $th-base-font-size
|
76
|
+
){
|
77
|
+
@warn "th-property-font-size() will be removed in next major release. Use th-property() instead.";
|
78
|
+
@include th-property(
|
79
|
+
$property-name: font-size,
|
80
|
+
$heading: $heading,
|
81
|
+
$breakpoint: $breakpoint,
|
82
|
+
$convert: $convert,
|
83
|
+
$base-font-size: $base-font-size
|
84
|
+
);
|
85
|
+
}
|
86
|
+
|
87
|
+
@mixin th-property-line-height(
|
88
|
+
$heading,
|
89
|
+
$breakpoint: false,
|
90
|
+
$convert: true,
|
91
|
+
$base-font-size: $th-base-font-size
|
92
|
+
){
|
93
|
+
@warn "th-property-line-height() will be removed in next major release. Use th-property() instead.";
|
94
|
+
$base-font-size: _th-property-base($heading, $breakpoint, $base-font-size);
|
95
|
+
@include th-property(
|
96
|
+
$property-name: line-height,
|
97
|
+
$heading: $heading,
|
98
|
+
$breakpoint: $breakpoint,
|
99
|
+
$convert: $convert,
|
100
|
+
$base-font-size: $base-font-size
|
101
|
+
);
|
102
|
+
}
|
103
|
+
|
104
|
+
@mixin th-property-margin-top(
|
105
|
+
$heading,
|
106
|
+
$breakpoint: false,
|
107
|
+
$convert: true,
|
108
|
+
$base-font-size: $th-base-font-size
|
109
|
+
){
|
110
|
+
@warn "th-property-margin-top() will be removed in next major release. Use th-property() instead.";
|
111
|
+
$base-font-size: _th-property-base($heading, $breakpoint, $base-font-size);
|
112
|
+
@include th-property(
|
113
|
+
$property-name: margin-top,
|
114
|
+
$heading: $heading,
|
115
|
+
$breakpoint: $breakpoint,
|
116
|
+
$convert: $convert,
|
117
|
+
$base-font-size: $base-font-size
|
118
|
+
);
|
119
|
+
}
|
120
|
+
|
121
|
+
@mixin th-property-margin-bottom(
|
122
|
+
$heading,
|
123
|
+
$breakpoint: false,
|
124
|
+
$convert: true,
|
125
|
+
$base-font-size: $th-base-font-size
|
126
|
+
){
|
127
|
+
@warn "th-property-margin-bottom() will be removed in next major release. Use th-property() instead.";
|
128
|
+
$base-font-size: _th-property-base($heading, $breakpoint, $base-font-size);
|
129
|
+
@include th-property(
|
130
|
+
$property-name: margin-bottom,
|
131
|
+
$heading: $heading,
|
132
|
+
$breakpoint: $breakpoint,
|
133
|
+
$convert: $convert,
|
134
|
+
$base-font-size: $base-font-size
|
135
|
+
);
|
136
|
+
}
|
@@ -90,6 +90,48 @@
|
|
90
90
|
@return $_return;
|
91
91
|
}
|
92
92
|
|
93
|
+
// Maps
|
94
|
+
// ------------------------------
|
95
|
+
|
96
|
+
// th-map-set()
|
97
|
+
/// Set a map key with a new value.
|
98
|
+
///
|
99
|
+
/// @since 0.0.15
|
100
|
+
/// @return {map} Map with new property
|
101
|
+
///
|
102
|
+
/// @param {map} $map - The map/haystack of values.
|
103
|
+
/// @param {string} $key - The key/needle used to find value.
|
104
|
+
/// @param {$value} $value - The new value of the map key.
|
105
|
+
///
|
106
|
+
/// @example scss - Set map key 'foo' to 'Hello World'
|
107
|
+
/// th-map-set(
|
108
|
+
/// (
|
109
|
+
/// foo: 'First',
|
110
|
+
/// bar: 'Second'
|
111
|
+
/// ),
|
112
|
+
/// $key: foo,
|
113
|
+
/// $value: 'Hello Word'
|
114
|
+
/// )
|
115
|
+
/// // (
|
116
|
+
/// // foo: 'Hello World',
|
117
|
+
/// // bar: 'Second'
|
118
|
+
/// // )
|
119
|
+
|
120
|
+
@function th-map-set(
|
121
|
+
$map,
|
122
|
+
$key,
|
123
|
+
$value
|
124
|
+
){
|
125
|
+
$_return: ();
|
126
|
+
@each $item in $map {
|
127
|
+
@if nth($item, 1) != $key {
|
128
|
+
$_return: map-merge($_return, (nth($item, 1): nth($item, 2)));
|
129
|
+
}
|
130
|
+
}
|
131
|
+
$_return: map-merge($_return, ($key: $value));
|
132
|
+
@return $_return;
|
133
|
+
}
|
134
|
+
|
93
135
|
// Lists
|
94
136
|
// ------------------------------
|
95
137
|
|
@@ -243,6 +285,35 @@
|
|
243
285
|
@return $_return;
|
244
286
|
}
|
245
287
|
|
288
|
+
// th-list-flatten()
|
289
|
+
/// Turns multidimensional `$list` into a one-level list.
|
290
|
+
///
|
291
|
+
/// @since 0.0.15
|
292
|
+
/// @link https://github.com/at-import/SassyLists/blob/master/stylesheets/SassyLists/_flatten.scss
|
293
|
+
/// @return {list} Flattened one-level list.
|
294
|
+
///
|
295
|
+
/// @param {list} $list - Multidimensional list to flatten
|
296
|
+
///
|
297
|
+
/// @example scss - Flatten multidimensional list.
|
298
|
+
/// th-list-flatten(a, b, (c, d))
|
299
|
+
/// // (a, b, c, d)
|
300
|
+
|
301
|
+
@function th-list-flatten($list) {
|
302
|
+
$result: ();
|
303
|
+
@each $item in $list {
|
304
|
+
@if length($item) > 1 {
|
305
|
+
$flatten: th-list-flatten($item);
|
306
|
+
@each $i in $flatten {
|
307
|
+
$result: append($result, $i, list-separator($list));
|
308
|
+
}
|
309
|
+
}
|
310
|
+
@else {
|
311
|
+
$result: append($result, $item, list-separator($list));
|
312
|
+
}
|
313
|
+
}
|
314
|
+
@return $result;
|
315
|
+
}
|
316
|
+
|
246
317
|
// Units
|
247
318
|
// ------------------------------
|
248
319
|
|
@@ -24,9 +24,11 @@
|
|
24
24
|
$heading,
|
25
25
|
$breakpoint: false
|
26
26
|
){
|
27
|
-
$breakpoint:
|
27
|
+
$breakpoint: th-core-context-get(breakpoint, $breakpoint);
|
28
28
|
$heading: th-heading-get-map($heading);
|
29
|
-
|
29
|
+
@if _th-heading-has-next($heading) {
|
30
|
+
$heading: _th-heading-get-next($heading, $breakpoint);
|
31
|
+
}
|
30
32
|
@return $heading;
|
31
33
|
}
|
32
34
|
|
@@ -107,8 +109,8 @@
|
|
107
109
|
@if $breakpoint {
|
108
110
|
@each $heading-list in $heading {
|
109
111
|
@if th-property(
|
110
|
-
$heading: $heading-list,
|
111
112
|
$property-name: breakpoint,
|
113
|
+
$heading: $heading-list,
|
112
114
|
$convert: false) == $breakpoint {
|
113
115
|
$heading: $heading-list;
|
114
116
|
}
|
@@ -119,22 +121,17 @@
|
|
119
121
|
@return $heading;
|
120
122
|
}
|
121
123
|
|
122
|
-
//
|
123
|
-
///
|
124
|
-
///
|
125
|
-
/// @since 0.0.14
|
126
|
-
/// @access private
|
127
|
-
/// @return {mixed} Returns heading list if available.
|
124
|
+
// th-h()
|
125
|
+
/// Alias to th-heading() function.
|
128
126
|
///
|
129
|
-
/// @
|
130
|
-
/// @param {number} $breakpoint [false] - A heading list breakpoint.
|
127
|
+
/// @since 0.0.15
|
131
128
|
|
132
|
-
@function
|
129
|
+
@function th-h(
|
133
130
|
$heading,
|
134
131
|
$breakpoint: false
|
135
132
|
){
|
136
|
-
@
|
137
|
-
$heading:
|
138
|
-
|
139
|
-
|
133
|
+
@return th-heading(
|
134
|
+
$heading: $heading,
|
135
|
+
$breakpoint: $breakpoint
|
136
|
+
)
|
140
137
|
}
|