sane-scale 0.6 → 0.7

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: 967cb2dd85d7c6ad70bc08983405aa7593acbea1
4
- data.tar.gz: ee44b4ea907f18b8e16c9f6756426b0d23b7aef9
3
+ metadata.gz: a1bb5f7d45547764726f6369ca98765ff1abf34a
4
+ data.tar.gz: d35f636c7d80f015b24c14af2c149779d7c00651
5
5
  SHA512:
6
- metadata.gz: ac337138bc6f33566991fa2f942bb893b82579f4a6c86a2f2a010f3867ab1f744bddf65d4aa9ccd17ced090d50592df44637249e3e87e02f4dd149d36e3f0c86
7
- data.tar.gz: d7480ffec32e0666831e93831b1745ae4a144f4d7644829ce4f87039d89508dd26ae28c05212c8514b9426a3706bbb025b9867359830d7f45ffa82026aad06a2
6
+ metadata.gz: 1c1819cbd107757e984104e02bf416d8bd1a17905038c85a32d0d8fd21b51e235088055d0ba8e8ff1f4f868cb60cc891eb354af3e40239cbe66945cf41df6bfe
7
+ data.tar.gz: a32b58f27053436c14bb2a8b0e016212df0f369812cb5d4fabd35ad75fbad258c2913ca0991bded7abf5199fdc1627139e4ef57a3c5c9b932550bc8843b1ed4e
data/README.md CHANGED
@@ -71,7 +71,8 @@ $typography: ss-build-typography((
71
71
 
72
72
  // Define your font scales and their constraints.
73
73
  "scales": (
74
- // Phone sizes.
74
+
75
+ // Phone sizes
75
76
  "default": (
76
77
  "base-font-size": 16px,
77
78
  "base-line-height": 1.5,
@@ -79,7 +80,7 @@ $typography: ss-build-typography((
79
80
  "max-line-height": 1.35
80
81
  ),
81
82
 
82
- // Tablet sizes and larger.
83
+ // Tablet sizes and larger
83
84
  "tablet": (
84
85
  "media-query": "screen and (min-width: 768px)",
85
86
  "base-font-size": 18px,
@@ -123,7 +124,7 @@ We just applied responsive styling to the lead paragraph style. It will use medi
123
124
  @include ss-set-responsive-font-size($font-verdana, 1);
124
125
  }
125
126
  ```
126
- We used the same size for the `.h4` heading, but with `$font-verdana`. That will result in a font-size of 16.4px by default and 19.8px for tablets and larger. Mathematically different, but visually equal.
127
+ We used the same size for the `.h4` heading, but with `$font-verdana`. This will result in a font-size of 16.4px by default and 19.8px for tablets and larger. Mathematically different, but visually equal.
127
128
 
128
129
 
129
130
 
@@ -140,7 +141,51 @@ You might occassionally want finer-grained control of your type styles. For thes
140
141
  Here we just styled our h4 to have the size 1 for only the tablet breakpoint. With `ss-set-responsive-font-size()` the corresponding sizes for each other breakpoint would have also been applied.
141
142
 
142
143
 
143
- ### Working with uppercase
144
+ ## Advanced Usage
145
+
146
+ ### Rounding
147
+
148
+ Rounding to any precision is supported.
149
+
150
+ ```scss
151
+ $typography: ss-build-typography((
152
+
153
+ // Define your font scales and their constraints.
154
+ "scales": (
155
+
156
+ // Phone sizes
157
+ "default": (
158
+ "base-font-size": 16px,
159
+ "base-line-height": 1.5,
160
+ "max-font-size": 28px,
161
+ "max-line-height": 1.35,
162
+ "font-size-precision": 0.1,
163
+ "line-height-precision: 0.01
164
+ ),
165
+
166
+ // ...
167
+ ));
168
+ ```
169
+
170
+ ### Solid and tight line-height
171
+
172
+ Oftentimes you may need to set very narrow lines of text, causing your line-height to look too loose. For a tighter line-height, use the `"line-height": "tight"` option.
173
+
174
+ ```scss
175
+ .caption-tight {
176
+ @include ss-set-responsive-font-size($font-verdana, -1, opts: ("line-height": "tight"));
177
+ }
178
+ ```
179
+
180
+ Other times you may want to set text to be solid (meaning no "leading"). In terms of CSS, this setting the line-height to be equal to the font-size. To do this, use the `"line-height": "solid"` option.
181
+
182
+ ```scss
183
+ .btn {
184
+ @include ss-set-responsive-font-size($font-verdana, 1, opts: ("line-height": "solid"));
185
+ }
186
+ ```
187
+
188
+ ### Uppercase styles
144
189
 
145
190
  If you'd like to set something in all caps and have it align to your font scales, include an `uppercase-adjustment` when defining fonts:
146
191
 
@@ -151,12 +196,12 @@ $font-verdana: (
151
196
  "line-height-adjustment": 0.94,
152
197
  "uppercase-adjustment": 0.85
153
198
  );
154
- ``
199
+ ```
155
200
 
156
- Apply the uppercase style like so:
201
+ Apply an uppercase style like so:
157
202
  ```scss
158
203
  .h4 {
159
- @include ss-set-responsive-font-size($font-verdana, 1, $uppercase: true);
204
+ @include ss-set-responsive-font-size($font-verdana, 1, opts: ("uppercase": true));
160
205
  }
161
206
  ```
162
207
 
data/lib/sane-scale.rb CHANGED
@@ -17,8 +17,8 @@ Compass::Frameworks.register('sane-scale', :path => extension_path)
17
17
  # version contains alphas, it will be created as a
18
18
  # prerelease version. Date is in the form of YYYY-MM-DD
19
19
  module SaneScale
20
- VERSION = "0.6"
21
- DATE = "2016-07-17"
20
+ VERSION = "0.7"
21
+ DATE = "2016-08-07"
22
22
  end
23
23
 
24
24
  # This is where any custom SassScript should be placed. The functions will be
@@ -5,4 +5,6 @@
5
5
 
6
6
  $typography: ss-build-typography() !default;
7
7
 
8
+ @import "sane-scale/round";
8
9
  @import "sane-scale/set-font-size";
10
+
@@ -10,13 +10,11 @@
10
10
  "base-line-height": 1.5,
11
11
  "max-font-size": 28px,
12
12
  "max-line-height": 1.35,
13
- "round-under": null,
14
13
  "numb-smaller-sizes": 1,
15
14
  "numb-larger-sizes": 4
16
15
  ), $opts);
17
16
 
18
-
19
- // Create font-size and line-height scales
17
+ // Create font-size scale
20
18
  $font-size-scale: ss-build-scale((
21
19
  "base-value": map-get($opts, "base-font-size"),
22
20
  "max-value": map-get($opts, "max-font-size"),
@@ -24,13 +22,14 @@
24
22
  "numb-larger-values": map-get($opts, "numb-larger-sizes")
25
23
  ));
26
24
 
25
+ // Create line-height scale
27
26
  $line-height-scale: ss-build-scale((
28
27
  "base-value": map-get($opts, "base-line-height"),
29
28
  "max-value": map-get($opts, "max-line-height"),
30
29
  "numb-smaller-values": map-get($opts, "numb-smaller-sizes"),
31
30
  "numb-larger-values": map-get($opts, "numb-larger-sizes")
32
31
  ));
33
-
32
+
34
33
  $sizes: ();
35
34
 
36
35
  // Pair each size with the correponding font-size
@@ -45,11 +44,11 @@
45
44
 
46
45
  // Values for size
47
46
  $values: (
48
- font-size: nth($font-size-scale, $arr-position),
49
- line-height: nth($line-height-scale, $arr-position)
47
+ "font-size": nth($font-size-scale, $arr-position),
48
+ "line-height": nth($line-height-scale, $arr-position)
50
49
  );
51
50
 
52
- // Merge into $font-scale.
51
+ // Add to size array.
53
52
  $sizes: map-merge($sizes, ($name-of-size: $values));
54
53
  }
55
54
 
@@ -0,0 +1,8 @@
1
+
2
+ // Round a value to any precision
3
+
4
+ @function ss-round($value: 1.0, $precision: 1.0) {
5
+ $scale: 1 / $precision;
6
+ $result: round($value * $scale) / $scale;
7
+ @return $result;
8
+ }
@@ -3,37 +3,81 @@
3
3
  ******************************************************/
4
4
 
5
5
  // Apply styles for a specific font, breakpoint, and size.
6
- @mixin ss-apply-font-styles($font, $size, $scale-name, $uppercase: false) {
6
+ @mixin ss-apply-font-styles($font, $size, $scale-name, $opts: ()) {
7
+
8
+ // Extend default opts
9
+ $opts: map-merge((
10
+ "uppercase": false,
11
+ "line-height": "normal"
12
+ ), $opts);
13
+
14
+ // FONT SIZE
15
+ // Get and apply adjustments.
7
16
 
8
- // Get font-size and apply adjustments.
9
17
  $unadjusted-font-size: map-deep-get($typography, $scale-name, "sizes", $size, "font-size");
10
18
  $font-size-adjustment: map-get($font, "font-size-adjustment") or 1.00;
11
19
  $uppercase-adjustment: map-get($font, "uppercase-adjustment") or 1.00;
12
20
 
13
- @if $uppercase {
21
+ @if map-get($opts, "uppercase") {
14
22
  $font-size-adjustment: $font-size-adjustment * $uppercase-adjustment;
15
23
  }
16
24
 
17
25
  $font-size: $unadjusted-font-size * $font-size-adjustment;
18
26
 
19
27
  // Round font-size.
20
- $font-size-precision: map-deep-get($typography, $scale-name, "font-size-precision") or 0.001;
28
+ $font-size-precision: map-deep-get($typography, $scale-name, "font-size-precision") or null;
29
+ @if ($font-size-precision) {
30
+ $font-size: ss-round($font-size, $font-size-precision);
31
+ }
21
32
 
22
- // Get line-height and apply adjustments.
23
- $unadjusted-line-height: map-deep-get($typography, $scale-name, "sizes", $size, "line-height");
24
- $line-height-adjustment: map-get($font, "line-height-adjustment") or 1.00;
25
-
26
- // If using relative line heights, the font-size-adjustment will
27
- // affect the line-height. This removes the unwanted effect.
28
- @if unitless($unadjusted-line-height) {
29
- $line-height-adjustment: $line-height-adjustment * (1 / $font-size-adjustment);
30
- }
31
33
 
32
- $line-height: $unadjusted-line-height * $line-height-adjustment;
34
+
35
+ // LINE HEIGHT
36
+ // Get and apply adjustments.
37
+
38
+ $line-height-setting: map-get($opts, "line-height");
39
+ $unadjusted-line-height: null;
40
+ $line-height: null;
41
+
42
+ // Use line-height associated with scale and size.
43
+ $normal-line-height: map-deep-get($typography, $scale-name, "sizes", $size, "line-height");
44
+
45
+ // No space between lines. 1.0 if unitless, otherwise equal to font-size.
46
+ $solid-line-height: if(unitless($normal-line-height), 1.0, $font-size);
47
+
48
+ // Halfway between default and solid line-height.
49
+ $tight-line-height: (($normal-line-height - $solid-line-height) / 2) + $solid-line-height;
50
+
51
+ // If line-height is set to solid, use 1.0 or font-size.
52
+ @if $line-height-setting == "solid" {
53
+ $line-height: $solid-line-height;
54
+
55
+ } @else {
56
+
57
+ // Line-height setting determines corresponding basis.
58
+ @if $line-height-setting == "tight" {
59
+ $unadjusted-line-height: $tight-line-height;
60
+ } @else {
61
+ $unadjusted-line-height: $normal-line-height;
62
+ }
63
+
64
+ // Apply adjustments.
65
+ $line-height-adjustment: map-get($font, "line-height-adjustment") or 1.00;
66
+
67
+ // If using relative line heights, the font-size-adjustment will
68
+ // affect the line-height. This removes the unwanted effect.
69
+ @if unitless($unadjusted-line-height) {
70
+ $line-height-adjustment: $line-height-adjustment * (1 / $font-size-adjustment);
71
+ }
72
+
73
+ $line-height: $unadjusted-line-height * $line-height-adjustment;
74
+ }
33
75
 
34
76
  // Round line-height.
35
- $line-height-precision: map-deep-get($typography, $scale-name, "line-height-precision") or 0.001;
36
- // $line-height: ss-round($line-height, $line-height-precision);
77
+ $line-height-precision: map-deep-get($typography, $scale-name, "line-height-precision") or null;
78
+ @if ($line-height-precision) {
79
+ $line-height: ss-round($line-height, $line-height-precision);
80
+ }
37
81
 
38
82
  font-size: $font-size;
39
83
  line-height: $line-height;
@@ -41,24 +85,36 @@
41
85
 
42
86
  // Apply non-responsive styling. Only the size used for
43
87
  // the specified media query will be applied.
44
- @mixin ss-set-font-size($font, $size, $scale-name, $uppercase: false) {
88
+ @mixin ss-set-font-size($font, $size, $scale-name, $opts: ()) {
45
89
 
90
+ // Extend default opts
91
+ $opts: map-merge((
92
+ "uppercase": false,
93
+ "line-height": "normal"
94
+ ), $opts);
95
+
46
96
  font-family: map-get($font, "family");
47
97
 
48
- @if $uppercase {
98
+ @if map-get($opts, "uppercase") {
49
99
  text-transform: uppercase;
50
100
  }
51
101
 
52
- @include ss-apply-font-styles($font, $size, $scale-name);
102
+ @include ss-apply-font-styles($font, $size, $scale-name, $opts);
53
103
  }
54
104
 
55
105
  // Apply responsive styling. Corresponding sizes for
56
106
  // each media query will be applied.
57
- @mixin ss-set-responsive-font-size($font, $size: 0, $uppercase: false) {
107
+ @mixin ss-set-responsive-font-size($font, $size: 0, $opts: ()) {
108
+
109
+ // Extend default opts
110
+ $opts: map-merge((
111
+ "uppercase": false,
112
+ "line-height": "normal"
113
+ ), $opts);
58
114
 
59
115
  font-family: map-get($font, "family");
60
116
 
61
- @if $uppercase {
117
+ @if map-get($opts, "uppercase") {
62
118
  text-transform: uppercase;
63
119
  }
64
120
 
@@ -66,14 +122,14 @@
66
122
 
67
123
  // For the default styles, don't include a media query.
68
124
  @if $scale-name == "default" {
69
- @include ss-apply-font-styles($font, $size, $scale-name, $uppercase);
125
+ @include ss-apply-font-styles($font, $size, $scale-name, $opts);
70
126
  }
71
127
 
72
128
  // For other breakpoints, set style with a media query.
73
129
  @else {
74
130
  $media-query: map-deep-get($typography, $scale-name, "media-query");
75
131
  @media #{$media-query} {
76
- @include ss-apply-font-styles($font, $size, $scale-name, $uppercase);
132
+ @include ss-apply-font-styles($font, $size, $scale-name, $opts);
77
133
  }
78
134
  }
79
135
  }
@@ -53,7 +53,7 @@ $typography: ss-build-typography((
53
53
  // Define your font scales and their constraints.
54
54
  "scales": (
55
55
 
56
- // Phone sizes.
56
+ // Phone sizes
57
57
  "default": (
58
58
  "base-font-size": 16px,
59
59
  "base-line-height": 1.5,
@@ -61,7 +61,7 @@ $typography: ss-build-typography((
61
61
  "max-line-height": 1.35
62
62
  ),
63
63
 
64
- // Tablet sizes and larger.
64
+ // Tablet sizes and larger
65
65
  "tablet": (
66
66
  "media-query": "screen and (min-width: 768px)",
67
67
  "base-font-size": 18px,
@@ -120,6 +120,9 @@ nav {
120
120
  @include ss-set-responsive-font-size($font-heading, 0);
121
121
  }
122
122
 
123
+
124
+ // Copy
125
+
123
126
  .copy-larger4 {
124
127
  @include ss-set-responsive-font-size($font-copy, 4);
125
128
  }
@@ -132,6 +135,8 @@ nav {
132
135
  @include ss-set-responsive-font-size($font-copy, 2);
133
136
  }
134
137
 
138
+ // Icons
139
+
135
140
  .icon-larger4 {
136
141
  @include ss-set-responsive-font-size($font-icon, 4);
137
142
  }
@@ -102,14 +102,15 @@ body {
102
102
  /* line 22, ../sass/_typography.scss */
103
103
  .h1 {
104
104
  font-family: Verdana, sans-serif;
105
- font-size: 24.92px;
106
- line-height: 1.42584;
105
+ text-transform: uppercase;
106
+ font-size: 21.182px;
107
+ line-height: 1.67746;
107
108
  }
108
109
  @media screen and (min-width: 768px) {
109
110
  /* line 22, ../sass/_typography.scss */
110
111
  .h1 {
111
- font-size: 37.38px;
112
- line-height: 1.32022;
112
+ font-size: 31.773px;
113
+ line-height: 1.55321;
113
114
  }
114
115
  }
115
116
 
@@ -1113,127 +1114,126 @@ nav a {
1113
1114
  }
1114
1115
  }
1115
1116
 
1116
- /* line 123, ../sass/main.scss */
1117
+ /* line 126, ../sass/main.scss */
1117
1118
  .copy-larger4 {
1118
1119
  font-family: Georgia, serif;
1119
- text-transform: uppercase;
1120
- font-size: 22.96px;
1121
- line-height: 1.64634;
1120
+ font-size: 28.0px;
1121
+ line-height: 1.35;
1122
1122
  }
1123
1123
  @media screen and (min-width: 768px) {
1124
- /* line 123, ../sass/main.scss */
1124
+ /* line 126, ../sass/main.scss */
1125
1125
  .copy-larger4 {
1126
- font-size: 34.44px;
1127
- line-height: 1.52439;
1126
+ font-size: 42px;
1127
+ line-height: 1.25;
1128
1128
  }
1129
1129
  }
1130
1130
 
1131
- /* line 127, ../sass/main.scss */
1131
+ /* line 130, ../sass/main.scss */
1132
1132
  .copy-larger3 {
1133
1133
  font-family: Georgia, serif;
1134
1134
  font-size: 24.34437px;
1135
1135
  line-height: 1.38603;
1136
1136
  }
1137
1137
  @media screen and (min-width: 768px) {
1138
- /* line 127, ../sass/main.scss */
1138
+ /* line 130, ../sass/main.scss */
1139
1139
  .copy-larger3 {
1140
1140
  font-size: 33.98248px;
1141
1141
  line-height: 1.32957;
1142
1142
  }
1143
1143
  }
1144
1144
 
1145
- /* line 131, ../sass/main.scss */
1145
+ /* line 134, ../sass/main.scss */
1146
1146
  .copy-larger2 {
1147
1147
  font-family: Georgia, serif;
1148
1148
  font-size: 21.16601px;
1149
1149
  line-height: 1.42302;
1150
1150
  }
1151
1151
  @media screen and (min-width: 768px) {
1152
- /* line 131, ../sass/main.scss */
1152
+ /* line 134, ../sass/main.scss */
1153
1153
  .copy-larger2 {
1154
1154
  font-size: 27.49545px;
1155
1155
  line-height: 1.41421;
1156
1156
  }
1157
1157
  }
1158
1158
 
1159
- /* line 135, ../sass/main.scss */
1159
+ /* line 140, ../sass/main.scss */
1160
1160
  .icon-larger4 {
1161
1161
  font-family: 'Feather';
1162
1162
  font-size: 26.6px;
1163
1163
  line-height: 1.42105;
1164
1164
  }
1165
1165
  @media screen and (min-width: 768px) {
1166
- /* line 135, ../sass/main.scss */
1166
+ /* line 140, ../sass/main.scss */
1167
1167
  .icon-larger4 {
1168
1168
  font-size: 39.9px;
1169
1169
  line-height: 1.31579;
1170
1170
  }
1171
1171
  }
1172
1172
 
1173
- /* line 139, ../sass/main.scss */
1173
+ /* line 144, ../sass/main.scss */
1174
1174
  .icon-larger3 {
1175
1175
  font-family: 'Feather';
1176
1176
  font-size: 23.12715px;
1177
1177
  line-height: 1.45898;
1178
1178
  }
1179
1179
  @media screen and (min-width: 768px) {
1180
- /* line 139, ../sass/main.scss */
1180
+ /* line 144, ../sass/main.scss */
1181
1181
  .icon-larger3 {
1182
1182
  font-size: 32.28336px;
1183
1183
  line-height: 1.39955;
1184
1184
  }
1185
1185
  }
1186
1186
 
1187
- /* line 143, ../sass/main.scss */
1187
+ /* line 148, ../sass/main.scss */
1188
1188
  .icon-larger2 {
1189
1189
  font-family: 'Feather';
1190
1190
  font-size: 20.10771px;
1191
1191
  line-height: 1.49792;
1192
1192
  }
1193
1193
  @media screen and (min-width: 768px) {
1194
- /* line 143, ../sass/main.scss */
1194
+ /* line 148, ../sass/main.scss */
1195
1195
  .icon-larger2 {
1196
1196
  font-size: 26.12068px;
1197
1197
  line-height: 1.48865;
1198
1198
  }
1199
1199
  }
1200
1200
 
1201
- /* line 147, ../sass/main.scss */
1201
+ /* line 152, ../sass/main.scss */
1202
1202
  .icon-larger1 {
1203
1203
  font-family: 'Feather';
1204
1204
  font-size: 17.48248px;
1205
1205
  line-height: 1.5379;
1206
1206
  }
1207
1207
  @media screen and (min-width: 768px) {
1208
- /* line 147, ../sass/main.scss */
1208
+ /* line 152, ../sass/main.scss */
1209
1209
  .icon-larger1 {
1210
1210
  font-size: 21.13442px;
1211
1211
  line-height: 1.58341;
1212
1212
  }
1213
1213
  }
1214
1214
 
1215
- /* line 151, ../sass/main.scss */
1215
+ /* line 156, ../sass/main.scss */
1216
1216
  .icon-base {
1217
1217
  font-family: 'Feather';
1218
1218
  font-size: 15.2px;
1219
1219
  line-height: 1.57895;
1220
1220
  }
1221
1221
  @media screen and (min-width: 768px) {
1222
- /* line 151, ../sass/main.scss */
1222
+ /* line 156, ../sass/main.scss */
1223
1223
  .icon-base {
1224
1224
  font-size: 17.1px;
1225
1225
  line-height: 1.68421;
1226
1226
  }
1227
1227
  }
1228
1228
 
1229
- /* line 155, ../sass/main.scss */
1229
+ /* line 160, ../sass/main.scss */
1230
1230
  .icon-smaller {
1231
1231
  font-family: Georgia, serif;
1232
1232
  font-size: 13.91107px;
1233
1233
  line-height: 1.54004;
1234
1234
  }
1235
1235
  @media screen and (min-width: 768px) {
1236
- /* line 155, ../sass/main.scss */
1236
+ /* line 160, ../sass/main.scss */
1237
1237
  .icon-smaller {
1238
1238
  font-size: 14.56392px;
1239
1239
  line-height: 1.70185;
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sane-scale
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.6'
4
+ version: '0.7'
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Fusilier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-17 00:00:00.000000000 Z
11
+ date: 2016-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sassy-math
@@ -66,6 +66,7 @@ files:
66
66
  - stylesheets/sane-scale/_build-scale.scss
67
67
  - stylesheets/sane-scale/_build-typography.scss
68
68
  - stylesheets/sane-scale/_map-deep-get.scss
69
+ - stylesheets/sane-scale/_round.scss
69
70
  - stylesheets/sane-scale/_set-font-size.scss
70
71
  - templates/project/config.rb
71
72
  - templates/project/fonts/feather-webfont.eot