-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feat] input supportingText 구현 #41
Changes from 5 commits
0cac093
465f73a
dae1ec7
5dc7127
c1ea374
e0c0c76
40ec4af
5453d32
fe286bd
f1c01fd
c0cbac3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,14 +3,23 @@ import { css } from '@emotion/react'; | |
import { InputProps } from '@/common/component/Input/Input'; | ||
import { theme } from '@/common/style/theme/theme'; | ||
|
||
export const inputContainerStyle = css({ | ||
export const containerStyle = css({ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
|
||
gap: '1.2rem', | ||
|
||
width: '100%', | ||
}); | ||
|
||
export const inputSupportStyle = css({ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
|
||
gap: '0.8rem', | ||
}); | ||
|
||
export const inputWarpperStyle = css({ | ||
export const warpperStyle = css({ | ||
display: 'flex', | ||
alignItems: 'center', | ||
|
||
|
@@ -28,17 +37,20 @@ export const inputStyle = css({ | |
|
||
'::placeholder': { | ||
color: theme.colors.gray_500, | ||
...theme.text.body03, | ||
}, | ||
}); | ||
|
||
export const variantStyle = (variant: Required<InputProps>['variant']) => { | ||
export const variantStyle = ({ variant, isError }: { variant: Required<InputProps>['variant']; isError: boolean }) => { | ||
const borderColor = isError ? `${theme.colors.red}` : `${theme.colors.gray_400}`; | ||
|
||
const style = { | ||
outline: { | ||
boxShadow: ` 0px 0px 0px 1px ${theme.colors.gray_400}`, | ||
boxShadow: ` 0px 0px 0px 1px ${borderColor}`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 요거 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. inset 안하면 원래의 경계선에 shadow가 생기고 inset을 설정하면 경계선 안에 shadow가 생기더라구요! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
그리고 추가적인 의견인데 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 그리고 현재 |
||
borderRadius: '8px', | ||
}, | ||
underline: { | ||
boxShadow: ` 0px 1px 0px ${theme.colors.gray_400}`, | ||
boxShadow: ` 0px 1px 0px ${borderColor}`, | ||
}, | ||
colored: { | ||
borderRadius: '100px', | ||
|
@@ -51,9 +63,9 @@ export const variantStyle = (variant: Required<InputProps>['variant']) => { | |
|
||
export const sizeStyle = (size: Required<InputProps>['size']) => { | ||
const style = { | ||
small: { padding: '0.8rem 1.2rem', ...theme.text.body04 }, | ||
medium: { padding: '1.2rem 1.2rem', ...theme.text.body02 }, | ||
large: { padding: '1.2rem 1.6rem', ...theme.text.body02 }, | ||
small: { padding: '0.8rem 1.2rem' }, | ||
medium: { padding: '1.2rem 1.2rem' }, | ||
large: { padding: '1.2rem 1.6rem' }, | ||
}; | ||
|
||
return style[size]; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
import React, { InputHTMLAttributes } from 'react'; | ||
|
||
import { | ||
inputContainerStyle, | ||
containerStyle, | ||
inputStyle, | ||
inputWarpperStyle, | ||
inputSupportStyle, | ||
sizeStyle, | ||
variantStyle, | ||
warpperStyle, | ||
} from '@/common/component/Input/Input.style'; | ||
import Label from '@/common/component/Label/Label'; | ||
import SupportingText from '@/common/component/SupportingText/SupportingText'; | ||
|
||
type InputSize = 'small' | 'medium' | 'large'; | ||
type InputVariant = 'outline' | 'underline' | 'colored'; | ||
|
@@ -18,15 +20,29 @@ export interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, | |
label?: string; | ||
LeftIcon?: React.FunctionComponent<React.SVGProps<SVGSVGElement>>; //svg 컴포넌트 | ||
isError?: boolean; | ||
isNotice?: boolean; | ||
supportingText?: string; | ||
} | ||
|
||
const Input = ({ variant, size = 'medium', label, LeftIcon, ...props }: InputProps) => { | ||
const Input = ({ | ||
variant, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 스타일 적용한 거 보니까 Required로 variant 값을 가져왔던데, 그렇다면 variant 값을 옵셔널로 주는 방향으로 코드를 작성하는 게 맞는 것 같습니다 ! |
||
size = 'medium', | ||
label, | ||
LeftIcon, | ||
isError = false, | ||
isNotice = false, | ||
supportingText, | ||
...props | ||
}: InputProps) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 특히
const Input = ({
...
}: InputProps, ref: ForwardRef<HTMLInputElement>) => {
return <input ref={ref} />;
}
export default forwardRef(Input) 이제 해당 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 넵! 알려주셔서 감사합니다~~!! |
||
return ( | ||
<article css={inputContainerStyle}> | ||
<article css={containerStyle}> | ||
{label && <Label id={label}>{label}</Label>} | ||
<div css={[inputWarpperStyle, variantStyle(variant), sizeStyle(size)]}> | ||
{LeftIcon && <LeftIcon />} | ||
<input css={[inputStyle]} {...props} /> | ||
<div css={inputSupportStyle}> | ||
<div css={[warpperStyle, variantStyle({ variant, isError }), sizeStyle(size)]}> | ||
{LeftIcon && <LeftIcon />} | ||
<input css={inputStyle} {...props} /> | ||
</div> | ||
{supportingText && <SupportingText text={supportingText} isError={isError} isNotice={isNotice} />} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 여기서 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이말을 듣고 children에 대해서 알아보고 적용하였습니다! |
||
</div> | ||
</article> | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { css } from '@emotion/react'; | ||
|
||
import { theme } from '@/common/style/theme/theme'; | ||
|
||
export const textStyle = (textColor: string) => | ||
css({ color: textColor, wordBreak: 'break-word', ...theme.text.body04 }); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { textStyle } from '@/common/component/SupportingText/SupportingText.style'; | ||
import { theme } from '@/common/style/theme/theme'; | ||
|
||
interface SupportingTextProps { | ||
text: string; | ||
isError?: boolean; //red | ||
isNotice?: boolean; //blue | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 주석을 사용하실거라면 저렇게 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 넵! 이름에서 용도가 드러난다고 판단해서 주석 삭제하였습니당 |
||
} | ||
|
||
const SupportingText = ({ text, isError = false, isNotice = false }: SupportingTextProps) => { | ||
const textColor = isError ? theme.colors.red : isNotice ? theme.colors.blue_900 : theme.colors.gray_400; | ||
return <p css={textStyle(textColor)}>{text}</p>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 요론거 가독성 좋게 그리고 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 넵! |
||
}; | ||
|
||
export default SupportingText; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
제가 스토리북으로 안 사실인데,
input
안의 텍스트에 대한 폰트 사이즈와 라인 헤이트도 설정해주셔야 될 것 같습니다 ! GUI 보구요 !There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오오! 알려주셔서 넘 감사합니다! 수정완료했습니다 !! 💯