2019-05-06 05:08:54 +00:00
|
|
|
<!-- accessible autocomplete, based on https://haltersweb.github.io/Accessibility/autocomplete.html -->
|
|
|
|
<ul id="compose-autosuggest-list-{realm}"
|
|
|
|
class="compose-autosuggest-list"
|
|
|
|
role="listbox"
|
|
|
|
>
|
2018-08-25 04:35:02 +00:00
|
|
|
{#each items as item, i (item.shortcode ? `emoji-${item.shortcode}` : `account-${item.id}`)}
|
2019-05-06 05:08:54 +00:00
|
|
|
<li id="{i === selected ? `compose-autosuggest-active-item-${realm}` : ''}"
|
|
|
|
class="compose-autosuggest-list-item {i === selected ? 'selected' : ''}"
|
|
|
|
role="option"
|
|
|
|
aria-selected="{i === selected}"
|
|
|
|
aria-label="{ariaLabels[i]}"
|
|
|
|
on:click="onClick(event, item)"
|
|
|
|
>
|
|
|
|
<div class="compose-autosuggest-list-grid" aria-hidden="true">
|
2018-05-02 00:05:36 +00:00
|
|
|
{#if type === 'account'}
|
2018-08-25 04:35:02 +00:00
|
|
|
<div class="compose-autosuggest-list-item-avatar">
|
|
|
|
<Avatar
|
|
|
|
size="small"
|
|
|
|
account={item}
|
|
|
|
/>
|
|
|
|
</div>
|
2018-03-25 19:24:38 +00:00
|
|
|
<span class="compose-autosuggest-list-display-name">
|
2018-08-19 22:23:40 +00:00
|
|
|
<AccountDisplayName account={item} />
|
2018-03-25 01:04:54 +00:00
|
|
|
</span>
|
2018-03-25 19:24:38 +00:00
|
|
|
<span class="compose-autosuggest-list-username">
|
2018-05-02 00:05:36 +00:00
|
|
|
{'@' + item.acct}
|
2018-03-25 01:04:54 +00:00
|
|
|
</span>
|
2018-05-02 00:05:36 +00:00
|
|
|
{:else}
|
|
|
|
<img src={$autoplayGifs ? item.url : item.static_url}
|
2018-03-25 19:24:38 +00:00
|
|
|
class="compose-autosuggest-list-item-icon"
|
2018-05-02 00:05:36 +00:00
|
|
|
alt="{':' + item.shortcode + ':'}"
|
2018-03-25 19:24:38 +00:00
|
|
|
/>
|
|
|
|
<span class="compose-autosuggest-list-display-name">
|
2018-05-02 00:05:36 +00:00
|
|
|
{':' + item.shortcode + ':'}
|
2018-03-25 19:24:38 +00:00
|
|
|
</span>
|
2018-05-02 00:05:36 +00:00
|
|
|
{/if}
|
2018-03-25 01:04:54 +00:00
|
|
|
</div>
|
|
|
|
</li>
|
2018-05-02 00:05:36 +00:00
|
|
|
{/each}
|
2018-03-25 01:04:54 +00:00
|
|
|
</ul>
|
|
|
|
<style>
|
2018-03-25 19:24:38 +00:00
|
|
|
.compose-autosuggest-list {
|
2018-03-25 01:04:54 +00:00
|
|
|
list-style: none;
|
|
|
|
width: 100%;
|
|
|
|
border-radius: 2px;
|
|
|
|
box-sizing: border-box;
|
|
|
|
border: 1px solid var(--compose-autosuggest-outline);
|
|
|
|
}
|
2018-03-25 19:24:38 +00:00
|
|
|
.compose-autosuggest-list-item {
|
2018-03-25 01:04:54 +00:00
|
|
|
border-bottom: 1px solid var(--compose-autosuggest-outline);
|
|
|
|
display: flex;
|
|
|
|
padding: 10px;
|
|
|
|
background: var(--settings-list-item-bg);
|
|
|
|
margin: 0;
|
|
|
|
flex: 1;
|
2019-05-06 05:08:54 +00:00
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
.compose-autosuggest-list-item:last-child {
|
|
|
|
border-bottom: none;
|
2018-03-25 01:04:54 +00:00
|
|
|
}
|
2018-03-25 19:24:38 +00:00
|
|
|
.compose-autosuggest-list-grid {
|
2018-03-25 01:04:54 +00:00
|
|
|
display: grid;
|
|
|
|
width: 100%;
|
2018-03-25 19:24:38 +00:00
|
|
|
grid-template-areas: "icon display-name"
|
|
|
|
"icon username";
|
2018-03-25 01:04:54 +00:00
|
|
|
grid-template-columns: min-content 1fr;
|
|
|
|
grid-column-gap: 10px;
|
|
|
|
grid-row-gap: 5px;
|
|
|
|
}
|
2018-03-25 19:24:38 +00:00
|
|
|
:global(.compose-autosuggest-list-item-avatar) {
|
|
|
|
grid-area: icon;
|
2018-03-25 01:04:54 +00:00
|
|
|
}
|
2018-03-25 19:24:38 +00:00
|
|
|
.compose-autosuggest-list-item-icon {
|
|
|
|
grid-area: icon;
|
|
|
|
width: 48px;
|
|
|
|
height: 48px;
|
2018-04-28 01:19:37 +00:00
|
|
|
object-fit: contain;
|
2018-03-25 19:24:38 +00:00
|
|
|
}
|
|
|
|
.compose-autosuggest-list-display-name {
|
2018-03-25 01:04:54 +00:00
|
|
|
grid-area: display-name;
|
|
|
|
font-size: 1.1em;
|
|
|
|
white-space: nowrap;
|
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
min-width: 0;
|
|
|
|
text-align: left;
|
|
|
|
}
|
2018-03-25 19:24:38 +00:00
|
|
|
.compose-autosuggest-list-username {
|
2018-03-25 01:04:54 +00:00
|
|
|
grid-area: username;
|
|
|
|
font-size: 1em;
|
|
|
|
color: var(--deemphasized-text-color);
|
|
|
|
white-space: nowrap;
|
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
text-align: left;
|
|
|
|
}
|
2019-05-06 05:08:54 +00:00
|
|
|
.compose-autosuggest-list-item:hover, .compose-autosuggest-list-item.selected {
|
2018-03-25 01:04:54 +00:00
|
|
|
background: var(--compose-autosuggest-item-hover);
|
|
|
|
}
|
2019-05-06 05:08:54 +00:00
|
|
|
.compose-autosuggest-list-item:active {
|
2018-03-25 01:04:54 +00:00
|
|
|
background: var(--compose-autosuggest-item-active);
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
<script>
|
|
|
|
import Avatar from '../Avatar.html'
|
2018-03-25 19:24:38 +00:00
|
|
|
import { store } from '../../_store/store'
|
2018-08-19 22:23:40 +00:00
|
|
|
import AccountDisplayName from '../profile/AccountDisplayName.html'
|
2019-05-06 05:08:54 +00:00
|
|
|
import { createAutosuggestAccessibleLabel } from '../../_utils/createAutosuggestAccessibleLabel'
|
2018-03-25 19:24:38 +00:00
|
|
|
|
2018-03-25 01:04:54 +00:00
|
|
|
export default {
|
2018-03-25 19:24:38 +00:00
|
|
|
store: () => store,
|
2019-05-06 05:08:54 +00:00
|
|
|
computed: {
|
|
|
|
ariaLabels: ({ items, type, $omitEmojiInDisplayNames }) => {
|
|
|
|
return items.map((item, i) => {
|
|
|
|
return createAutosuggestAccessibleLabel(type, $omitEmojiInDisplayNames, i, items)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
2018-05-06 23:25:17 +00:00
|
|
|
methods: {
|
|
|
|
onClick (event, item) {
|
|
|
|
event.preventDefault()
|
|
|
|
event.stopPropagation()
|
|
|
|
this.fire('click', item)
|
|
|
|
}
|
|
|
|
},
|
2018-03-25 01:04:54 +00:00
|
|
|
components: {
|
2018-08-19 22:23:40 +00:00
|
|
|
Avatar,
|
|
|
|
AccountDisplayName
|
2018-03-25 01:04:54 +00:00
|
|
|
}
|
|
|
|
}
|
2018-04-28 01:19:37 +00:00
|
|
|
</script>
|