File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ describe('emoji', () => {
7676
7777 it ( 'skips the textual presentation VS15 character' , ( ) => {
7878 expect ( emojify ( '✴︎' ) ) // This is U+2734 EIGHT POINTED BLACK STAR then U+FE0E VARIATION SELECTOR-15
79- . toEqual ( '<img draggable="false" class="emojione" alt="✴" title=":eight_pointed_black_star:" src="/emoji/2734 .svg" />' ) ;
79+ . toEqual ( '<img draggable="false" class="emojione" alt="✴" title=":eight_pointed_black_star:" src="/emoji/2734_border .svg" />' ) ;
8080 } ) ;
8181 } ) ;
8282} ) ;
Original file line number Diff line number Diff line change @@ -6,6 +6,15 @@ const trie = new Trie(Object.keys(unicodeMapping));
66
77const assetHost = process . env . CDN_HOST || '' ;
88
9+ // Emoji requiring extra borders depending on theme
10+ const darkEmoji = '🎱🐜⚫🖤⬛◼️◾◼️✒️▪️💣🎳📷📸♣️🕶️✴️🔌💂♀️📽️🍳🦍💂🔪🕳️🕹️🕋🖊️🖋️💂♂️🎤🎓🎥🎼♠️🎩🦃📼📹🎮🐃🏴' ;
11+ const lightEmoji = '👽⚾🐔☁️💨🕊️👀🍥👻🐐❕❔⛸️🌩️🔊🔇📃🌧️🐏🍚🍙🐓🐑💀☠️🌨️🔉🔈💬💭🏐🏳️⚪⬜◽◻️▫️' ;
12+
13+ const emojiFilename = ( filename , match ) => {
14+ const borderedEmoji = document . body . classList . contains ( 'theme-mastodon-light' ) ? lightEmoji : darkEmoji ;
15+ return borderedEmoji . includes ( match ) ? ( filename + '_border' ) : filename ;
16+ } ;
17+
918const emojify = ( str , customEmojis = { } ) => {
1019 const tagCharsWithoutEmojis = '<&' ;
1120 const tagCharsWithEmojis = Object . keys ( customEmojis ) . length ? '<&:' : '<&' ;
@@ -60,7 +69,7 @@ const emojify = (str, customEmojis = {}) => {
6069 } else { // matched to unicode emoji
6170 const { filename, shortCode } = unicodeMapping [ match ] ;
6271 const title = shortCode ? `:${ shortCode } :` : '' ;
63- replacement = `<img draggable="false" class="emojione" alt="${ match } " title="${ title } " src="${ assetHost } /emoji/${ filename } .svg" />` ;
72+ replacement = `<img draggable="false" class="emojione" alt="${ match } " title="${ title } " src="${ assetHost } /emoji/${ emojiFilename ( filename , match ) } .svg" />` ;
6473 rend = i + match . length ;
6574 // If the matched character was followed by VS15 (for selecting text presentation), skip it.
6675 if ( str . codePointAt ( rend ) === 65038 ) {
Original file line number Diff line number Diff line change @@ -39,3 +39,5 @@ $account-background-color: $white !default;
3939@function lighten ($color , $amount ) {
4040 @return hsl (hue ($color ), saturation ($color ), lightness ($color ) - $amount );
4141}
42+
43+ $emojis-requiring-inversion : ' chains' ;
Original file line number Diff line number Diff line change 1- $black- emojis : ' 8ball ' ' ant ' ' back' ' black_circle ' ' black_heart ' ' black_large_square ' ' black_medium_small_square ' ' black_medium_square ' ' black_nib ' ' black_small_square ' ' bomb ' ' bowling ' ' bust_in_silhouette ' ' busts_in_silhouette ' ' camera ' ' camera_with_flash ' ' clubs ' ' copyright' ' curly_loop' ' currency_exchange' ' dark_sunglasses ' ' eight_pointed_black_star ' ' electric_plug ' ' end' ' female-guard ' ' film_projector ' ' fried_egg ' ' gorilla ' ' guardsman ' ' heavy_check_mark' ' heavy_division_sign' ' heavy_dollar_sign' ' heavy_minus_sign' ' heavy_multiplication_x' ' heavy_plus_sign' ' hocho ' ' hole ' ' joystick ' ' kaaba ' ' lower_left_ballpoint_pen ' ' lower_left_fountain_pen ' ' male-guard ' ' microphone ' ' mortar_board ' ' movie_camera ' ' musical_score ' ' on' ' registered' ' soon' ' spades ' ' speaking_head_in_silhouette ' ' spider' ' telephone_receiver' ' tm' ' top' ' tophat ' ' turkey ' ' vhs ' ' video_camera ' ' video_game ' ' water_buffalo ' ' waving_black_flag ' ' wavy_dash' ;
1+ $emojis-requiring-inversion : ' back' ' copyright' ' curly_loop' ' currency_exchange' ' end' ' heavy_check_mark' ' heavy_division_sign' ' heavy_dollar_sign' ' heavy_minus_sign' ' heavy_multiplication_x' ' heavy_plus_sign' ' on' ' registered' ' soon' ' spider' ' telephone_receiver' ' tm' ' top' ' wavy_dash' !default ;
22
3- %white-emoji-outline {
4- filter : drop-shadow (1px 1px 0 $white ) drop-shadow (-1px 1px 0 $white ) drop-shadow (1px -1px 0 $white ) drop-shadow (-1px -1px 0 $white );
5- transform : scale (.71 );
3+ %emoji-color-inversion {
4+ filter : invert (1 );
65}
76
87.emojione {
9- @each $emoji in $black- emojis {
8+ @each $emoji in $emojis-requiring-inversion {
109 & [title = ' :#{$emoji } :' ] {
11- @extend %white- emoji-outline ;
10+ @extend %emoji-color-inversion ;
1211 }
1312 }
1413}
You can’t perform that action at this time.
0 commit comments