Skip to content

Instantly share code, notes, and snippets.

@TravisMullen
Last active June 8, 2017 18:19
Show Gist options
  • Save TravisMullen/e8a94383f626b66ddf2cdcbddcb2024b to your computer and use it in GitHub Desktop.
Save TravisMullen/e8a94383f626b66ddf2cdcbddcb2024b to your computer and use it in GitHub Desktop.
Wrap each char of a string with indexed class
// es6
export function injector (_text, _classPrefix) {
let text
let inject = []
const prefix = _classPrefix || 'char-'
if (typeof (_text) !== 'string') {
text = _text.toString()
} else {
text = _text
}
if (text.length) {
for (const letter in text) {
let index = parseInt(letter, 10) + 1
inject.push(`<span class="${prefix + index}" aria-hidden="true">${text[letter]}</span>`)
}
}
inject = inject.join('')
return inject
}
// scss
// @mixin rotated-text($num-letters: 100, $angle-span: 180deg, $angle-offset: 0deg) {
// $angle-per-char: $angle-span / $num-letters;
// @for $i from 1 through $num-letters {
// .char#{$i} {
// @include transform(rotate($angle-offset + $angle-per-char * $i))
// }
// }
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment