accoutrement 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f2eca6b2e9fd7f48c7f94b5b44e15eab2c878bd4
4
- data.tar.gz: d642b716f57ebe99eea3fd9126f66c0c4ab13e60
3
+ metadata.gz: 051b8e47b2a6d8e73a0b18f697efb6380d7eee58
4
+ data.tar.gz: 4c8c50d20b2d0ddecd0f5f7ba16e4d65338d53cb
5
5
  SHA512:
6
- metadata.gz: 9556f7c356b1afc1879ac8e77c600ffdf1336902f21623b684b97d4a6e3a89c5b415fed175720bb589613255e7452453abde0292d0c764189113e65a50e07216
7
- data.tar.gz: 81c5286e72063b50b32a82eaa53d29371e5a239d1acc59c8ef27c270d11eb6d5be1ff0a996460080fd693b92d69524342024970032e5a85c5c1dc0054d83327e
6
+ metadata.gz: 1a99afa561cadaaf1a5d4cbf8f42866b8a75be7f0f39c1ae51ee1c0aae2dc8a4eb60d3ad84956f809af79a39459dadb39b552da1e96ff32b2fc15e4249f270ca
7
+ data.tar.gz: bfb27c22775f50c07653575551d657e6a193b6f5680fc14ca0f5240bf44f7f7ca8600bc0ea2cc1623ac24fc707d14abcdfb8922ffe2764a8d580114b83f44076
data/README.md CHANGED
@@ -12,7 +12,7 @@ Don't upgrade unless you're willing to use new things in new ways.
12
12
  License
13
13
  -------
14
14
 
15
- Copyright © Eric Meyer.
15
+ Copyright © Eric M. Suzanne
16
16
 
17
17
  Original code licensed under MIT/GLPv2
18
18
  Open Source projects used within this project retain their original licenses.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.6
1
+ 0.1.7
@@ -1,7 +1,13 @@
1
+ // Sass Extensions
2
+ // ---------------
3
+
4
+ @import 'accoutrement/maps';
5
+ @import 'accoutrement/strings';
6
+
7
+
1
8
  // Utilities
2
9
  // ---------
3
10
 
4
- @import 'accoutrement/maps';
5
11
  @import 'accoutrement/settings';
6
12
  @import 'accoutrement/scale';
7
13
  @import 'accoutrement/fonts';
@@ -1,7 +1,11 @@
1
1
  // Fontface Tools
2
2
  // ==============
3
3
 
4
- @include set(fontface, formats, woff ttf);
4
+ @include set(fontface, (
5
+ formats: woff ttf,
6
+ valid-styles: italic oblique,
7
+ valid-weights: 100 200 300 400 500 600 700 800 900 bold bolder lighter,
8
+ ));
5
9
 
6
10
 
7
11
  // Fonts
@@ -23,32 +27,115 @@
23
27
  $fonts: get(fonts),
24
28
  $formats: get(fontface, formats)
25
29
  ) {
30
+ $_output: _get-font-face($fonts, $formats);
31
+
32
+ @each $font in $_output {
33
+ @font-face {
34
+ @include output-map($font);
35
+ }
36
+ }
37
+ }
38
+
39
+
40
+ // Font Placeholders
41
+ // -----------------
42
+ // Create font-family placeholders
43
+ @mixin font-placeholders(
44
+ $fonts: get(fonts)
45
+ ) {
46
+ $_output: _get-font-placeholders($fonts);
47
+
48
+ @each $font, $map in $_output {
49
+ #{$font} {
50
+ @include output-map($map);
51
+ }
52
+ }
53
+ }
54
+
55
+
56
+ // Get Font Face
57
+ // -------------
58
+ // PRIVATE: Return a list of font-face output maps
59
+ @function _get-font-face(
60
+ $fonts: get(fonts),
61
+ $formats: get(fontface, formats)
62
+ ) {
63
+ $_return: ();
64
+
26
65
  @each $font, $info in $fonts {
27
- $name: map-get($info, name) or $font;
66
+ $_name: map-get($info, name) or $font;
67
+ $_files: map-get($info, files) or ();
68
+ $_interp-path: map-get($info, path);
69
+ $_interp-styles: map-get($info, styles);
70
+
71
+ @if $_interp-path and $_interp-styles {
72
+ $_interp: _interpolate-font-files($_interp-path, $_interp-styles);
73
+ $_files: map-merge($_interp, $_files);
74
+ }
28
75
 
29
- @each $styles, $path in map-get($info, files) {
76
+ @each $styles, $path in $_files {
30
77
  $styles: _parse-font-styles($styles);
31
- $src: _build-font-src($path, $formats);
78
+ $_src: _build-font-src($path, $formats);
79
+
80
+ $_return: append($_return, (
81
+ font-family: quote($_name),
82
+ src: $_src,
83
+ font-weight: map-get($styles, weight),
84
+ font-style: map-get($styles, style),
85
+ ));
86
+ }
87
+ }
88
+
89
+ @return $_return;
90
+ }
32
91
 
33
- @font-face {
34
- font-family: quote($name);
35
- src: $src;
36
- font-weight: map-get($styles, weight);
37
- font-style: map-get($styles, style);
92
+
93
+ // Interpolate Font Files
94
+ // ----------------------
95
+ // PRIVATE: Return font files based on path/style interpolation
96
+ @function _interpolate-font-files(
97
+ $path,
98
+ $variants: regular
99
+ ) {
100
+ $_styles: get(fontface, valid-styles);
101
+ $_weights: get(fontface, valid-weights);
102
+ $_return: ();
103
+
104
+ @each $v in $variants {
105
+ $_key: ();
106
+ $_weight: '';
107
+ $_style: '';
108
+
109
+ @if length($v) == 1 {
110
+ $_weight: $v;
111
+ $_key: $v;
112
+ } @else {
113
+ @each $item in $v {
114
+ @if index($_styles, $item) {
115
+ $_style: $item;
116
+ } @else if index($_weights, $item) {
117
+ $_weight: $item;
118
+ }
119
+ $_key: append($_key, to-lower-case($item));
38
120
  }
39
121
  }
122
+
123
+ $_val: interpolate($path, $_weight, $_style);
124
+ $_return: map-merge($_return, ($_key: $_val));
40
125
  }
126
+
127
+ @return $_return;
41
128
  }
42
129
 
43
130
 
44
131
  // Parse Font Styles
45
132
  // -----------------
46
- // Return font weight and style based on shorthand syntax
133
+ // PRIVATE: Return font weight and style based on shorthand syntax
47
134
  @function _parse-font-styles(
48
135
  $face
49
136
  ) {
50
- $styles: italic, oblique;
51
- $weights: 100, 200, 300, 400, 500, 600, 700, 800, 900, bold, bolder, lighter;
137
+ $styles: get(fontface, valid-styles);
138
+ $weights: get(fontface, valid-weights);
52
139
  $return: (
53
140
  weight: normal,
54
141
  style: normal,
@@ -68,7 +155,7 @@
68
155
 
69
156
  // Build Font SRC
70
157
  // --------------
71
- // Return src attribute based on path and formats
158
+ // PRIVATE: Return src attribute based on path and formats
72
159
  @function _build-font-src(
73
160
  $path,
74
161
  $formats: get(fontface, formats)
@@ -92,22 +179,26 @@
92
179
  }
93
180
 
94
181
 
95
- // Font Placeholders
96
- // -----------------
97
- // Create font-family placeholders
98
- @mixin font-placeholders(
182
+ // Get Font Placeholders
183
+ // ---------------------
184
+ // PRIVATE: Return a list of font-placeholder maps ready for output
185
+ @function _get-font-placeholders(
99
186
  $fonts: get(fonts)
100
187
  ) {
188
+ $_return: ();
189
+
101
190
  @each $font, $info in $fonts {
102
- $name: map-get($info, name) or $font;
103
- $type: map-get($info, type);
104
- $stack: append($name, map-get($info, stack), comma);
105
- $stack: append($stack, $type, comma);
191
+ $_name: map-get($info, name) or $font;
192
+ $_type: map-get($info, type);
193
+ $_stack: join($_name, map-get($info, stack) or (), comma);
194
+ $_stack: append($_stack, $_type, comma);
106
195
 
107
- @if $type == monospace {
108
- $stack: append($stack, serif);
196
+ @if $_type == monospace {
197
+ $_stack: append($_stack, serif);
109
198
  }
110
199
 
111
- %#{$font} { font-family: $stack; }
200
+ $_return: map-merge($_return, ('%#{$font}': (font-family: $_stack)));
112
201
  }
202
+
203
+ @return $_return;
113
204
  }
@@ -0,0 +1,46 @@
1
+ // String Functions
2
+ // ================
3
+
4
+ $interpolation-format-string: '%s';
5
+
6
+ // String Replace
7
+ // --------------
8
+ // Return a string, with a substring replaced
9
+ @function str-replace(
10
+ $string,
11
+ $old,
12
+ $new: ''
13
+ ) {
14
+ $_i: str-index($string, $old);
15
+ $_n: str-length($old);
16
+
17
+ $_a: str-slice($string, 1, $_i - 1);
18
+ $_z: str-slice($string, $_i + $_n);
19
+
20
+ @return $_a + $new + $_z;
21
+ }
22
+
23
+
24
+ // Interpolate
25
+ // -----------
26
+ // Return a string with interpolated values replacing '%s' format strings
27
+ @function interpolate(
28
+ $string,
29
+ $values...
30
+ ) {
31
+ $_return: $string;
32
+
33
+ @each $val in $values {
34
+ @if str-index($_return, $interpolation-format-string) {
35
+ $_return: str-replace($_return, $interpolation-format-string, $val);
36
+ } @else {
37
+ @warn 'Too many values passed for interpolation with "#{$string}".';
38
+ }
39
+ }
40
+
41
+ @if str-index($_return, $interpolation-format-string) {
42
+ @warn 'Not all format strings were replaced in "#{$string}".';
43
+ }
44
+
45
+ @return $_return;
46
+ }
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: accoutrement
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
- - Eric Meyer
7
+ - Eric M. Suzanne
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
@@ -61,6 +61,7 @@ files:
61
61
  - stylesheets/accoutrement/_pseudo-elements.scss
62
62
  - stylesheets/accoutrement/_scale.scss
63
63
  - stylesheets/accoutrement/_settings.scss
64
+ - stylesheets/accoutrement/_strings.scss
64
65
  - stylesheets/accoutrement/_tooltips.scss
65
66
  - README.md
66
67
  - VERSION