2019-07-15 16:42:27 +00:00
|
|
|
<template>
|
|
|
|
<div class="panel panel-default">
|
|
|
|
<div class="panel-heading">
|
|
|
|
<div class="title">
|
|
|
|
{{ $t('nav.search') }}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="search-input-container">
|
|
|
|
<input
|
|
|
|
ref="searchInput"
|
|
|
|
v-model="searchTerm"
|
2024-02-07 15:53:49 +02:00
|
|
|
class="input search-input"
|
2019-07-15 16:42:27 +00:00
|
|
|
:placeholder="$t('nav.search')"
|
|
|
|
@keyup.enter="newQuery(searchTerm)"
|
|
|
|
>
|
|
|
|
<button
|
2020-11-25 10:36:14 +02:00
|
|
|
class="btn button-default search-button"
|
2021-02-01 21:07:09 +02:00
|
|
|
type="submit"
|
2021-02-25 14:32:21 +02:00
|
|
|
@click="newQuery(searchTerm)"
|
2019-07-15 16:42:27 +00:00
|
|
|
>
|
2020-10-20 22:13:19 +03:00
|
|
|
<FAIcon icon="search" />
|
2019-07-15 16:42:27 +00:00
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
<div
|
2021-08-22 16:12:36 +03:00
|
|
|
v-if="loading && statusesOffset == 0"
|
2019-07-15 16:42:27 +00:00
|
|
|
class="text-center loading-icon"
|
|
|
|
>
|
2020-10-21 00:31:16 +03:00
|
|
|
<FAIcon
|
|
|
|
icon="circle-notch"
|
|
|
|
spin
|
|
|
|
size="lg"
|
|
|
|
/>
|
2019-07-15 16:42:27 +00:00
|
|
|
</div>
|
|
|
|
<div v-else-if="loaded">
|
|
|
|
<div class="search-nav-heading">
|
|
|
|
<tab-switcher
|
|
|
|
ref="tabSwitcher"
|
|
|
|
:on-switch="onResultTabSwitch"
|
2019-08-10 00:26:29 -04:00
|
|
|
:active-tab="currenResultTab"
|
2019-07-15 16:42:27 +00:00
|
|
|
>
|
|
|
|
<span
|
2019-08-09 23:48:08 -04:00
|
|
|
key="statuses"
|
2019-07-15 16:42:27 +00:00
|
|
|
:label="$t('user_card.statuses') + resultCount('visibleStatuses')"
|
|
|
|
/>
|
|
|
|
<span
|
2019-08-09 23:48:08 -04:00
|
|
|
key="people"
|
2019-07-15 16:42:27 +00:00
|
|
|
:label="$t('search.people') + resultCount('users')"
|
|
|
|
/>
|
|
|
|
<span
|
2019-08-09 23:48:08 -04:00
|
|
|
key="hashtags"
|
2019-07-15 16:42:27 +00:00
|
|
|
:label="$t('search.hashtags') + resultCount('hashtags')"
|
|
|
|
/>
|
|
|
|
</tab-switcher>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="panel-body">
|
|
|
|
<div v-if="currenResultTab === 'statuses'">
|
|
|
|
<Status
|
|
|
|
v-for="status in visibleStatuses"
|
|
|
|
:key="status.id"
|
|
|
|
:collapsable="false"
|
|
|
|
:expandable="false"
|
|
|
|
:compact="false"
|
|
|
|
class="search-result"
|
|
|
|
:statusoid="status"
|
|
|
|
:no-heading="false"
|
|
|
|
/>
|
2021-08-16 21:30:07 +03:00
|
|
|
<button
|
|
|
|
v-if="!loading && loaded && lastStatusFetchCount > 0"
|
2024-02-29 18:07:15 +02:00
|
|
|
class="more-statuses-button button-unstyled -link"
|
2021-08-22 15:36:03 +03:00
|
|
|
@click.prevent="search(searchTerm, 'statuses')"
|
2021-08-16 21:30:07 +03:00
|
|
|
>
|
|
|
|
<div class="new-status-notification text-center">
|
|
|
|
{{ $t('search.load_more') }}
|
|
|
|
</div>
|
|
|
|
</button>
|
|
|
|
<div
|
|
|
|
v-else-if="loading && statusesOffset > 0"
|
|
|
|
class="text-center loading-icon"
|
|
|
|
>
|
|
|
|
<FAIcon
|
|
|
|
icon="circle-notch"
|
|
|
|
spin
|
|
|
|
size="lg"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div
|
|
|
|
v-if="(visibleStatuses.length === 0 || lastStatusFetchCount === 0) && !loading && loaded"
|
|
|
|
class="search-result-heading"
|
|
|
|
>
|
|
|
|
<h4>
|
2022-07-15 20:26:05 -04:00
|
|
|
{{ visibleStatuses.length === 0 ? $t('search.no_results') : $t('search.no_more_results') }}
|
2021-08-16 21:30:07 +03:00
|
|
|
</h4>
|
|
|
|
</div>
|
2019-07-15 16:42:27 +00:00
|
|
|
</div>
|
|
|
|
<div v-else-if="currenResultTab === 'people'">
|
|
|
|
<div
|
|
|
|
v-if="users.length === 0 && !loading && loaded"
|
|
|
|
class="search-result-heading"
|
|
|
|
>
|
|
|
|
<h4>{{ $t('search.no_results') }}</h4>
|
|
|
|
</div>
|
|
|
|
<FollowCard
|
|
|
|
v-for="user in users"
|
|
|
|
:key="user.id"
|
|
|
|
:user="user"
|
|
|
|
class="list-item search-result"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div v-else-if="currenResultTab === 'hashtags'">
|
|
|
|
<div
|
|
|
|
v-if="hashtags.length === 0 && !loading && loaded"
|
|
|
|
class="search-result-heading"
|
|
|
|
>
|
|
|
|
<h4>{{ $t('search.no_results') }}</h4>
|
|
|
|
</div>
|
|
|
|
<div
|
|
|
|
v-for="hashtag in hashtags"
|
|
|
|
:key="hashtag.url"
|
|
|
|
class="status trend search-result"
|
|
|
|
>
|
|
|
|
<div class="hashtag">
|
|
|
|
<router-link :to="{ name: 'tag-timeline', params: { tag: hashtag.name } }">
|
|
|
|
#{{ hashtag.name }}
|
|
|
|
</router-link>
|
|
|
|
<div v-if="lastHistoryRecord(hashtag)">
|
|
|
|
<span v-if="lastHistoryRecord(hashtag).accounts == 1">
|
|
|
|
{{ $t('search.person_talking', { count: lastHistoryRecord(hashtag).accounts }) }}
|
|
|
|
</span>
|
|
|
|
<span v-else>
|
|
|
|
{{ $t('search.people_talking', { count: lastHistoryRecord(hashtag).accounts }) }}
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div
|
|
|
|
v-if="lastHistoryRecord(hashtag)"
|
|
|
|
class="count"
|
|
|
|
>
|
|
|
|
{{ lastHistoryRecord(hashtag).uses }}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="search-result-footer text-center panel-footer faint" />
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script src="./search.js"></script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
.search-result-heading {
|
2024-02-29 18:07:15 +02:00
|
|
|
color: var(--faint);
|
2019-07-15 16:42:27 +00:00
|
|
|
padding: 0.75rem;
|
|
|
|
text-align: center;
|
|
|
|
}
|
|
|
|
|
|
|
|
@media all and (max-width: 800px) {
|
|
|
|
.search-nav-heading {
|
|
|
|
.tab-switcher .tabs .tab-wrapper {
|
|
|
|
display: block;
|
|
|
|
justify-content: center;
|
|
|
|
flex: 1 1 auto;
|
|
|
|
text-align: center;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.search-result {
|
|
|
|
box-sizing: border-box;
|
|
|
|
border-bottom: 1px solid;
|
2024-02-29 18:07:15 +02:00
|
|
|
border-color: var(--border);
|
2019-07-15 16:42:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.search-input-container {
|
|
|
|
padding: 0.8rem;
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
|
|
|
|
.search-input {
|
|
|
|
width: 100%;
|
|
|
|
line-height: 1.125rem;
|
|
|
|
font-size: 1rem;
|
|
|
|
padding: 0.5rem;
|
|
|
|
box-sizing: border-box;
|
|
|
|
}
|
|
|
|
|
|
|
|
.search-button {
|
|
|
|
margin-left: 0.5em;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.loading-icon {
|
|
|
|
padding: 1em;
|
|
|
|
}
|
|
|
|
|
|
|
|
.trend {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
.hashtag {
|
|
|
|
flex: 1 1 auto;
|
2024-02-29 18:07:15 +02:00
|
|
|
color: var(--text);
|
2019-07-15 16:42:27 +00:00
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
white-space: nowrap;
|
|
|
|
}
|
|
|
|
|
|
|
|
.count {
|
|
|
|
flex: 0 0 auto;
|
|
|
|
width: 2rem;
|
|
|
|
font-size: 1.5rem;
|
|
|
|
line-height: 2.25rem;
|
|
|
|
font-weight: 500;
|
|
|
|
text-align: center;
|
2024-02-29 18:07:15 +02:00
|
|
|
color: var(--text);
|
2019-07-15 16:42:27 +00:00
|
|
|
}
|
2023-01-09 13:02:16 -05:00
|
|
|
}
|
2021-08-16 21:30:07 +03:00
|
|
|
|
2023-01-09 13:02:16 -05:00
|
|
|
.more-statuses-button {
|
|
|
|
height: 3.5em;
|
|
|
|
line-height: 3.5em;
|
2024-02-29 18:07:15 +02:00
|
|
|
width: 100%;
|
2023-01-09 13:02:16 -05:00
|
|
|
}
|
2019-07-15 16:42:27 +00:00
|
|
|
|
|
|
|
</style>
|