1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/** @jsxImportSource npm:hono@3/jsx */
import { useState } from "https://deno.land/x/hono@v4.3.11/middleware.ts";
import date_me_doc_locations from "https://esm.town/v/stevekrouse/date_me_doc_locations";
import Layout from "https://esm.town/v/stevekrouse/dateme_layout";
export default function Home(c) {
const AutocompleteInput = () => {
const [inputValue, setInputValue] = useState('');
const [filteredLocations, setFilteredLocations] = useState([]);
const [isOpen, setIsOpen] = useState(false);
const handleInputChange = (e) => {
const value = e.target.value;
setInputValue(value);
setIsOpen(true);
const filtered = date_me_doc_locations.filter(location =>
location.toLowerCase().includes(value.toLowerCase())
);
setFilteredLocations(filtered);
};
const handleSelectLocation = (location) => {
setInputValue(location);
setIsOpen(false);
};
return (
<div class="relative w-[200px]">
<input
type="text"
name="location"
value={inputValue}
onInput={handleInputChange}
class="w-full border border-gray-300 px-2 py-1"
placeholder="Search location..."
/>
{isOpen && filteredLocations.length > 0 && (
<ul class="absolute z-10 w-full bg-white border border-gray-300 mt-1 max-h-60 overflow-auto">
{filteredLocations.map((location) => (
<li
key={location}
class="px-2 py-1 cursor-pointer hover:bg-gray-100"
onClick={() => handleSelectLocation(location)}
>
{location}
</li>
))}
</ul>
)}
</div>
);
};
return (
<Layout activeTab={new URL(c.req.url).pathname}>
<div class="max-w-lg mx-auto p-10">
<div class="mb-10">
<div class="text-4xl font-bold mb-4">
Date thoughtfully
</div>
<div class="text-lg">
Date Me Docs are long-form, earnest dating profiles for romantic partners.
</div>
</div>
<form class="space-y-4" action="/browse">
<div class="flex text-xl space-x-2">
<div>I'm</div>
<select name="gender" class="border border-gray-300">
<option value="" class="text-gray-500">...</option>
<option value="m">male</option>
<option value="f">female</option>
<option value="nb">non-binary</option>
</select>
</div>
<div class="flex text-xl space-x-2">
<div>Looking for</div>
<select name="desired-gender" class="border border-gray-300">
<option value="">...</option>
<option value="m">male</option>
<option value="f">female</option>
<option value="nb">non-binary</option>
</select>
</div>
<div class="flex text-xl space-x-2">
<div>Between</div>
<input defaultValue={18} type="number" name="min-age" class="w-12 h-min border border-gray-300" />
<div>and</div>
<input defaultValue={70} type="number" name="max-age" class="w-12 border border-gray-300" />
<div>years old</div>
</div>
<div class="flex text-xl space-x-2 items-center relative">
<div>In</div>
<AutocompleteInput />
</div>
<button class="border text-xl border-gray-300 px-4 py-2 bg-blue-500 text-white font-bold rounded">
Search
</button>
</form>
</div>
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
August 17, 2024