logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://hacktivis.me/git/pleroma-fe.git

search.vue (5624B)


  1. <template>
  2. <div class="Search panel panel-default">
  3. <div class="panel-heading">
  4. <div class="title">
  5. {{ $t('nav.search') }}
  6. </div>
  7. </div>
  8. <div class="panel-body search-input-container">
  9. <input
  10. ref="searchInput"
  11. v-model="searchTerm"
  12. class="input search-input"
  13. :placeholder="$t('nav.search')"
  14. @keyup.enter="newQuery(searchTerm)"
  15. >
  16. <button
  17. class="btn button-default search-button"
  18. type="submit"
  19. @click="newQuery(searchTerm)"
  20. >
  21. <FAIcon icon="search" />
  22. </button>
  23. </div>
  24. <div
  25. v-if="loading && statusesOffset == 0"
  26. class="panel-body text-center loading-icon"
  27. >
  28. <FAIcon
  29. icon="circle-notch"
  30. spin
  31. size="lg"
  32. />
  33. </div>
  34. <div v-else-if="loaded">
  35. <div class="search-nav-heading">
  36. <tab-switcher
  37. ref="tabSwitcher"
  38. :on-switch="onResultTabSwitch"
  39. :active-tab="currenResultTab"
  40. >
  41. <span
  42. key="statuses"
  43. :label="$t('user_card.statuses') + resultCount('visibleStatuses')"
  44. />
  45. <span
  46. key="people"
  47. :label="$t('search.people') + resultCount('users')"
  48. />
  49. <span
  50. key="hashtags"
  51. :label="$t('search.hashtags') + resultCount('hashtags')"
  52. />
  53. </tab-switcher>
  54. </div>
  55. </div>
  56. <div class="panel-body">
  57. <div v-if="currenResultTab === 'statuses'">
  58. <Status
  59. v-for="status in visibleStatuses"
  60. :key="status.id"
  61. :collapsable="false"
  62. :expandable="false"
  63. :compact="false"
  64. class="search-result"
  65. :statusoid="status"
  66. :no-heading="false"
  67. />
  68. <button
  69. v-if="!loading && loaded && lastStatusFetchCount > 0"
  70. class="more-statuses-button button-unstyled -link"
  71. @click.prevent="search(searchTerm, 'statuses')"
  72. >
  73. <div class="new-status-notification text-center">
  74. {{ $t('search.load_more') }}
  75. </div>
  76. </button>
  77. <div
  78. v-else-if="loading && statusesOffset > 0"
  79. class="text-center loading-icon"
  80. >
  81. <FAIcon
  82. icon="circle-notch"
  83. spin
  84. size="lg"
  85. />
  86. </div>
  87. <div
  88. v-if="(visibleStatuses.length === 0 || lastStatusFetchCount === 0) && !loading && loaded"
  89. class="search-result-heading"
  90. >
  91. <h4>
  92. {{ visibleStatuses.length === 0 ? $t('search.no_results') : $t('search.no_more_results') }}
  93. </h4>
  94. </div>
  95. </div>
  96. <div v-else-if="currenResultTab === 'people'">
  97. <div
  98. v-if="users.length === 0 && !loading && loaded"
  99. class="search-result-heading"
  100. >
  101. <h4>{{ $t('search.no_results') }}</h4>
  102. </div>
  103. <FollowCard
  104. v-for="user in users"
  105. :key="user.id"
  106. :user="user"
  107. class="list-item search-result"
  108. />
  109. </div>
  110. <div v-else-if="currenResultTab === 'hashtags'">
  111. <div
  112. v-if="hashtags.length === 0 && !loading && loaded"
  113. class="search-result-heading"
  114. >
  115. <h4>{{ $t('search.no_results') }}</h4>
  116. </div>
  117. <div
  118. v-for="hashtag in hashtags"
  119. :key="hashtag.url"
  120. class="status trend search-result"
  121. >
  122. <div class="hashtag">
  123. <router-link :to="{ name: 'tag-timeline', params: { tag: hashtag.name } }">
  124. #{{ hashtag.name }}
  125. </router-link>
  126. <div v-if="lastHistoryRecord(hashtag)">
  127. <span v-if="lastHistoryRecord(hashtag).accounts == 1">
  128. {{ $t('search.person_talking', { count: lastHistoryRecord(hashtag).accounts }) }}
  129. </span>
  130. <span v-else>
  131. {{ $t('search.people_talking', { count: lastHistoryRecord(hashtag).accounts }) }}
  132. </span>
  133. </div>
  134. </div>
  135. <div
  136. v-if="lastHistoryRecord(hashtag)"
  137. class="count"
  138. >
  139. {{ lastHistoryRecord(hashtag).uses }}
  140. </div>
  141. </div>
  142. </div>
  143. </div>
  144. <div class="search-result-footer text-center panel-footer faint" />
  145. </div>
  146. </template>
  147. <script src="./search.js"></script>
  148. <style lang="scss">
  149. .search-result-heading {
  150. color: var(--faint);
  151. padding: 0.75rem;
  152. text-align: center;
  153. }
  154. @media all and (max-width: 800px) {
  155. .search-nav-heading {
  156. .tab-switcher .tabs .tab-wrapper {
  157. display: block;
  158. justify-content: center;
  159. flex: 1 1 auto;
  160. text-align: center;
  161. }
  162. }
  163. }
  164. .search-result {
  165. box-sizing: border-box;
  166. border-bottom: 1px solid;
  167. border-color: var(--border);
  168. }
  169. .search-input-container {
  170. padding: 0.8rem;
  171. display: flex;
  172. justify-content: center;
  173. .search-input {
  174. width: 100%;
  175. line-height: 1.125rem;
  176. font-size: 1rem;
  177. padding: 0.5rem;
  178. box-sizing: border-box;
  179. }
  180. .search-button {
  181. margin-left: 0.5em;
  182. }
  183. }
  184. .loading-icon {
  185. padding: 1em;
  186. }
  187. .trend {
  188. display: flex;
  189. align-items: center;
  190. .hashtag {
  191. flex: 1 1 auto;
  192. color: var(--text);
  193. overflow: hidden;
  194. text-overflow: ellipsis;
  195. white-space: nowrap;
  196. }
  197. .count {
  198. flex: 0 0 auto;
  199. width: 2rem;
  200. font-size: 1.5rem;
  201. line-height: 2.25rem;
  202. font-weight: 500;
  203. text-align: center;
  204. color: var(--text);
  205. }
  206. }
  207. .more-statuses-button {
  208. height: 3.5em;
  209. line-height: 3.5em;
  210. width: 100%;
  211. }
  212. </style>