Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 

106 linhas
2.4 KiB

  1. <template>
  2. <section class="flex flex-col items-center min-h-screen">
  3. <div class="container w-full p-6 max-w-6xl grow flex flex-col items-center">
  4. <nav
  5. class="w-full flex bg-slate-800 font-semibold rounded-full backdrop-blur sticky top-0 justify-center items-center hover:ring">
  6. <input ref="searchInput" v-model="terms" autofocus placeholder="search" type="search"
  7. class="rounded-full text-xl w-full text-center text-white p-4 bg-transparent focus-visible:border-none"
  8. @keypress.enter="search()">
  9. <b v-if="films.length" class="px-4 py-2 absolute right-2 block bg-green-400 text-slate-800 rounded-full">
  10. {{ films.length }}
  11. </b>
  12. </nav>
  13. <NuxtLink v-for="(film, index) in films" :key="index" :href="film.title" :to="'/details/' + film.id"
  14. class="hover:bg-slate-200 w-full p-4 flex-col border-b-2 border-GREY-100">
  15. <img :src="config.public.IMG_BASE_URL + film.poster_path" :alt="film.title">
  16. <span class="flex flex-row">
  17. {{ film.title }}
  18. {{ film.original_title }}
  19. {{ film.vote_count }}
  20. {{ film.release_date }}
  21. {{ film.id }}
  22. </span>
  23. </NuxtLink>
  24. </div>
  25. </section>
  26. </template>
  27. <script setup lang="ts">
  28. const config = useRuntimeConfig()
  29. const terms = ref('')
  30. const films = ref([])
  31. const search = async () => {
  32. if (terms.value !== '') {
  33. films.value = []
  34. const { data } = await useFetch(`/api/search/${terms.value}`)
  35. films.value = data.value
  36. } else {
  37. initList()
  38. }
  39. }
  40. const initList = async () => {
  41. const { data } = await useFetch(`/api/list`)
  42. films.value = data.value
  43. }
  44. onMounted(() => {
  45. nextTick(() => {
  46. initList()
  47. })
  48. })
  49. </script>
  50. <style>
  51. .title b {
  52. @apply text-green-400 capitalize;
  53. }
  54. .icon {
  55. @apply w-4 h-4 mx-2;
  56. }
  57. .icon-container {
  58. color: #8094ae;
  59. @apply flex items-center
  60. }
  61. .icon-container .icon {
  62. color: rgb(109, 109, 109);
  63. }
  64. .icon-size p {
  65. color: rgb(54, 150, 75);
  66. }
  67. .icon-seed p {
  68. color: rgb(12, 108, 233);
  69. }
  70. .loader>div {
  71. animation: loader 2.4s cubic-bezier(0, 0.2, 0.8, 1) infinite;
  72. }
  73. @keyframes loader {
  74. 0%,
  75. 100% {
  76. animation-timing-function: cubic-bezier(0.5, 0, 1, 0.5);
  77. }
  78. 0% {
  79. transform: rotateY(0deg);
  80. }
  81. 50% {
  82. transform: rotateY(1800deg);
  83. animation-timing-function: cubic-bezier(0, 0.5, 0.5, 1);
  84. }
  85. 100% {
  86. transform: rotateY(3600deg);
  87. }
  88. }
  89. </style>