Added custom data attributes, character escape function, and character class for kerning pairs#45
Added custom data attributes, character escape function, and character class for kerning pairs#45alienresident wants to merge 8 commits intodavatron5000:masterfrom
Conversation
Added `item` to "data-character" a custom HTML 5 data attribute of the span. This can then be called by pseudo elements using `content: attr(data-character);`. This works for my [use case](http://codepen.io/alienresident/pen/mhqrj) but I think it would be more useful to add `data-{method}="'+item+'"`. So you could have data-character, data-word, data-line attributes depending on what method(s) you used. I am not sure how to do this.... It may also be useful to call this only if you want this by calling an additional argument. Thoughts?
Added +item+ as a custom data attribute for pseudo element magic. Added +item+ as a class so you can create kerning pair rules
If statement to figure out the method. If it's 'char' it's adds a class char - item value i.e. If the letter is 'a' it's adds a class of 'char-a'. This allows you create kerning pairs. You can create kerning pair rules for all the character combos. You won't need to know the content beforehand. Use case could be on a CMS where you won't know the headings beforehand but want strict kerning rules.
|
Thanks for this commit. Really pulling things together. Let's figure this out b/c there's quite a few requests that do the same thing but they've all become a little too complex. char-* classesThe /* Edit: Updated example. It's too early. Need more coffee */
[data-char="a"] + [data-char="b"] {
/* do something */
}Escaped charactersEDIT: Re-re-read and looked at your
Non-latin languagesI think you've solved it the best with a limited escape set, but are we sure this problem is solved fairly well? Next stepsWhat might make sense is schedule this for a |
From Dave Rupert's comment of the PR we don't need the extra char-* we can use [data-char="*"] instead. Brillant!
|
Hi Dave, Removed the
|
It might be a EDIT: On second thought, removing space-wrapping may actually break kerning pairs since two words would be next to each other. 😦 |
I was breaking the space character!In the escape function I was breaking the space character! |
|
Opened up <div id="demo3" class="demo">
<p>
<span class="line1" data-line="This is an amazing">This is an amazing</span>
<span class="line2" data-line=" Revolution in Typography. "> Revolution in Typography. </span>
<span class="line3" data-line=" The possibilities are endless: "> The possibilities are endless: </span>
<span class="line4" data-line=" Coloring, Vertical spacing, and Kerning."> Coloring, Vertical spacing, and Kerning.</span>
</p>
</div>Looks like we might have to |
|
Bookmarking: Escape function from #7 might be useful here for a complete escaping setup (if we still need it in the Lettering.js/jquery.lettering.js Lines 14 to 30 in 80d53da |
Changes to LetteringJS
data-char,data-wordanddata-linechar - item valuei.e. If the letter isait's adds a class ofchar-a.\i.eclass="char-&"can be styled.char-\&see CSS character escape sequences for more details.Use cases (codepens)
Collection of examples LetteringJS Collection
Incorporates Ideas/Work from Other Pull Requests
#41 Add a character-specific class to letters
#26 Add data-content='item' attribute to the generated span tags
#6 Added additional classes
I am sure I have missed something and this approach may be overly simplistic.
Thanks,
Mark