GoogleSearch.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. <template>
  2. <div class="search-options"
  3. dir="ltr">
  4. <q-checkbox v-model="showRichSnippet"
  5. label="Rich Snippet" />
  6. <q-checkbox v-model="showDate"
  7. label="Date" />
  8. <q-checkbox v-if="viewMode === 'desktop'"
  9. v-model="showCached"
  10. label="Cached" />
  11. </div>
  12. <div class="options-rules"
  13. dir="ltr">
  14. <div class="title q-mr-xs">
  15. Title(<span v-if="viewMode === 'desktop'">{{ this.titleWidth }}</span><span v-else>{{ this.titleWidthMobile }}</span>px / 573px)
  16. </div>
  17. <div class="url q-mr-xs">
  18. URL(<span v-if="viewMode === 'desktop'">{{ this.urlWidth }}</span><span v-else>{{ this.urlWidthMobile }}</span> / 536px)
  19. </div>
  20. <div class="meta q-mr-xs">
  21. META(<span v-if="viewMode === 'desktop'">{{ this.metaWidth }}</span><span v-else>{{ this.metaWidthMobile }}</span> / 930px)
  22. </div>
  23. </div>
  24. <div class="row"
  25. dir="ltr">
  26. <div class="col-2" />
  27. <div class="col-8 container">
  28. <div class="search-area row">
  29. <div class="col-2 google-logo">
  30. <q-img src="/img/google-logo.png"
  31. width="92px"
  32. height="30px" />
  33. </div>
  34. <div class="col-10">
  35. <q-input v-model="text"
  36. class="search-box"
  37. dense
  38. rounded
  39. outlined>
  40. <template v-slot:append>
  41. <q-icon v-if="text === ''"
  42. name="search" />
  43. <q-icon v-else
  44. name="clear"
  45. class="cursor-pointer"
  46. @click="text = ''" />
  47. </template>
  48. </q-input>
  49. </div>
  50. </div>
  51. <div class="search-categories row">
  52. <div class="col-2" />
  53. <div class="col-10 d-flex"
  54. style="justify-content: space-between">
  55. <div class="categories">
  56. <div v-for="item in categories"
  57. :key="item"
  58. class="categories-btn"
  59. :class="item.class">
  60. <q-icon :name="item.icon"
  61. style="margin: 0 2px 6px"
  62. size="14px" />
  63. {{ item.title }}
  64. <div v-if="item.active === true"
  65. style="border-bottom: 3px solid #1A73E8; position: relative; bottom: -4px;" />
  66. </div>
  67. </div>
  68. <div class="d-flex">
  69. <q-btn-toggle v-model="viewMode"
  70. spread
  71. flat
  72. no-caps
  73. toggle-color="primary"
  74. color="white"
  75. text-color="black"
  76. :options="[
  77. {value: 'desktop', slot: 'one'},
  78. {value: 'mobile', slot: 'two'}]">
  79. <template v-slot:one>
  80. <div class="d-flex">
  81. <q-icon name="mdi-desktop-mac"
  82. style="margin-right: 4px;" />
  83. Desktop
  84. </div>
  85. </template>
  86. <template v-slot:two>
  87. <div class="d-flex">
  88. <q-icon name="mdi-cellphone"
  89. style="margin-right: 4px" />
  90. Mobile
  91. </div>
  92. </template>
  93. </q-btn-toggle>
  94. </div>
  95. </div>
  96. </div>
  97. <q-separator style="width: 100%" />
  98. <div v-if="viewMode === 'desktop'"
  99. class="desktop-content">
  100. <div class="search-title">
  101. <span ref="desktopTitle"
  102. class="title d-inline-flex">
  103. {{ this.title }}
  104. </span>
  105. </div>
  106. <div class="search-url">
  107. <span ref="desktopUrl"
  108. class="d-inline-flex">
  109. {{ this.url }}
  110. <q-icon v-if="showCached"
  111. name="mdi-menu-down"
  112. style="cursor: pointer" />
  113. </span>
  114. </div>
  115. <div v-if="showRichSnippet"
  116. class="rating d-flex">
  117. <q-rating v-model="rate"
  118. color="orange"
  119. icon-half="star_half"
  120. readonly
  121. style="margin-right: 5px" />
  122. Rating: {{ this.rate }} - 798 votes
  123. </div>
  124. <div class="d-flex date-and-description">
  125. <span ref="desktopMeta">
  126. <span v-if="showDate"
  127. class="date">
  128. 24 Dec, 2019 -
  129. </span>
  130. <span class="description">
  131. {{ this.description }}
  132. </span>
  133. </span>
  134. </div>
  135. </div>
  136. <div v-if="viewMode === 'mobile'"
  137. class="mobile-content">
  138. <q-card class="mobile-card">
  139. <q-card-section>
  140. <div class="search-url">
  141. <q-img src="https://nodes.alaatv.com/upload/landing/chatr/alaa%20logo.png"
  142. width="16px"
  143. height="16px"
  144. style="margin-right: 12px" />
  145. <span ref="mobileUrl"
  146. class="d-inline-flex">
  147. {{ this.url }}
  148. </span>
  149. </div>
  150. <div class="search-title">
  151. <span ref="mobileTitle"
  152. class="title d-inline-flex">
  153. {{ this.title }}
  154. </span>
  155. </div>
  156. <div class="description d-flex">
  157. <span class="d-inline-flex">
  158. <template v-if="showDate">
  159. 24 Dec, 2019 -
  160. </template>
  161. {{ this.description }}
  162. </span>
  163. </div>
  164. <!-- -------------------hidden the text for getting the width of the content---------------------- -->
  165. <span ref="mobileMeta"
  166. class="hidden-text d-inline-flex">
  167. <template v-if="showDate">
  168. 24 Dec, 2019 -
  169. </template>
  170. {{ this.description }}
  171. </span>
  172. <!-- ------------------------------------- END ---------------------------------------------------- -->
  173. <p v-if="showRichSnippet"
  174. style="margin-bottom: 1px; margin-top: 3px; margin-left: 2px">Rating</p>
  175. <div v-if="showRichSnippet"
  176. class="rating d-flex">
  177. {{ this.rate }}/5.0
  178. <q-rating v-model="rate"
  179. color="orange"
  180. icon-half="star_half"
  181. readonly
  182. style="margin-right: 5px" />
  183. (798)
  184. </div>
  185. </q-card-section>
  186. </q-card>
  187. </div>
  188. </div>
  189. <div class="col-2" />
  190. </div>
  191. </template>
  192. <script>
  193. export default {
  194. name: 'GoogleSearch',
  195. props: {
  196. title: {
  197. type: String,
  198. default: 'جلسه معرفی'
  199. },
  200. url: {
  201. type: String,
  202. default: 'https://office.alaatv.com:700 › c/29524'
  203. },
  204. description: {
  205. type: String,
  206. default: 'توضیحات کلی راجع به مصاحبه با ستارگان عدالت اموزشی'
  207. }
  208. },
  209. data () {
  210. return {
  211. text: '',
  212. titleWidth: 0,
  213. urlWidth: 0,
  214. metaWidth: 0,
  215. titleWidthMobile: 0,
  216. urlWidthMobile: 0,
  217. metaWidthMobile: 0,
  218. showRichSnippet: true,
  219. showDate: true,
  220. showCached: true,
  221. viewMode: 'desktop',
  222. rate: 4.5,
  223. categories: [
  224. {
  225. icon: 'search',
  226. title: 'All',
  227. class: 'active',
  228. active: true
  229. },
  230. {
  231. icon: 'image',
  232. title: 'Images'
  233. },
  234. {
  235. icon: 'isax:video-square',
  236. title: 'Videos'
  237. },
  238. {
  239. icon: 'mdi-newspaper',
  240. title: 'News'
  241. },
  242. {
  243. icon: 'mdi-dots-vertical',
  244. title: 'More'
  245. }
  246. ]
  247. }
  248. },
  249. watch: {
  250. showCached (newVal) {
  251. setTimeout(() => {
  252. this.widthOfRef('urlWidth', 'desktopUrl')
  253. }, 10)
  254. },
  255. showDate (newVal) {
  256. setTimeout(() => {
  257. if (this.viewMode === 'desktop') {
  258. this.widthOfRef('metaWidth', 'desktopMeta')
  259. } else {
  260. this.widthOfRef('metaWidthMobile', 'mobileMeta')
  261. }
  262. }, 10)
  263. },
  264. viewMode (newVal) {
  265. setTimeout(() => {
  266. if (this.viewMode === 'desktop') {
  267. this.widthOfRef('titleWidth', 'desktopTitle')
  268. this.widthOfRef('urlWidth', 'desktopUrl')
  269. this.widthOfRef('metaWidth', 'desktopMeta')
  270. } else {
  271. this.widthOfRef('titleWidthMobile', 'mobileTitle')
  272. this.widthOfRef('urlWidthMobile', 'mobileUrl')
  273. this.widthOfRef('metaWidthMobile', 'mobileMeta')
  274. }
  275. }, 10)
  276. }
  277. },
  278. mounted () {
  279. this.widthOfRef('titleWidth', 'desktopTitle')
  280. this.widthOfRef('urlWidth', 'desktopUrl')
  281. this.widthOfRef('metaWidth', 'desktopMeta')
  282. },
  283. methods: {
  284. widthOfRef (key, refName) {
  285. this[key] = this.$refs[refName].clientWidth
  286. }
  287. }
  288. }
  289. </script>
  290. <style scoped>
  291. .d-flex {
  292. display: flex;
  293. }
  294. .d-inline-flex {
  295. display: inline-flex;
  296. }
  297. .search-title {
  298. margin-bottom: 5px;
  299. }
  300. .hidden-text {
  301. visibility: hidden;
  302. white-space: nowrap;
  303. position: absolute;
  304. line-height: 0;
  305. }
  306. .search-title .title{
  307. cursor: pointer;
  308. color: #1a0dab;
  309. font-size: 20px;
  310. font-family: arial, sans-serif !important;
  311. font-weight: 400;
  312. text-decoration: none;
  313. }
  314. .search-url {
  315. display: flex;
  316. margin-bottom: 5px;
  317. line-height: 16px;
  318. color: #006621;
  319. font-size: 16px;
  320. font-family: 'Roboto', 'Helvetica', 'Arial', sans-serif !important;
  321. font-weight: 400;
  322. }
  323. </style>
  324. <style lang="scss" scoped>
  325. .search-options {
  326. display: flex;
  327. justify-content: center;
  328. }
  329. .options-rules {
  330. display: flex;
  331. justify-content: center;
  332. }
  333. .container {
  334. background: #FFFFFF;
  335. margin-top: 10px;
  336. padding: 24px 16px;
  337. border: 1px solid transparent;
  338. box-shadow: 0 2px 5px 1px rgb(64 60 67 / 16%);
  339. .search-area {
  340. .google-logo {
  341. display: grid;
  342. justify-items: center;
  343. align-items: center;
  344. }
  345. .search-box {
  346. &:deep(.q-field__control::before) {
  347. border: 1px solid transparent;
  348. box-shadow: 0 2px 5px 1px rgb(64 60 67 / 16%);
  349. }
  350. }
  351. }
  352. .search-categories {
  353. margin-top: 16px;
  354. .categories {
  355. display: flex;
  356. justify-content: center;
  357. align-items: center;
  358. .active {
  359. color: #1A73E8 !important;
  360. padding-top: 7px;
  361. }
  362. .categories-btn {
  363. color: #5f6368;
  364. margin: 0 8px;
  365. &:deep(.q-btn__content) {
  366. font-size: 14px;
  367. font-family: Google Sans, arial, sans-serif;
  368. }
  369. }
  370. }
  371. }
  372. .desktop-content {
  373. margin-top: 30px;
  374. padding-left: 0;
  375. padding-right: 17.5%;
  376. .rating {
  377. font-family: 'Roboto', 'Helvetica', 'Arial', sans-serif !important;
  378. font-size: 14px;
  379. font-weight: 400;
  380. line-height: 20px;
  381. color: grey;
  382. &:deep(.q-rating__icon-container) {
  383. margin: 0;
  384. }
  385. }
  386. .date-and-description {
  387. color: #545454;
  388. font-family: 'Roboto', 'Helvetica', 'Arial', sans-serif !important;
  389. font-size: 14px;
  390. font-weight: 400;
  391. line-height: 20px;
  392. }
  393. }
  394. .mobile-content {
  395. display: flex;
  396. justify-content: center;
  397. margin-top: 24px;
  398. .mobile-card {
  399. width: 100%;
  400. max-width: 360px;
  401. color: #3C4043;
  402. .search-title {
  403. .title {
  404. color: #1967D2;
  405. font-size: 16px;
  406. }
  407. margin-top: 10px;
  408. margin-bottom: 12px;
  409. }
  410. .search-url {
  411. color: #3C4043;
  412. font-size: 12px;
  413. }
  414. .rating {
  415. font-family: 'Roboto', 'Helvetica', 'Arial', sans-serif !important;
  416. font-size: 14px;
  417. font-weight: 400;
  418. line-height: 20px;
  419. color: grey;
  420. &:deep(.q-rating__icon-container) {
  421. margin: 0;
  422. }
  423. }
  424. }
  425. }
  426. }
  427. </style>