Skip to content

Commit fb7d430

Browse files
authored
Merge pull request #39 from codeit9-temporary/features/SearchInput-ui컴포넌트-구현
Feat: SearchInput 컴포넌트 구현, global.css input outline:none 추가, tailwind.config 반응형 값 수정
2 parents 992608a + cfec09b commit fb7d430

File tree

4 files changed

+54
-5
lines changed

4 files changed

+54
-5
lines changed

components/Search/SearchInput.tsx

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { ChangeEvent, FormEvent, useState } from "react";
2+
import { useRouter } from "next/router";
3+
import Image from "next/image";
4+
5+
export const SearchInput = () => {
6+
const router = useRouter();
7+
const [value, setValue] = useState("");
8+
9+
const handleChange = (e: ChangeEvent<HTMLInputElement>) => {
10+
setValue(e.target.value);
11+
};
12+
13+
const handleSubmit = (e: FormEvent<HTMLFormElement>) => {
14+
e.preventDefault();
15+
router.push({
16+
pathname: router.pathname,
17+
query: { ...router.query, search: value },
18+
});
19+
};
20+
21+
return (
22+
<form
23+
onSubmit={handleSubmit}
24+
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"
25+
>
26+
<Image
27+
src="/icons/search.svg"
28+
width={16}
29+
height={16}
30+
alt="search button"
31+
/>
32+
<input
33+
value={value}
34+
onChange={handleChange}
35+
placeholder="링크를 검색해 보세요."
36+
className="flex-grow bg-transparent placeholder:text-gray-500"
37+
/>
38+
</form>
39+
);
40+
};
41+
42+
export default SearchInput;

public/icons/search.svg

Lines changed: 4 additions & 0 deletions
Loading

styles/globals.css

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44

55
@font-face {
66
font-family: "Pretendard-Regular";
7-
src: url("https://fastly.jsdelivr.net/gh/Project-Noonnu/[email protected]/Pretendard-Regular.woff")
8-
format("woff");
7+
src: url("https://fastly.jsdelivr.net/gh/Project-Noonnu/[email protected]/Pretendard-Regular.woff") format("woff");
98
font-weight: 400;
109
font-style: normal;
1110
}
@@ -36,3 +35,7 @@ button {
3635
cursor: pointer;
3736
font-family: inherit;
3837
}
38+
39+
input {
40+
outline: none;
41+
}

tailwind.config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ const config: Config = {
2323
purple100: "#6d6afe",
2424
},
2525
screens: {
26-
sm: "343px",
27-
md: "768px",
28-
lg: "1200px",
26+
sm: { min: "343px", max: "767px" },
27+
md: { min: "768px", max: "1199px" },
28+
lg: { min: "1200px" },
2929
},
3030
},
3131
},

0 commit comments

Comments
 (0)