aboutsummaryrefslogtreecommitdiff
path: root/src/components/search/search.vue
diff options
context:
space:
mode:
authorHenry Jameson <me@hjkos.com>2019-07-28 13:30:29 +0300
committerHenry Jameson <me@hjkos.com>2019-07-28 13:30:29 +0300
commitb3aff9bbae77b2fd34b2267ce9196c0ebd3e4691 (patch)
tree1219e00b6bfe6784add1578a3bc986c1dbb5f34d /src/components/search/search.vue
parent7f6f025792dcb3a10c94c8952d0312abd0b46989 (diff)
parent4827e4d972f8ee11e606693e24ae4ca21711c6b1 (diff)
Merge remote-tracking branch 'upstream/develop' into emoji-selector-update
* upstream/develop: (469 commits) Feature/add sticker picker guard more secure routes guard secure routes by redirecting to root closest can returns itself as well find inside status-content div only try to use the closest a tag as target Update es.json Also apply keyword filter to subjects Remove files I accidentally pushed in fix issues caused by merges in usersearch on @ Add user search at fix eslint warnings remove vue-popperjs fix moderation menu partially hidden by usercard boundary migrate popper css rewrite ModerationTools using v-tooltip make popover position for status action dropdow relative to parent node rewrite ExtraButtons using v-tooltip install v-tooltip i18n/Update pedantic Japanese translation ...
Diffstat (limited to 'src/components/search/search.vue')
-rw-r--r--src/components/search/search.vue211
1 files changed, 211 insertions, 0 deletions
diff --git a/src/components/search/search.vue b/src/components/search/search.vue
new file mode 100644
index 00000000..4350e672
--- /dev/null
+++ b/src/components/search/search.vue
@@ -0,0 +1,211 @@
+<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"
+ class="search-input"
+ :placeholder="$t('nav.search')"
+ @keyup.enter="newQuery(searchTerm)"
+ >
+ <button
+ class="btn search-button"
+ @click="newQuery(searchTerm)"
+ >
+ <i class="icon-search" />
+ </button>
+ </div>
+ <div
+ v-if="loading"
+ class="text-center loading-icon"
+ >
+ <i class="icon-spin3 animate-spin" />
+ </div>
+ <div v-else-if="loaded">
+ <div class="search-nav-heading">
+ <tab-switcher
+ ref="tabSwitcher"
+ :on-switch="onResultTabSwitch"
+ :custom-active="currenResultTab"
+ >
+ <span
+ data-tab-dummy
+ data-filter="statuses"
+ :label="$t('user_card.statuses') + resultCount('visibleStatuses')"
+ />
+ <span
+ data-tab-dummy
+ data-filter="people"
+ :label="$t('search.people') + resultCount('users')"
+ />
+ <span
+ data-tab-dummy
+ data-filter="hashtags"
+ :label="$t('search.hashtags') + resultCount('hashtags')"
+ />
+ </tab-switcher>
+ </div>
+ </div>
+ <div class="panel-body">
+ <div v-if="currenResultTab === 'statuses'">
+ <div
+ v-if="visibleStatuses.length === 0 && !loading && loaded"
+ class="search-result-heading"
+ >
+ <h4>{{ $t('search.no_results') }}</h4>
+ </div>
+ <Status
+ v-for="status in visibleStatuses"
+ :key="status.id"
+ :collapsable="false"
+ :expandable="false"
+ :compact="false"
+ class="search-result"
+ :statusoid="status"
+ :no-heading="false"
+ />
+ </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">
+@import '../../_variables.scss';
+
+.search-result-heading {
+ color: $fallback--faint;
+ color: var(--faint, $fallback--faint);
+ 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;
+ border-color: $fallback--border;
+ border-color: var(--border, $fallback--border);
+}
+
+.search-result-footer {
+ border-width: 1px 0 0 0;
+ border-style: solid;
+ border-color: var(--border, $fallback--border);
+ padding: 10px;
+ background-color: $fallback--fg;
+ background-color: var(--panel, $fallback--fg);
+}
+
+.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;
+ color: $fallback--text;
+ color: var(--text, $fallback--text);
+ 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;
+ color: $fallback--text;
+ color: var(--text, $fallback--text);
+ }
+}
+
+</style>