Add a skin tone mapping fixture for emoji
What does this MR do and why?
Adds Gitlab::Emoji::SkinTones, which works out from the TanukiEmoji index which emoji is a skin tone variant of which base emoji, and a rake task tanuki_emoji:skin_tones that writes the result to fixtures/emojis/skin_tones.json.
Nothing reads the fixture yet and no runtime behaviour changes. This is the first step of &24004 (default emoji skin tone). The consumers are #633107 (the user preference and APIs), #633108 (server-side reaction toggling) and #633110 (the web picker, which bundles the fixture the same way it bundles fixtures/emojis/aliases.json).
Related to #633106.
Why the mapping comes from codepoints, and why a fixture
- Emoji names cannot be used to find a base: 415 toned names end in
_tone1.._tone5, 1,460 end in_skin_tone, and 5 are the bare modifierstone1..tone5. Stripping the tone modifiers (U+1F3FB..U+1F3FF) and the variation selector (U+FE0F, whichspycarries while its tones do not) from the glyph gives the base reliably: 322 base emoji, each with exactly five variants. - Two-person emoji whose people have different tones (260 names, for example
handshake_light_skin_tone_medium_skin_tone) have no single tone. They are listed undermixedinstead of being mapped to a base, so consumers can hide or keep them deliberately. - Three names are registered twice in the gem (
man_in_tuxedois🤵 and🤵♂️ , alsobeetleandcricket). The module keeps the characterTanukiEmoji.find_by_alpha_codereturns, so the mapping agrees with the rest of the backend. Renaming them upstream would change what stored:beetle:and:cricket:awards render as, so that is tracked in gitlab-org/ruby/gems/tanuki_emoji#43 and not part of this change. The fiveman_in_tuxedo_*_skin_tonevariants belong to🤵♂️ and therefore have no base. They are listed underunmappedso consumers can treat them as variants rather than plain emoji. - A file under
fixtures/emojis/follows the existingaliases.jsonandintents.jsonpattern, which the frontend imports through theemojis/alias. Adding the data toemojis.jsonwould require an emoji asset version bump, which copies 3,780 files (24 MB). - The fixture-freshness spec fails if the committed JSON differs from a fresh generation, so the generated file does not need to be reviewed by hand.
References
- Epic: &24004
- Issue: #633106
- Documentation step:
doc/development/fe_guide/emojis.md
Screenshots or screen recordings
No UI change.
How to set up and validate locally
-
bundle exec rake tanuki_emoji:skin_tonesproduces no diff on this branch. -
bin/rspec spec/lib/gitlab/emoji/skin_tones_spec.rbpasses. -
In a Rails console:
Gitlab::Emoji::SkinTones.variants_for('thumbsup') # => ["thumbsup_tone1", "thumbsup_tone2", "thumbsup_tone3", "thumbsup_tone4", "thumbsup_tone5"] Gitlab::Emoji::SkinTones.base_name('people_holding_hands_medium_skin_tone') # => "people_holding_hands" Gitlab::Emoji::SkinTones.mixed_tone_names.size # => 260 Gitlab::Emoji::SkinTones.unmapped_names.size # => 5
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.