doggystyle 0.1.0

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.
Files changed (294) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +16 -0
  3. data/.hound.yml +5 -0
  4. data/.npmignore +18 -0
  5. data/.ruby-version +1 -0
  6. data/.scss-lint.yml +243 -0
  7. data/.travis.yml +5 -0
  8. data/CHANGELOG.md +5 -0
  9. data/Gemfile +4 -0
  10. data/LICENSE.txt +21 -0
  11. data/README.md +40 -0
  12. data/RELEASING.md +1 -0
  13. data/Rakefile +9 -0
  14. data/bin/doggystyle +5 -0
  15. data/bower.json +38 -0
  16. data/circle.yml +13 -0
  17. data/core/_imports.scss +229 -0
  18. data/core/animations/_jump.scss +7 -0
  19. data/core/animations/_shake.scss +24 -0
  20. data/core/animations/_wobble.scss +8 -0
  21. data/core/functions/_mobile-first.scss +3 -0
  22. data/core/functions/_opposite-direction.scss +45 -0
  23. data/core/functions/casts/_to-bool.scss +19 -0
  24. data/core/functions/casts/_to-color.scss +74 -0
  25. data/core/functions/casts/_to-list.scss +38 -0
  26. data/core/functions/casts/_to-map.scss +27 -0
  27. data/core/functions/casts/_to-null.scss +15 -0
  28. data/core/functions/casts/_to-number.scss +66 -0
  29. data/core/functions/casts/_to-string.scss +15 -0
  30. data/core/functions/colours/_colour-contrast.scss +61 -0
  31. data/core/functions/colours/_colour.scss +69 -0
  32. data/core/functions/colours/_random-colour.scss +78 -0
  33. data/core/functions/lists/_contains.scss +62 -0
  34. data/core/functions/lists/_first.scss +19 -0
  35. data/core/functions/lists/_insert-nth.scss +37 -0
  36. data/core/functions/lists/_last.scss +11 -0
  37. data/core/functions/lists/_merge.scss +30 -0
  38. data/core/functions/lists/_prepend.scss +11 -0
  39. data/core/functions/lists/_remove-nth.scss +53 -0
  40. data/core/functions/lists/_remove.scss +30 -0
  41. data/core/functions/lists/_replace-nth.scss +55 -0
  42. data/core/functions/lists/_replace.scss +36 -0
  43. data/core/functions/lists/_reverse.scss +31 -0
  44. data/core/functions/lists/_second.scss +19 -0
  45. data/core/functions/lists/_shift.scss +24 -0
  46. data/core/functions/lists/_slice.scss +52 -0
  47. data/core/functions/lists/_sort.scss +51 -0
  48. data/core/functions/maps/_map-deep-get.scss +51 -0
  49. data/core/functions/maps/_map-deep-set.scss +34 -0
  50. data/core/functions/maps/_map-depth.scss +23 -0
  51. data/core/functions/maps/_map-extend.scss +47 -0
  52. data/core/functions/maps/_map-has-keys.scss +23 -0
  53. data/core/functions/maps/_map-has-nested-keys.scss +24 -0
  54. data/core/functions/maps/_map-set.scss +4 -0
  55. data/core/functions/maps/_map-zip.scss +50 -0
  56. data/core/functions/numbers/_add-unit.scss +54 -0
  57. data/core/functions/numbers/_pad.scss +16 -0
  58. data/core/functions/numbers/_spacer.scss +16 -0
  59. data/core/functions/numbers/_strip.scss +29 -0
  60. data/core/functions/numbers/_units.scss +17 -0
  61. data/core/functions/svg/_dots.scss +84 -0
  62. data/core/functions/svg/_fake-radius.scss +131 -0
  63. data/core/functions/svg/_lines.scss +76 -0
  64. data/core/functions/svg/_svg.scss +12 -0
  65. data/core/functions/text/_smart-lineheight.scss +13 -0
  66. data/core/functions/text/_string-explode.scss +45 -0
  67. data/core/functions/text/_string-replace.scss +38 -0
  68. data/core/helpers/_custom-elements.scss +114 -0
  69. data/core/helpers/_eases.scss +44 -0
  70. data/core/helpers/_reset.scss +282 -0
  71. data/core/helpers/_show-breakpoints.scss +25 -0
  72. data/core/helpers/_strings.scss +648 -0
  73. data/core/helpers/_warnings.scss +3 -0
  74. data/core/helpers/checks/_check.scss +69 -0
  75. data/core/helpers/checks/_is-absolute-length.scss +25 -0
  76. data/core/helpers/checks/_is-angel.scss +25 -0
  77. data/core/helpers/checks/_is-arglist.scss +11 -0
  78. data/core/helpers/checks/_is-bool.scss +23 -0
  79. data/core/helpers/checks/_is-calc.scss +11 -0
  80. data/core/helpers/checks/_is-colour.scss +23 -0
  81. data/core/helpers/checks/_is-dark.scss +14 -0
  82. data/core/helpers/checks/_is-duration.scss +15 -0
  83. data/core/helpers/checks/_is-false.scss +13 -0
  84. data/core/helpers/checks/_is-first-character.scss +11 -0
  85. data/core/helpers/checks/_is-frequency.scss +15 -0
  86. data/core/helpers/checks/_is-function.scss +44 -0
  87. data/core/helpers/checks/_is-integer.scss +15 -0
  88. data/core/helpers/checks/_is-length.scss +16 -0
  89. data/core/helpers/checks/_is-light.scss +14 -0
  90. data/core/helpers/checks/_is-list.scss +11 -0
  91. data/core/helpers/checks/_is-map.scss +11 -0
  92. data/core/helpers/checks/_is-null.scss +11 -0
  93. data/core/helpers/checks/_is-number.scss +19 -0
  94. data/core/helpers/checks/_is-percentage.scss +13 -0
  95. data/core/helpers/checks/_is-position.scss +16 -0
  96. data/core/helpers/checks/_is-pseudo.scss +24 -0
  97. data/core/helpers/checks/_is-relative-length.scss +25 -0
  98. data/core/helpers/checks/_is-resolution.scss +15 -0
  99. data/core/helpers/checks/_is-selector.scss +3 -0
  100. data/core/helpers/checks/_is-string.scss +11 -0
  101. data/core/helpers/checks/_is-time.scss +15 -0
  102. data/core/helpers/checks/_is-unit.scss +16 -0
  103. data/core/helpers/private/_arglist-to-list.scss +36 -0
  104. data/core/helpers/private/_brightness.scss +13 -0
  105. data/core/helpers/private/_find-digits.scss +41 -0
  106. data/core/helpers/private/_find-integer.scss +40 -0
  107. data/core/helpers/private/_from-hex.scss +48 -0
  108. data/core/helpers/private/_from-hsl.scss +55 -0
  109. data/core/helpers/private/_from-rgb.scss +55 -0
  110. data/core/helpers/private/_get-color-value.scss +26 -0
  111. data/core/helpers/private/_hash-fix.scss +15 -0
  112. data/core/helpers/private/_hex-to-dec.scss +28 -0
  113. data/core/helpers/private/_length.scss +26 -0
  114. data/core/helpers/private/_lightness.scss +15 -0
  115. data/core/helpers/private/_list-items-to-strings.scss +8 -0
  116. data/core/helpers/private/_min-max-number.scss +12 -0
  117. data/core/helpers/private/_pow.scss +29 -0
  118. data/core/helpers/private/_string-compare.scss +38 -0
  119. data/core/helpers/private/_string-explode.scss +43 -0
  120. data/core/helpers/private/_sudo.scss +23 -0
  121. data/core/helpers/symbols/_arrows.scss +337 -0
  122. data/core/helpers/symbols/_block.scss +97 -0
  123. data/core/helpers/symbols/_box.scss +385 -0
  124. data/core/helpers/symbols/_common.scss +101 -0
  125. data/core/helpers/symbols/_currency.scss +82 -0
  126. data/core/helpers/symbols/_dingbats.scss +565 -0
  127. data/core/helpers/symbols/_geometric.scss +289 -0
  128. data/core/helpers/symbols/_letterlike.scss +235 -0
  129. data/core/helpers/symbols/_misc.scss +568 -0
  130. data/core/helpers/symbols/_operators.scss +766 -0
  131. data/core/helpers/symbols/_punctuation.scss +214 -0
  132. data/core/mixins/_align.scss +15 -0
  133. data/core/mixins/_animate.scss +16 -0
  134. data/core/mixins/_aspect-ratio.scss +86 -0
  135. data/core/mixins/_backface-visibility.scss +7 -0
  136. data/core/mixins/_background-image.scss +13 -0
  137. data/core/mixins/_blend.scss +10 -0
  138. data/core/mixins/_blendmodes.scss +24 -0
  139. data/core/mixins/_border-radius.scss +105 -0
  140. data/core/mixins/_browsers.scss +155 -0
  141. data/core/mixins/_bulletpoint.scss +12 -0
  142. data/core/mixins/_center.scss +3 -0
  143. data/core/mixins/_clearfix.scss +7 -0
  144. data/core/mixins/_columns.scss +22 -0
  145. data/core/mixins/_custom-property.scss +15 -0
  146. data/core/mixins/_devices.scss +97 -0
  147. data/core/mixins/_dropdown.scss +38 -0
  148. data/core/mixins/_fake-radius.scss +99 -0
  149. data/core/mixins/_filters.scss +163 -0
  150. data/core/mixins/_flip.scss +11 -0
  151. data/core/mixins/_font-face.scss +11 -0
  152. data/core/mixins/_fontsize.scss +126 -0
  153. data/core/mixins/_gallery.scss +134 -0
  154. data/core/mixins/_gradient.scss +72 -0
  155. data/core/mixins/_image-size.scss +18 -0
  156. data/core/mixins/_image.scss +12 -0
  157. data/core/mixins/_inputs.scss +18 -0
  158. data/core/mixins/_keyframes.scss +8 -0
  159. data/core/mixins/_last.scss +5 -0
  160. data/core/mixins/_nth-last.scss +7 -0
  161. data/core/mixins/_nth.scss +10 -0
  162. data/core/mixins/_placeholder.scss +15 -0
  163. data/core/mixins/_prefixer.scss +55 -0
  164. data/core/mixins/_selection.scss +15 -0
  165. data/core/mixins/_shadow.scss +7 -0
  166. data/core/mixins/_size.scss +13 -0
  167. data/core/mixins/_smart-horizontal.scss +21 -0
  168. data/core/mixins/_sudo-image.scss +12 -0
  169. data/core/mixins/_text-shadow.scss +30 -0
  170. data/core/mixins/_transforms.scss +264 -0
  171. data/core/mixins/_transition.scss +189 -0
  172. data/core/mixins/_triangle-classic.scss +170 -0
  173. data/core/mixins/_triangle.scss +250 -0
  174. data/core/mixins/_unwrap.scss +5 -0
  175. data/core/mixins/_user-select.scss +5 -0
  176. data/core/mixins/_vertical.scss +10 -0
  177. data/core/mixins/columns/_columns.scss +92 -0
  178. data/core/mixins/flexbox/_flex-container.scss +201 -0
  179. data/core/mixins/flexbox/_flex-grid.scss +235 -0
  180. data/core/mixins/flexbox/_flex-items.scss +140 -0
  181. data/core/mixins/flexbox/_flex-remove.scss +12 -0
  182. data/core/mixins/grid/_break-between.scss +6 -0
  183. data/core/mixins/grid/_grid.scss +150 -0
  184. data/core/mixins/svg/_svg-size.scss +4 -0
  185. data/core/mixins/svg/_svg.scss +9 -0
  186. data/core/placeholders/_clear.scss +27 -0
  187. data/core/placeholders/_cursor.scss +35 -0
  188. data/core/placeholders/_misc.scss +20 -0
  189. data/core/placeholders/_rendering.scss +21 -0
  190. data/core/placeholders/_text.scss +41 -0
  191. data/core/settings/_colours.scss +30 -0
  192. data/core/settings/_directories.scss +7 -0
  193. data/core/settings/_global.scss +14 -0
  194. data/core/settings/_grid.scss +24 -0
  195. data/core/settings/_padding.scss +8 -0
  196. data/core/settings/_spacing.scss +8 -0
  197. data/core/settings/_text.scss +13 -0
  198. data/doggystyle.gemspec +29 -0
  199. data/eyeglass-exports.js +7 -0
  200. data/features/install.feature +29 -0
  201. data/features/step_definitions/doggystyle_steps.rb +31 -0
  202. data/features/support/bourbon_support.rb +19 -0
  203. data/features/support/env.rb +1 -0
  204. data/features/update.feature +30 -0
  205. data/features/version.feature +5 -0
  206. data/index.js +7 -0
  207. data/lib/doggystyle.rb +7 -0
  208. data/lib/doggystyle/generator.rb +81 -0
  209. data/lib/doggystyle/version.rb +3 -0
  210. data/package.json +33 -0
  211. data/spec/doggystyle/library/border_color_spec.rb +51 -0
  212. data/spec/doggystyle/library/border_radius_spec.rb +25 -0
  213. data/spec/doggystyle/library/border_style_spec.rb +51 -0
  214. data/spec/doggystyle/library/border_width_spec.rb +51 -0
  215. data/spec/doggystyle/library/buttons_spec.rb +53 -0
  216. data/spec/doggystyle/library/clearfix_spec.rb +18 -0
  217. data/spec/doggystyle/library/contrast_switch_spec.rb +23 -0
  218. data/spec/doggystyle/library/ellipsis_spec.rb +20 -0
  219. data/spec/doggystyle/library/font_face_spec_1.rb +16 -0
  220. data/spec/doggystyle/library/font_face_spec_2.rb +21 -0
  221. data/spec/doggystyle/library/font_face_spec_3.rb +16 -0
  222. data/spec/doggystyle/library/font_face_spec_4.rb +17 -0
  223. data/spec/doggystyle/library/font_stacks_spec.rb +40 -0
  224. data/spec/doggystyle/library/hide_text_spec.rb +17 -0
  225. data/spec/doggystyle/library/hide_visually_spec.rb +35 -0
  226. data/spec/doggystyle/library/margin_spec.rb +51 -0
  227. data/spec/doggystyle/library/modular_scale_spec.rb +43 -0
  228. data/spec/doggystyle/library/padding_spec.rb +51 -0
  229. data/spec/doggystyle/library/position_spec.rb +67 -0
  230. data/spec/doggystyle/library/prefixer_spec.rb +34 -0
  231. data/spec/doggystyle/library/shade_spec.rb +31 -0
  232. data/spec/doggystyle/library/size_spec.rb +31 -0
  233. data/spec/doggystyle/library/strip_unit_spec.rb +31 -0
  234. data/spec/doggystyle/library/text_inputs_spec.rb +75 -0
  235. data/spec/doggystyle/library/tint_spec.rb +31 -0
  236. data/spec/doggystyle/library/triangle_spec.rb +31 -0
  237. data/spec/doggystyle/library/word_wrap_spec.rb +29 -0
  238. data/spec/doggystyle/utilities/assign_inputs_spec.rb +50 -0
  239. data/spec/doggystyle/utilities/collapse_directionals.rb +25 -0
  240. data/spec/doggystyle/utilities/directional_values_spec.rb +21 -0
  241. data/spec/doggystyle/utilities/font_source_declaration_spec.rb +29 -0
  242. data/spec/doggystyle/utilities/retrieve_bourbon_setting_spec.rb +31 -0
  243. data/spec/doggystyle/utilities/unpack_spec.rb +32 -0
  244. data/spec/doggystyle/validators/contains_spec.rb +27 -0
  245. data/spec/doggystyle/validators/is_length_spec.rb +49 -0
  246. data/spec/doggystyle/validators/is_light_spec.rb +37 -0
  247. data/spec/doggystyle/validators/is_number_spec.rb +43 -0
  248. data/spec/doggystyle/validators/is_size_spec.rb +43 -0
  249. data/spec/fixtures/_setup.scss +1 -0
  250. data/spec/fixtures/library/border-color.scss +26 -0
  251. data/spec/fixtures/library/border-radius.scss +17 -0
  252. data/spec/fixtures/library/border-style.scss +21 -0
  253. data/spec/fixtures/library/border-width.scss +21 -0
  254. data/spec/fixtures/library/buttons.scss +17 -0
  255. data/spec/fixtures/library/clearfix.scss +5 -0
  256. data/spec/fixtures/library/contrast-switch.scss +9 -0
  257. data/spec/fixtures/library/ellipsis.scss +5 -0
  258. data/spec/fixtures/library/font-face-1.scss +6 -0
  259. data/spec/fixtures/library/font-face-2.scss +10 -0
  260. data/spec/fixtures/library/font-face-3.scss +8 -0
  261. data/spec/fixtures/library/font-face-4.scss +7 -0
  262. data/spec/fixtures/library/font-stacks.scss +41 -0
  263. data/spec/fixtures/library/hide-text.scss +5 -0
  264. data/spec/fixtures/library/hide-visually.scss +9 -0
  265. data/spec/fixtures/library/margin.scss +21 -0
  266. data/spec/fixtures/library/modular-scale.scss +29 -0
  267. data/spec/fixtures/library/padding.scss +21 -0
  268. data/spec/fixtures/library/position.scss +25 -0
  269. data/spec/fixtures/library/prefixer.scss +13 -0
  270. data/spec/fixtures/library/shade.scss +17 -0
  271. data/spec/fixtures/library/size.scss +13 -0
  272. data/spec/fixtures/library/strip-unit.scss +17 -0
  273. data/spec/fixtures/library/text-inputs.scss +21 -0
  274. data/spec/fixtures/library/tint.scss +17 -0
  275. data/spec/fixtures/library/triangle.scss +9 -0
  276. data/spec/fixtures/library/word-wrap.scss +9 -0
  277. data/spec/fixtures/utilities/assign-inputs.scss +19 -0
  278. data/spec/fixtures/utilities/collapse-directionals.scss +17 -0
  279. data/spec/fixtures/utilities/directional-values.scss +13 -0
  280. data/spec/fixtures/utilities/font-source-declaration.scss +11 -0
  281. data/spec/fixtures/utilities/retrieve-bourbon-setting.scss +16 -0
  282. data/spec/fixtures/utilities/unpack.scss +17 -0
  283. data/spec/fixtures/validators/contains.scss +28 -0
  284. data/spec/fixtures/validators/is-length.scss +35 -0
  285. data/spec/fixtures/validators/is-light.scss +29 -0
  286. data/spec/fixtures/validators/is-number.scss +31 -0
  287. data/spec/fixtures/validators/is-size.scss +31 -0
  288. data/spec/spec_helper.rb +22 -0
  289. data/spec/support/matchers/have_rule.rb +35 -0
  290. data/spec/support/matchers/have_ruleset.rb +20 -0
  291. data/spec/support/matchers/have_value.rb +17 -0
  292. data/spec/support/parser_support.rb +16 -0
  293. data/spec/support/sass_support.rb +10 -0
  294. metadata +527 -0
