Skip to content

Commit ac2fbdb

Browse files
committed
UIを整えた
1 parent eb3d41b commit ac2fbdb

File tree

3 files changed

+7
-14
lines changed

3 files changed

+7
-14
lines changed

web/app/search/page.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ export default function SearchPage(props: {
1414
const query = searchParams?.query || "";
1515

1616
return (
17-
<div className="flex min-h-screen items-center justify-center bg-gray-100">
18-
<div className="card w-96 bg-white p-6 shadow-md">
19-
<h2 className="mb-4 font-bold text-2xl">Search</h2>
17+
<div className="flex min-h-screen justify-center ">
18+
<div className="w-full">
19+
<h2 className="m-5 mb-4 font-bold text-2xl">ユーザー検索</h2>
2020
<Search placeholder="検索" />
2121
<Table query={query} />
2222
</div>

web/components/search/search.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ export default function Search({ placeholder }: { placeholder: string }) {
1919
}
2020

2121
return (
22-
<div className="relative flex flex-1 flex-shrink-0">
22+
<div className="relative mr-5 ml-5 flex flex-1 flex-shrink-0">
2323
<label htmlFor="search" className="sr-only">
2424
Search
2525
</label>
2626
<input
27-
className="peer block w-full rounded-md border border-gray-200 py-[9px] pl-10 text-sm outline-2 placeholder:text-gray-500"
27+
className=" block w-full rounded-md border border-gray-200 py-[9px] pl-10 text-sm outline-none placeholder:text-gray-500 focus:border-primary focus:ring-1 focus:ring-primary"
2828
placeholder={placeholder}
2929
onChange={(e) => {
3030
handleSearch(e.target.value);

web/components/search/table.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,16 @@ export default function UserTable({ query }: { query: string }) {
1313

1414
const [users, setUsers] = useState<User[] | null>(null);
1515

16-
useEffect(() => {
17-
if (data) {
18-
setUsers(data);
19-
}
20-
}, [data]);
21-
2216
useEffect(() => {
2317
function searchByUserName(query: string) {
2418
const filteredUsers = data?.filter((user) =>
2519
user.name.toLowerCase().includes(query.toLowerCase()),
2620
);
2721
setUsers(filteredUsers || null);
2822
}
29-
if (query === "") {
23+
if (!query) {
3024
setUsers(data);
31-
}
32-
if (query) {
25+
} else {
3326
searchByUserName(query);
3427
}
3528
}, [query, data]);

0 commit comments

Comments
 (0)