1
1
<script setup>
2
- import { ref } from ' vue' ;
2
+ import { ref , watchEffect } from ' vue' ;
3
3
import { find , get , createSupercut } from ' ../api'
4
+ import LoadingDots from ' ./LoadingDots.vue'
4
5
5
6
const emit = defineEmits ([' send-supercut' , ' send-videos' , ' send-transcripts' ])
6
7
8
+ const searchForm = ref (null )
7
9
const query = ref (' ' )
8
10
const range = ref (2 )
9
11
const cutLength = ref (10 )
12
+ const error = ref (false )
13
+
14
+ const onClick = async (e ) => {
15
+ e .preventDefault ()
16
+ // searchForm.value.reset()
17
+ error .value = false
18
+ emit (' send-videos' , [])
19
+ emit (' send-transcripts' , [])
20
+ emit (' send-supercut' , null )
21
+
22
+ if (query .value .trim ().length == 1 ) return
10
23
11
- const onClick = async () => {
12
24
console .log (" search form: on click method called" )
13
25
console .log (query .value , range .value , cutLength .value )
14
26
@@ -19,6 +31,7 @@ const onClick = async () => {
19
31
clips = clips .flat (1 )
20
32
console .log (clips)
21
33
34
+ if (clips .length == 0 ) error .value = true
22
35
emit (' send-videos' , clips)
23
36
24
37
let transcripts = clips .map (c => c .transcript )
@@ -31,6 +44,11 @@ const onClick = async () => {
31
44
32
45
emit (' send-supercut' , supercut)
33
46
47
+ // reset form params
48
+ // query.value = ''
49
+ // range.value = 2
50
+ // cutLength.value = 10
51
+
34
52
// const videoListData = await getVideoList(query, range, cutLength)
35
53
// const videoItems = videoListData.map(async (item) => {
36
54
// const videoSrc = await getVideo(item.id, query, cutLength)
@@ -46,42 +64,57 @@ const onClick = async () => {
46
64
47
65
}
48
66
67
+ watchEffect (() => {
68
+ error .value = false
69
+ })
70
+
49
71
</script >
50
72
51
73
<template >
52
- <div class =" w-full flex md:flex-row flex-col gap-2" >
74
+ <form @submit = " onClick " ref = " searchForm " class =" w-full flex md:flex-row flex-col gap-2 header-text dark:inputDarkModeOverride " >
53
75
<div class =" flex md:block justify-between gap-2" >
54
76
<input type =" text" name =" query" id =" input-query" v-model =" query" placeholder =" What are you thinking about"
55
- class =" rounded-full px-2 py-1 flex-1 lg:min-w-96" >
77
+ class =" dark:text-slate-400 dark:inputDarkModeOverride rounded-full px-2 py-1 flex-1 lg:min-w-96" >
56
78
57
79
<!-- <button class="md:hidden">></button> -->
58
80
59
81
<div class =" md:hidden" >
60
- <button class =" rounded-full px-2 py-0.5 text-sm border border-1 border-green-300 bg-white text-green-300 "
82
+ <button class =" header-button "
61
83
@click =" onClick" >search</button >
62
84
</div >
63
85
</div >
64
86
65
- <div class =" flex flex-row gap-2 text-sm text-gray-500 px-1" >
87
+ <div class =" flex flex-row gap-2 px-1" >
66
88
<div >
67
89
<label class =" pe-2" for =" range" >Number of videos</label >
68
90
<input type =" number" name =" range" id =" input-range" v-model =" range" aria-placeholder =" Number of videos"
69
- class =" rounded-full px-2 py-1 max-w-16" >
91
+ class =" dark:text-slate-400 rounded-full px-2 py-1 max-w-16" >
70
92
</div >
71
93
72
94
73
95
<div >
74
96
<label class =" pe-2" for =" cut-length" >Duration of cut</label >
75
97
<input type =" number" name =" cut-length" id =" input-cut-length" v-model =" cutLength" aria-placeholder =" Duration of videos"
76
- class =" rounded-full px-2 py-1 max-w-16" >
98
+ class =" dark:text-slate-400 rounded-full px-2 py-1 max-w-16" >
77
99
</div >
78
100
</div >
79
101
80
102
<div class =" hidden md:block" >
81
- <button class =" rounded-full px-2 py-0.5 text-sm border border-1 border-green-300 bg-white text-green-300 "
103
+ <button class =" header-button "
82
104
@click =" onClick" >search</button >
83
105
</div >
84
106
107
+ </form >
108
+
109
+ <div v-if =" query" class =" header-text" >
110
+ <p >You are looking for videos containing some
111
+ <span class =" green-underline" >{{ query }}</span >, that are not more than
112
+ <span class =" green-underline" >{{ cutLength }}</span > seconds long, and not more than
113
+ <span class =" green-underline" >{{ range }}</span > when put together.<LoadingDots />
114
+ </p >
115
+ </div >
85
116
117
+ <div v-if =" query && error" class =" py-2 header-text" >
118
+ <p >We came up empty. Please try again.</p >
86
119
</div >
87
120
</template >
0 commit comments