Hi elm-discuss!
I'm Travis Parker ("tjp" on slack) and I've just recently started using
elm, first for an internal project at work (so not public code, a green
field project though!) and now for a separate, personal project.
I've been working with emojis
<https://hello.pixinote.com/moments/2016/9/21/pixinote-emojified> a lot
recently and couldn't find anything like Twemoji
<https://github.com/twitter/twemoji> for Elm, so I decided I'd create it!
Having recently written code to parse emojis out of user-provided text I
already had the problem at the top of my mind (though it's much nicer in
Elm than it was in Go).
Sidenote: that's the hard part of emoji handling because the characater
sequences for emojis are variable length and worse, some are prefixes of
others, so even after finding a match you have to continue searching. The
good news is I tackled that problem first and it works
<https://github.com/teepark/elmoji/blob/master/Elmoji.elm#L18>! There's a
demo in Example.elm
<https://github.com/teepark/elmoji/blob/master/Example.elm>.
So now I'm turning my attention to the public API and wanted to get
feedback. Some thoughts I'd bounce off the list:
- Twemoji supports passing it a DOM node and it would replace all
text-based emojis with <img> tags. I can do that
<https://github.com/teepark/elmoji/blob/master/Elmoji/Html.elm#L11> but
only for Strings, since Html is an opaque type. Is there a good workaround?
Is it even worth it? With the API I've already got you can build an
emoji-converting replacement for Html.text, which feels pretty good (well
almost a replacement -- since it also drops images inline it has to return
"List Html a").
- Given Twemoji's existence it seems like I should support that, but
EmojiOne <http://emojione.com/> is also out there (that's my choice in
fact) so I currently allow the user to specify the means of "List String ->
Html a" (list of strings because those are the hexadecimal unicode code
points for an emoji). I can provide pre-fab converters
<https://github.com/teepark/elmoji/blob/master/Elmoji/Html.elm#L41> for
those two, does that seem like the right level of abstraction? I don't want
to go too abstract (hat tip: Design Guidelines). It also occurs to me that
you could have a more advanced replacer that puts the original characters
back in wrapped in an <i> with font opacity 0 and the image as a background
-- then it would both display correctly and be copy/paste-able, but only
with this slightly more abstract API to allow it.
- I know it needs docs, examples in those docs, and tests, but anything
else I should know or consider when packaging this up for public
consumption?
Thanks!
Travis
--
You received this message because you are subscribed to the Google Groups "Elm
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.