jonnybarnes / emoji-a11y
Make emoji more accessible
Installs: 1 209
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: >=7.0
Requires (Dev)
- phpunit/phpunit: ~6.0
This package is auto-updated.
Last update: 2024-11-04 23:06:51 UTC
README
Make emoji more accessible.
Install
Add this package with composer:
composer require jonnybarnes/emoji-a11y
Usage
Anywhere you have some text with emoji use the makeEmojiAccessible
method.
$emoji = new Jonnybarnes\EmojiA11y\EmojiModifier();
$text = 'I’m 😀';
$emoji->makeEmojiAccessible($text); // I’m <span role="img" aria-label="grinning face">😀</span>
Customise HTML
You can pass in a string to the constructor that will be used in the
makeEmojiAccessible
method. We use PHP’s sprinf
function.
Three variables are passed into the function. The desired output form, then the
text of the emoji, then the matched emoji character. Thankfully sprintf
allows
you to swap variable order if you need to, see example 3 in the manual.
Of course you need to provide your own CSS for presentation.
Inspired by http://adrianroselli.com/2016/12/accessible-emoji-tweaked.html