pinafore/routes/_components/compose/ComposeAutosuggestionList.html

119 lines
3.2 KiB
HTML
Raw Normal View History

2018-03-25 21:24:38 +02:00
<ul class="compose-autosuggest-list">
{#each items as item, i}
2018-03-25 21:24:38 +02:00
<li class="compose-autosuggest-list-item">
<button class="compose-autosuggest-list-button {i === selected ? 'selected' : ''}"
2018-03-25 03:04:54 +02:00
tabindex="0"
on:click="onClick(event, item)">
2018-03-25 21:24:38 +02:00
<div class="compose-autosuggest-list-grid">
{#if type === 'account'}
2018-03-25 03:04:54 +02:00
<Avatar
2018-03-25 21:24:38 +02:00
className="compose-autosuggest-list-item-avatar"
2018-03-25 03:04:54 +02:00
size="small"
account={item}
2018-03-25 03:04:54 +02:00
/>
2018-03-25 21:24:38 +02:00
<span class="compose-autosuggest-list-display-name">
<AccountDisplayName account={item} />
2018-03-25 03:04:54 +02:00
</span>
2018-03-25 21:24:38 +02:00
<span class="compose-autosuggest-list-username">
{'@' + item.acct}
2018-03-25 03:04:54 +02:00
</span>
{:else}
<img src={$autoplayGifs ? item.url : item.static_url}
2018-03-25 21:24:38 +02:00
class="compose-autosuggest-list-item-icon"
alt="{':' + item.shortcode + ':'}"
2018-03-25 21:24:38 +02:00
/>
<span class="compose-autosuggest-list-display-name">
{':' + item.shortcode + ':'}
2018-03-25 21:24:38 +02:00
</span>
{/if}
2018-03-25 03:04:54 +02:00
</div>
</button>
</li>
{/each}
2018-03-25 03:04:54 +02:00
</ul>
<style>
2018-03-25 21:24:38 +02:00
.compose-autosuggest-list {
2018-03-25 03:04:54 +02:00
list-style: none;
width: 100%;
border-radius: 2px;
box-sizing: border-box;
border: 1px solid var(--compose-autosuggest-outline);
}
2018-03-25 21:24:38 +02:00
.compose-autosuggest-list-item {
2018-03-25 03:04:54 +02:00
border-bottom: 1px solid var(--compose-autosuggest-outline);
display: flex;
}
2018-03-25 21:24:38 +02:00
.compose-autosuggest-list-item:last-child {
2018-03-25 03:04:54 +02:00
border-bottom: none;
}
2018-03-25 21:24:38 +02:00
.compose-autosuggest-list-button {
2018-03-25 03:04:54 +02:00
padding: 10px;
background: var(--settings-list-item-bg);
border: none;
margin: 0;
flex: 1;
}
2018-03-25 21:24:38 +02:00
.compose-autosuggest-list-grid {
2018-03-25 03:04:54 +02:00
display: grid;
width: 100%;
2018-03-25 21:24:38 +02:00
grid-template-areas: "icon display-name"
"icon username";
2018-03-25 03:04:54 +02:00
grid-template-columns: min-content 1fr;
grid-column-gap: 10px;
grid-row-gap: 5px;
}
2018-03-25 21:24:38 +02:00
:global(.compose-autosuggest-list-item-avatar) {
grid-area: icon;
2018-03-25 03:04:54 +02:00
}
2018-03-25 21:24:38 +02:00
.compose-autosuggest-list-item-icon {
grid-area: icon;
width: 48px;
height: 48px;
object-fit: contain;
2018-03-25 21:24:38 +02:00
}
.compose-autosuggest-list-display-name {
2018-03-25 03:04:54 +02: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 21:24:38 +02:00
.compose-autosuggest-list-username {
2018-03-25 03:04:54 +02:00
grid-area: username;
font-size: 1em;
color: var(--deemphasized-text-color);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
text-align: left;
}
2018-03-25 21:24:38 +02:00
.compose-autosuggest-list-button:hover, .compose-autosuggest-list-button.selected {
2018-03-25 03:04:54 +02:00
background: var(--compose-autosuggest-item-hover);
}
2018-03-25 21:24:38 +02:00
.compose-autosuggest-list-button:active {
2018-03-25 03:04:54 +02:00
background: var(--compose-autosuggest-item-active);
}
</style>
<script>
import Avatar from '../Avatar.html'
2018-03-25 21:24:38 +02:00
import { store } from '../../_store/store'
import AccountDisplayName from '../profile/AccountDisplayName.html'
2018-03-25 21:24:38 +02:00
2018-03-25 03:04:54 +02:00
export default {
2018-03-25 21:24:38 +02:00
store: () => store,
methods: {
onClick (event, item) {
event.preventDefault()
event.stopPropagation()
this.fire('click', item)
}
},
2018-03-25 03:04:54 +02:00
components: {
Avatar,
AccountDisplayName
2018-03-25 03:04:54 +02:00
}
}
</script>