-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #166 from KNU-HAEDAL/Refactor/cta-#165
CTA 버튼, textarea 리팩토링 & 모듈화 #165
- Loading branch information
Showing
5 changed files
with
123 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import styled from '@emotion/styled'; | ||
|
||
type CTAProps = { | ||
label: string; | ||
disabled?: boolean; | ||
onClick: () => void; | ||
}; | ||
|
||
const CTA = ({ label, disabled, onClick }: CTAProps) => { | ||
return ( | ||
<StyledCTA disabled={disabled} onClick={onClick}> | ||
{label} | ||
</StyledCTA> | ||
); | ||
}; | ||
|
||
export default CTA; | ||
|
||
const StyledCTA = styled.button<{ disabled?: boolean }>` | ||
width: calc(100% - 16px); // 부모 요소의 좌우 padding 빼고 | ||
border: none; | ||
border-radius: 10px; | ||
background-color: var(--color-green-01); | ||
color: var(--color-white); | ||
font-size: var(--font-size-md); | ||
font-weight: bold; | ||
outline: none; | ||
padding: 10px 8px; | ||
margin: 0 auto; | ||
&:disabled { | ||
cursor: not-allowed; | ||
color: var(--color-grey-01); | ||
background-color: var(--color-grey-02); | ||
} | ||
/* &:hover와 &:focus는 disabled === false일 때만 적용 */ | ||
&:hover, | ||
&:focus { | ||
${({ disabled }) => | ||
!disabled && | ||
` | ||
opacity: 0.8 !important; | ||
background-color: var(--color-green-01) !important; | ||
color: var(--color-white) !important; | ||
`} | ||
} | ||
`; | ||
|
||
// 컨테이너 필요할 때 따로 임포트하여 사용 | ||
export const CTAContainer = styled.div` | ||
position: sticky; | ||
bottom: 0; | ||
display: flex; | ||
width: 100%; | ||
height: 4rem; | ||
padding: 8px 16px; | ||
background-color: var(--color-white); | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import styled from '@emotion/styled'; | ||
|
||
type TextareaProps = { | ||
placeholder?: string; | ||
value: string; | ||
onChange: (e: React.ChangeEvent<HTMLTextAreaElement>) => void; | ||
valid?: boolean; | ||
}; | ||
|
||
const Textarea = ({ placeholder, value, onChange, valid }: TextareaProps) => { | ||
return ( | ||
<StyledTextarea | ||
placeholder={placeholder} | ||
value={value} | ||
onChange={onChange} | ||
valid={valid} | ||
/> | ||
); | ||
}; | ||
|
||
export default Textarea; | ||
|
||
const StyledTextarea = styled.textarea<{ valid?: boolean }>` | ||
font-size: var(--font-size-sm); | ||
color: var(--color-black); | ||
border-radius: 20px; | ||
border: ${({ valid }) => | ||
valid | ||
? 'var(--color-grey-02) 1px solid' | ||
: 'var(--color-class-05) 1px solid'}; | ||
padding: 12px; | ||
width: 100%; | ||
height: 180px; | ||
resize: none; | ||
outline: none; | ||
&::placeholder { | ||
color: var(--color-grey-01); | ||
opacity: 1; /* Firefox에서 placeholder 색상을 명시적으로 설정하기 위해 추가 */ | ||
} | ||
&:focus { | ||
border: ${({ valid }) => | ||
valid | ||
? 'var(--color-green-01) 1px solid' | ||
: 'var(--color-class-05) 1px solid'}; | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters