pinafore/routes/_components/profile/AccountDisplayName.html
Nolan Lawson af1d4b63d3
better support for de-emojified user display names (#451)
improvements to #450 to fix #449, especially for aria labels
2018-08-19 19:31:54 -07:00

32 lines
1.1 KiB
HTML

<span class="account-display-name">{@html massagedAccountName }</span>
<style>
.account-display-name {
pointer-events: none; /* allows focus to work correctly, focus on the parent only */
}
</style>
<script>
import { emojifyText } from '../../_utils/emojifyText'
import { store } from '../../_store/store'
import escapeHtml from 'escape-html'
import { removeEmoji } from '../../_utils/removeEmoji'
export default {
store: () => store,
computed: {
emojis: ({ account }) => (account.emojis || []),
accountName: ({ account }) => (account.display_name || account.username),
massagedAccountName: ({ accountName, emojis, $autoplayGifs, $omitEmojiInDisplayNames }) => {
accountName = escapeHtml(accountName)
if ($omitEmojiInDisplayNames) { // display name emoji are annoying to some screenreader users
let emojiFreeDisplayName = removeEmoji(accountName, emojis)
if (emojiFreeDisplayName) {
return emojiFreeDisplayName
}
}
return emojifyText(accountName, emojis, $autoplayGifs)
}
}
}
</script>