Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions components/Search/SearchInput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { ChangeEvent, FormEvent, useState } from "react";
import { useRouter } from "next/router";
import Image from "next/image";

export const SearchInput = () => {
const router = useRouter();
const [value, setValue] = useState("");

const handleChange = (e: ChangeEvent<HTMLInputElement>) => {
setValue(e.target.value);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

입력값을 받을때 debounce를 적용해봐도 좋을것같습니다 !

};

const handleSubmit = (e: FormEvent<HTMLFormElement>) => {
e.preventDefault();
router.push({
pathname: router.pathname,
query: { ...router.query, search: value },
});
};

return (
<form
onSubmit={handleSubmit}
className="flex gap-[8px] w-[1024px] h-[54px] items-center px-[16px] py-[15px] bg-gray-100 rounded-[10px] md:w-[704px] md:h-[54px] sm:w-[325px] sm:h-[43px] transition-all"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

혹시 민지님이 작업하신 Container (layout) 에 들어가는거면 w-full 로 해도되지않을까요?

Copy link
Collaborator Author

@junjeeong junjeeong Nov 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저희는 특정 페이지에서만 쓰이긴 하지만 ui 컴포넌트는 다른 곳에서 금방 쓸 수 있도록 재사용성을 고려해서 만들어야 한다고 생각했습니다! 고로 부모 컴포넌트에 종속적으로 크기를 갖는 게 아닌 이 친구만의 고유한 width가 있어야 한다고 생각했습니다!

>
<Image
src="/icons/search.svg"
width={16}
height={16}
alt="search button"
/>
<input
value={value}
onChange={handleChange}
placeholder="링크를 검색해 보세요."
className="flex-grow bg-transparent placeholder:text-gray-500"
/>
</form>
);
};

export default SearchInput;
4 changes: 4 additions & 0 deletions public/icons/search.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

@font-face {
font-family: "Pretendard-Regular";
src: url("https://fastly.jsdelivr.net/gh/Project-Noonnu/[email protected]/Pretendard-Regular.woff")
format("woff");
src: url("https://fastly.jsdelivr.net/gh/Project-Noonnu/[email protected]/Pretendard-Regular.woff") format("woff");
font-weight: 400;
font-style: normal;
}
Expand Down Expand Up @@ -36,3 +35,7 @@ button {
cursor: pointer;
font-family: inherit;
}

input {
outline: none;
}
6 changes: 3 additions & 3 deletions tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ const config: Config = {
purple100: "#6d6afe",
},
screens: {
sm: "343px",
md: "768px",
lg: "1200px",
sm: { min: "343px", max: "767px" },
md: { min: "768px", max: "1199px" },
lg: { min: "1200px" },
},
},
},
Expand Down
Loading