@@ -0,0 +1,25 @@
1
+ @mixin show-breakpoints() {
2
+ body:after {
3
+ content:"> #{$max}px";
4
+ background-color:darken($red, 20);
5
+ bottom:0;
6
+ right:0;
7
+ padding:4px $pad0;
8
+ @include border-radius(5 top-left);
9
+ @include ani(background-color color);
10
+ @extend %no-pointerevents, %no-wrap;
11
+ position:fixed;
12
+ z-index:9999;
13
+ font-size:10px;
14
+ color:white;
15
+ text-align:center;
16
+ @each $name, $value in $breakpoints {
17
+ $random-color: random-colour();
18
+ @include break($value) {
19
+ content:"#{$name}: #{$value}px";
20
+ background-color:$random-color;
21
+ color:colour-contrast($random-color);
22
+ }
23
+ }
24
+ }
25
+ }
@@ -0,0 +1,648 @@
1
+ /// SassyStrings - v1.1.4 - 2015-12-06
2
+ /// Return character from `$string` at `$index`.
3
+ /// @since 1.2.0
4
+ /// @param {String} $string - string to check
5
+ /// @param {String} $index - index to inspect
6
+ /// @return {String}
7
+ @function _ss-char-at($string, $index) {
8
+ @return str-slice($string, $index, $index);
9
+ }
10
+
11
+ /// Calculating Levenshtein distance between strings `$a` and `$b`.
12
+ /// @since 1.2.0
13
+ /// @param {String} $a - first string
14
+ /// @param {String} $b - second string
15
+ /// @return {Number}
16
+ @function _ss-levenshtein($a, $b) {
17
+ $a: to-lower-case($a);
18
+ $b: to-lower-case($b);
19
+
20
+ $n: str-length($a);
21
+ $m: str-length($b);
22
+
23
+ $matrix: _ss-matrix($n + 1, $m + 1);
24
+ $cost: _ss-matrix($n, $m);
25
+
26
+ @if $a == $b { @return 0; }
27
+ @if $n == 0 { @return $m; }
28
+ @if $m == 0 { @return $n; }
29
+
30
+ @for $i from 0 through $n {
31
+ @for $j from 0 through $m {
32
+ $v: if($i == 0, $j, if($j == 0, $i, 0));
33
+ @if $v != 0 {
34
+ $matrix: _ss-set-matrix($matrix, $i + 1, $j + 1, $v);
35
+ }
36
+ @if $i != 0 and $j != 0 {
37
+ $v: if(str-slice($a, $i, $i) == str-slice($b, $j, $j), 0, 1);
38
+ @if $v != 0 {
39
+ $cost: _ss-set-matrix($cost, $i, $j, $v);
40
+ }
41
+ }
42
+ }
43
+ }
44
+
45
+ @for $i from 2 through length($matrix) {
46
+ @for $j from 2 through length(nth($matrix, $i)) {
47
+ $matrix: _ss-set-matrix($matrix, $i, $j, min(_ss-e($matrix, $i - 1, $j) + 1, _ss-e($matrix, $i, $j - 1) + 1, _ss-e($matrix, $i - 1, $j - 1) + _ss-e($cost, $i - 1, $j - 1)));
48
+ }
49
+ }
50
+
51
+ @return _ss-e($matrix, length($matrix), length(nth($matrix, 1)));
52
+ }
53
+
54
+ /// Helper to target an element in a matrix
55
+ /// @access private
56
+ /// @param {Number} $m - matrix
57
+ /// @param {Number} $x - x coord
58
+ /// @param {Number} $y - y coord
59
+ /// @return {Number}
60
+ @function _ss-e($m, $x, $y) {
61
+ @return nth(nth($m, $x), $y);
62
+ }
63
+
64
+ /// Helper instanciation a matrix of $x by $y
65
+ /// @access private
66
+ /// @param {Number} $x - number of cols
67
+ /// @param {Number} $y - number of lines
68
+ /// @return {List}
69
+ @function _ss-matrix($x, $y) {
70
+ $matrix: ();
71
+
72
+ @for $i from 1 through $x {
73
+ $tmp: ();
74
+
75
+ @for $y from 1 through $y {
76
+ $tmp: append($tmp, 0)
77
+ }
78
+
79
+ $matrix: append($matrix, $tmp);
80
+ }
81
+
82
+ @return $matrix;
83
+ }
84
+
85
+ /// Helper assigning $value at $matrix[$x, $y]
86
+ /// @access private
87
+ /// @param {Number} $matrix - matrix to update
88
+ /// @param {Number} $x - x coord
89
+ /// @param {Number} $y - y coord
90
+ /// @param {Number} $value - value to assign at $matrix[$x, $y]
91
+ /// @return {List}
92
+ @function _ss-set-matrix($matrix, $x, $y, $value) {
93
+ @return set-nth($matrix, $x, set-nth(nth($matrix, $x), $y, $value));
94
+ }
95
+
96
+ /// Count the number of occurrences of `$needle` in `$string`.
97
+ /// @since 1.2.0
98
+ /// @param {String} $string - string
99
+ /// @param {String} $needle - substring to count in `$string`
100
+ /// @return {Number}
101
+ @function _ss-str-count($string, $needle) {
102
+ $index: str-index($string, $needle);
103
+ $result: if($index, 1, 0);
104
+
105
+ @if $index {
106
+ @for $i from $index + str-length($needle) through str-length($string) {
107
+ @if str-slice($string, $i, $i + str-length($needle) - 1) == $needle {
108
+ $result: $result + 1;
109
+ }
110
+ }
111
+ }
112
+
113
+ @return $result;
114
+ }
115
+
116
+ /// Check whether `$string` ends with `$needle`.
117
+ /// @since 1.2.0
118
+ /// @param {String} $string - string to check
119
+ /// @param {String} $needle - substring to check
120
+ /// @return {Bool}
121
+ @function _ss-str-ends-with($string, $needle) {
122
+ @return str-slice($string, -1 * str-length($needle)) == $needle;
123
+ }
124
+
125
+ /// Split `$string` into several parts using `$delimiter`.
126
+ /// @since 1.2.0
127
+ /// @param {String} $string - string to split
128
+ /// @param {String} $delimiter ('') - string to use as a delimiter to split `$string`
129
+ /// @return {List}
130
+ @function _ss-str-explode($string, $delimiter: "") {
131
+ $result: ();
132
+ $length: str-length($string);
133
+
134
+ @if str-length($delimiter) == 0 {
135
+ @for $i from 1 through $length {
136
+ $result: append($result, str-slice($string, $i, $i));
137
+ }
138
+
139
+ @return $result;
140
+ }
141
+
142
+ $running: true;
143
+ $remaining: $string;
144
+
145
+ @while $running {
146
+ $index: str-index($remaining, $delimiter);
147
+
148
+ @if $index {
149
+ $slice: str-slice($remaining, 1, $index - 1);
150
+ $result: append($result, $slice);
151
+ $remaining: str-slice($remaining, $index + str-length($delimiter));
152
+ } @else {
153
+ $running: false;
154
+ }
155
+ }
156
+
157
+ @return append($result, $remaining);
158
+ }
159
+
160
+ /// Implode `$list` into a string.
161
+ /// @since 1.2.0
162
+ /// @param {List} $list - list to convert to string
163
+ /// @return {String}
164
+ @function _ss-str-implode($list) {
165
+ $result: "";
166
+
167
+ @each $item in $list {
168
+ $result: $result + if(length($item) > 1, str-implode($item), $item);
169
+ }
170
+
171
+ @return $result;
172
+ }
173
+
174
+ /// Return last index of `$needle` in `$string`.
175
+ /// @since 1.2.0
176
+ /// @param {String} $string - string to search in
177
+ /// @param {String} $needle - substring to search for
178
+ /// @return {Number}
179
+ @function _ss-str-last-index($string, $needle) {
180
+ $index: str-index($string, $needle);
181
+ $result: $index;
182
+
183
+ @if $index {
184
+ @for $i from $index + str-length($needle) through str-length($string) {
185
+ @if str-slice($string, $i, $i + str-length($needle) - 1) == $needle {
186
+ $result: $i;
187
+ }
188
+ }
189
+ }
190
+
191
+ @return $result;
192
+ }
193
+
194
+ /// Lower case first character of `$string`.
195
+ /// @since 1.2.0
196
+ /// @param {String} $string - string to lower the first character
197
+ /// @return {String}
198
+ @function _ss-str-lcfirst($string) {
199
+ @return to-lower-case(str-slice($string, 1, 1)) + str-slice($string, 2);
200
+ }
201
+
202
+ /// Pad `$string` from `$direction` with `$pad` to reach `$length` characters.
203
+ /// @since 1.2.0
204
+ /// @param {String} $string - string to pad
205
+ /// @param {Number} $length - number of characters to go for in returned string
206
+ /// @param {String} $pad (" ") - string to use to pad `$string`
207
+ /// @param {String} $direction (left) - direction left or right for padding
208
+ /// @return {String}
209
+ @function _ss-str-pad($string, $length, $pad: " ", $direction: left) {
210
+ $new-string: $string;
211
+ $index: 1;
212
+
213
+ @if $length > str-length($string) {
214
+ @while str-length($new-string) < $length {
215
+ $remains: $length - str-length($new-string);
216
+ $pad: if($remains < str-length($pad), str-slice($pad, 1, $remains), $pad);
217
+
218
+ @if $direction == left {
219
+ $new-string: str-insert($new-string, $pad, $index);
220
+ $index: $index + str-length($pad);
221
+ } @else {
222
+ $new-string: $new-string + $pad;
223
+ }
224
+ }
225
+ }
226
+
227
+ @return $new-string;
228
+ }
229
+
230
+ /// Replace occurrences of `%s` in `$string` by `$elements`.
231
+ /// @since 1.2.0
232
+ /// @param {String} $string - string to check
233
+ /// @param {Arglist} $elements - strings to use for replacements in `%s`
234
+ /// @return {String}
235
+ @function _ss-str-printf($string, $elements...) {
236
+ $breaker: "%s";
237
+ $result: $string;
238
+
239
+ @each $element in $elements {
240
+ $index: str-index($result, $breaker);
241
+ @if $index {
242
+ $result: str-slice($result, 1, $index - 1) + _ss-stringify($element) + str-slice($result, $index + str-length($breaker));
243
+ } @else {
244
+ @return $result;
245
+ }
246
+ }
247
+
248
+ @return $result;
249
+ }
250
+
251
+ /// Repeat `$string` `$times` times.
252
+ /// @since 1.2.0
253
+ /// @param {String} $string - string to repeat
254
+ /// @param {Number} $times - number of times to repeat $string
255
+ /// @return {String}
256
+ @function _ss-str-repeat($string, $times) {
257
+ $result: "";
258
+
259
+ @for $i from 1 through $times {
260
+ $result: $result + $string;
261
+ }
262
+
263
+ @return $result;
264
+ }
265
+
266
+ /// Replace `$search` with `$replace` in `$string`.
267
+ /// @since 1.2.0
268
+ /// @param {String} $string - Initial string
269
+ /// @param {String} $search - Substring to replace
270
+ /// @param {String} $replace ("") - New value
271
+ /// @return {String} - Updated string
272
+ @function _ss-str-replace($string, $search, $replace: "") {
273
+ $index: str-index($string, $search);
274
+
275
+ @if $index {
276
+ @return str-slice($string, 1, $index - 1) + $replace + _ss-str-replace(str-slice($string, $index + str-length($search)), $search, $replace);
277
+ }
278
+
279
+ @return $string;
280
+ }
281
+
282
+ /// Reverse `$string`.
283
+ /// @since 1.2.0
284
+ /// @param {String} $string - string to reverse
285
+ /// @return {String}
286
+ @function _ss-str-reverse($string) {
287
+ $result: "";
288
+
289
+ @for $i from str-length($string) through 1 {
290
+ $result: $result + str-slice($string, $i, $i);
291
+ }
292
+
293
+ @return $result;
294
+ }
295
+
296
+ /// Rotate all characters from the alphabet in `$string` by `$rot` positions.
297
+ /// @since 1.2.0
298
+ /// @param {String} $string - string to rotate
299
+ /// @param {Number} $rot (13) - number of positions to switch in alphabet
300
+ /// @return {String}
301
+ @function _ss-str-rot($string, $rot: 13) {
302
+ $alphabet: a b c d e f g h i j k l m n o p q r s t u v w x y z;
303
+ $result: "";
304
+
305
+ @for $i from 1 through str-length($string) {
306
+ $char: str-slice($string, $i, $i);
307
+ $index: index($alphabet, to-lower-case($char));
308
+ $is-caps: $index and (index($alphabet, to-lower-case($char)) != index($alphabet, $char));
309
+ $new-char: if($index,
310
+ if($index + $rot > length($alphabet),
311
+ nth($alphabet, $index + $rot - length($alphabet)),
312
+ nth($alphabet, $index + $rot)
313
+ ),
314
+ $char
315
+ );
316
+
317
+ @if $is-caps {
318
+ $new-char: to-upper-case($new-char);
319
+ }
320
+
321
+ $result: $result + $new-char;
322
+ }
323
+
324
+ @return $result;
325
+ }
326
+
327
+ /// Shuffle characters from `$string`.
328
+ /// @since 1.2.0
329
+ /// @param {String} $string - string to shuffle
330
+ /// @return {String}
331
+ @function _ss-str-shuffle($string) {
332
+ @return str-implode(_ss-shuffle(str-explode($string)));
333
+ }
334
+
335
+ /// Shuffle a list
336
+ /// @access private
337
+ /// @param {List} $list - shuffle a list
338
+ /// @return {List}
339
+ @function _ss-shuffle($list) {
340
+ @for $i from length($list) through 1 {
341
+ $j: random(length($list) - 1) + 1;
342
+ $tmp: nth($list, $i);
343
+ $list: set-nth($list, $i, nth($list, $j));
344
+ $list: set-nth($list, $j, $tmp);
345
+ }
346
+
347
+ @return $list;
348
+ }
349
+
350
+ /// Check whether `$string` stars with `$needle`.
351
+ /// @since 1.2.0
352
+ /// @param {String} $string - string to check
353
+ /// @param {String} $needle - substring to check
354
+ /// @return {Bool}
355
+ @function _ss-str-starts-with($string, $needle) {
356
+ @return str-slice($string, 1, str-length($needle)) == $needle;
357
+ }
358
+
359
+ /// Remove all trailing and leading whitespaces from `$string`.
360
+ /// @since 1.2.0
361
+ /// @param {String} $string - string
362
+ /// @return {String}
363
+ @function _ss-str-trim($string) {
364
+ $start: 1;
365
+ $end: str-length($string);
366
+
367
+ @for $i from 1 through str-length($string) {
368
+ $first: str-slice($string, $i, $i);
369
+ $last: str-slice($string, -$i, -$i);
370
+
371
+ @if $first == " " and $i + 1 == $start + 1 {
372
+ $start: $i + 1;
373
+ }
374
+
375
+ @if $last == " " and str-length($string) - $i == $end - 1 {
376
+ $end: str-length($string) - $i;
377
+ }
378
+ }
379
+
380
+ @return str-slice($string, $start, $end);
381
+ }
382
+
383
+ /// Capitalize first letter from `$string`.
384
+ /// @since 1.2.0
385
+ /// @param {String} $string - string for capitalization
386
+ /// @return {String}
387
+ @function _ss-str-ucfirst($string) {
388
+ @return to-upper-case(str-slice($string, 1, 1)) + str-slice($string, 2);
389
+ }
390
+
391
+ /// Count number of words in `$string`.
392
+ /// @since 1.2.0
393
+ /// @param {String} $string - string to check
394
+ /// @return {String}
395
+ @function _ss-str-word-count($string) {
396
+ @if $string == "" {
397
+ @return 0;
398
+ }
399
+
400
+ $string: str-trim($string);
401
+ $words: ();
402
+ $i: str-length($string);
403
+
404
+ @while $i > 0 {
405
+ @if str-slice($string, $i, $i) == " " {
406
+ $words: append($words, str-slice($string, $i + 1));
407
+ $string: str-slice($string, 1, $i - 1);
408
+ }
409
+ $i: $i - 1;
410
+ }
411
+
412
+ @return length(append($words, $string));
413
+ }
414
+
415
+ /// Cast `$literal` to string.
416
+ /// @since 1.2.0
417
+ /// @param {*} $literal - number to cast to string
418
+ /// @return {String}
419
+ @function _ss-stringify($literal) {
420
+ $result: "";
421
+
422
+ @if length($literal) == 1 {
423
+ $result: $literal + unquote("");
424
+ } @else {
425
+ @each $item in $literal {
426
+ $result: $result + stringify($item);
427
+ }
428
+ }
429
+
430
+ @return quote($result);
431
+ }
432
+
433
+ @function char-at($string, $index) {
434
+ @if type-of($string) != "string" {
435
+ @error "`char-at` function expecting a string for $string; #{type-of($string)} given.";
436
+ }
437
+
438
+ @if type-of($index) != "number" {
439
+ @error "`char-at` function expecting a number for $index; #{type-of($index)} given.";
440
+ }
441
+
442
+ @if $index < 1 or $index > str-length($string) {
443
+ @error "Out of bounds $index for `char-at`.";
444
+ }
445
+
446
+ @return _ss-char-at($string, $index);
447
+ }
448
+
449
+ @function levenshtein($a, $b) {
450
+ @if type-of($a) != "string" {
451
+ @error "`str-count` function expecting a string for $a; #{type-of($a)} given.";
452
+ }
453
+
454
+ @if type-of($b) != "string" {
455
+ @error "`str-count` function expecting a string for $b; #{type-of($b)} given.";
456
+ }
457
+
458
+ @return _ss-levenshtein($a, $b);
459
+ }
460
+
461
+ @function str-count($string, $needle) {
462
+ @if type-of($string) != "string" {
463
+ @error "`str-count` function expecting a string for $string; #{type-of($string)} given.";
464
+ }
465
+
466
+ @if type-of($needle) != "string" {
467
+ @error "`str-count` function expecting a string for $needle; #{type-of($needle)} given.";
468
+ }
469
+
470
+ @return _ss-str-count($string, $needle);
471
+ }
472
+
473
+ @function str-ends-with($string, $needle) {
474
+ @if type-of($string) != "string" {
475
+ @error "`str-starts-with` function expecting a string for $string; #{type-of($string)} given.";
476
+ }
477
+
478
+ @if type-of($needle) != "string" {
479
+ @error "`str-starts-with` function expecting a string for $needle; #{type-of($needle)} given.";
480
+ }
481
+
482
+ @return _ss-str-ends-with($string, $needle);
483
+ }
484
+
485
+ @function str-explode($string, $delimiter: '') {
486
+ @if type-of($string) != "string" {
487
+ @error "`explode` function expecting a string; #{type-of($string)} given.";
488
+ }
489
+
490
+ @if type-of($delimiter) != "string" {
491
+ @error "`explode` function expecting a string; #{type-of($delimiter)} given.";
492
+ }
493
+
494
+ @return _ss-str-explode($string, $delimiter);
495
+ }
496
+
497
+ @function str-implode($list) {
498
+ @if type-of($list) != "list" {
499
+ @error '$list for str-implode must be a list';
500
+ }
501
+
502
+ @return _ss-str-implode($list);
503
+ }
504
+
505
+ @function str-last-index($string, $needle) {
506
+ @if type-of($string) != "string" {
507
+ @error "`str-last-index` function expecting a string for $string; #{type-of($string)} given.";
508
+ }
509
+
510
+ @if type-of($needle) != "string" {
511
+ @error "`str-last-index` function expecting a string for $needle; #{type-of($needle)} given.";
512
+ }
513
+
514
+ @return _ss-str-last-index($string, $needle);
515
+ }
516
+
517
+ @function str-lcfirst($string) {
518
+ @if type-of($string) != "string" {
519
+ @error "`str-lcfirst` function expecting a string for $string; #{type-of($string)} given.";
520
+ }
521
+
522
+ @return _ss-str-lcfirst($string);
523
+ }
524
+
525
+ @function str-pad($string, $length, $pad: " ", $direction: left) {
526
+ @if type-of($string) != "string" {
527
+ @error "`str-pad` function expecting a string for $string; #{type-of($string)} given.";
528
+ }
529
+
530
+ @if type-of($pad) != "string" {
531
+ @error "`str-pad` function expecting a string for $pad; #{type-of($pad)} given.";
532
+ }
533
+
534
+ @if type-of($length) != "number" {
535
+ @error "`str-pad` function expecting a number for $length; #{type-of($length)} given.";
536
+ }
537
+
538
+ @if index(left right, $direction) == null {
539
+ @error "`str-pad` function expecting either `left` or `right` for $direction: #{$direction} given.";
540
+ }
541
+
542
+ @return _ss-str-pad($string, $length, $pad, $direction);
543
+ }
544
+
545
+ @function str-printf($string, $elements...) {
546
+ @if type-of($string) != "string" {
547
+ @error "`str-printf` function expecting a string for $string; #{type-of($string)} given.";
548
+ }
549
+
550
+ @return _ss-str-printf($string, $elements...);
551
+ }
552
+
553
+ @function str-repeat($string, $times) {
554
+ @if type-of($string) != "string" {
555
+ @error "`str-repeat` function expecting a string for $string; #{type-of($string)} given.";
556
+ }
557
+
558
+ @if type-of($times) != "number" {
559
+ @error "`str-repeat` function expecting a number for $times; #{type-of($times)} given.";
560
+ }
561
+
562
+ @return _ss-str-repeat($string, $times);
563
+ }
564
+
565
+ @function str-replace($string, $search, $replace: '') {
566
+ @if type-of($string) != "string" {
567
+ @error "`str-replace` function expecting a string for $string; #{type-of($string)} given.";
568
+ }
569
+
570
+ @if type-of($search) != "string" {
571
+ @error "`str-replace` function expecting a string for $search; #{type-of($search)} given.";
572
+ }
573
+
574
+ @if type-of($replace) != "string" {
575
+ @error "`str-replace` function expecting a string for $replace; #{type-of($replace)} given.";
576
+ }
577
+
578
+ @return _ss-str-replace($string, $search, $replace);
579
+ }
580
+
581
+
582
+ @function str-reverse($string) {
583
+ @if type-of($string) != "string" {
584
+ @error "`str-reverse` function expecting a string for $string; #{type-of($string)} given.";
585
+ }
586
+
587
+ @return _ss-str-reverse($string);
588
+ }
589
+
590
+ @function str-rot($string, $rot: 13) {
591
+ @if type-of($string) != "string" {
592
+ @error "`str-rot` function expecting a string for $string; #{type-of($string)} given.";
593
+ }
594
+
595
+ @if type-of($rot) != "number" {
596
+ @error "`str-rot` function expecting a number for $rot; #{type-of($rot)} given.";
597
+ }
598
+
599
+ @return _ss-str-rot($string, $rot);
600
+ }
601
+
602
+ @function str-shuffle($string) {
603
+ @if type-of($string) != string {
604
+ @error '$string of str-shuffle must be a string';
605
+ }
606
+
607
+ @return _ss-str-shuffle($string);
608
+ }
609
+
610
+ @function str-starts-with($string, $needle) {
611
+ @if type-of($string) != "string" {
612
+ @error "`str-starts-with` function expecting a string for $string; #{type-of($string)} given.";
613
+ }
614
+
615
+ @if type-of($needle) != "string" {
616
+ @error "`str-starts-with` function expecting a string for $needle; #{type-of($needle)} given.";
617
+ }
618
+
619
+ @return _ss-str-starts-with($string, $needle);
620
+ }
621
+
622
+ @function str-trim($string) {
623
+ @if type-of($string) != "string" {
624
+ @error "`str-trim` function expecting a string for $string; #{type-of($string)} given.";
625
+ }
626
+
627
+ @return _ss-str-trim($string);
628
+ }
629
+
630
+ @function str-ucfirst($string) {
631
+ @if type-of($string) != "string" {
632
+ @error "`str-ucfirst` function expecting a string for $string; #{type-of($string)} given.";
633
+ }
634
+
635
+ @return _ss-str-ucfirst($string);
636
+ }
637
+
638
+ @function str-word-count($string) {
639
+ @if type-of($string) != "string" {
640
+ @error "`str-word-count` function expecting a string for $string; #{type-of($string)} given.";
641
+ }
642
+
643
+ @return _ss-str-word-count($string);
644
+ }
645
+
646
+ @function stringify($literal) {
647
+ @return _ss-stringify($literal);
648
+ }