Skip to content

Commit

Permalink
Merge pull request #186 from baegyeong/main
Browse files Browse the repository at this point in the history
style: input 폴더 대소문자 구분
  • Loading branch information
baegyeong authored May 27, 2024
2 parents 4576718 + bd54269 commit ddc6e2b
Show file tree
Hide file tree
Showing 3 changed files with 137 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/components/common/input/Input.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import styled from "styled-components";

const Input = ({ type, placeholder, id, register, rules }) => {
return (
<>
<InputField
type={type}
id={id}
placeholder={placeholder}
autoComplete="off"
{...register(id, { ...rules })}
/>
</>
);
};

const InputField = styled.input`
height: 2.8rem;
border-radius: 0.3rem;
outline: none;
border: none;
border: 1.3px solid #216d32;
width: 100%;
padding-left: 1rem;
&::placeholder {
color: #b3b3b3;
}
`;

export default Input;
76 changes: 76 additions & 0 deletions src/components/common/input/InputGroup.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import Input from "./Input";
import Box from "@/components/register/Box";
import Label from "@/components/register/Label";
import AlertMessage from "@/components/register/AlertMessage";
import DoubleCheck from "@/components/register/DoubleCheck";
import styled from "styled-components";
import { DoubleCheckStyle } from "../../register/DoubleCheck";

const InputGroup = ({
id,
type,
label,
placeholder,
mypage,
margin,
btn,
register,
error,
rules,
doubleCheck,
value,
onClick,
}) => {
return (
<Box>
<Label htmlFor={id} child={label} margin={margin}></Label>
<InputCss>
<Input
id={id}
type={type}
placeholder={placeholder}
mypage={mypage}
register={register}
rules={rules}
/>
{doubleCheck && (
<DoubleCheck
active={value && !error}
onClick={doubleCheck}
></DoubleCheck>
)}
</InputCss>

{error && <AlertMessage>{error?.message}</AlertMessage>}

{btn && (
<ChangeButton className="mypageBtn" onClick={onClick}>
변경
</ChangeButton>
)}
</Box>
);
};
const InputCss = styled.div`
position: relative;
display: flex;
align-items: center;
margin-bottom: 1rem;
margin-top: 1rem;
@media screen and (max-width: 1023px) {
width: 100%;
}
`;

const ChangeButton = styled(DoubleCheckStyle)`
background-color: #fefefe;
color: #216d32;
border: 1px solid #216d32;
width: 4rem;
height: 2rem;
position: relative;
right: 0.5rem;
`;

export default InputGroup;
30 changes: 30 additions & 0 deletions src/components/common/input/SelectInput.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { useFormContext } from "react-hook-form";
import { StyledElement } from "@/styles/StyledInput";

const SelectInput = ({ name, id, selected, list }) => {
const { register } = useFormContext();

return (
<StyledElement
as="select"
name={name}
id={id}
required
defaultValue={selected}
{...register(name, {
required: true,
})}
>
<option value="default" disabled>
카테고리를 선택하세요.
</option>
{list.map((item) => (
<option key={item} value={item}>
{item}
</option>
))}
</StyledElement>
);
};

export default SelectInput;

0 comments on commit ddc6e2b

Please sign in to comment.