Skip to content

Commit

Permalink
style: CustomSelectorButton 공통 컴포넌트 (#71)
Browse files Browse the repository at this point in the history
* feat: businesscardcontainer

* style: Text 컴포넌트 textColor 속성 추가

* style: alerttext, countnumber 수정

* style: selectorbutton 수정

* style: customselectorbutton

* refactor: 필수 prop 설정

* refactor: pr 수정사항 반영

* refactor: 속성명 수정
  • Loading branch information
from1to2 authored Nov 8, 2023
1 parent 6b0a18a commit 470ae05
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
1 change: 1 addition & 0 deletions src/components/common/BusinessCardContainer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ const CameraIcon = styled.img`
width: 38px;
height: 38px;
`

const UploadLabel = styled.label`
cursor: pointer;
`
Expand Down
24 changes: 12 additions & 12 deletions src/components/common/CustomSelectorButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ import { palette } from '@/styles/palette'
type CustomSelectorButtonProps = {
isDarkMode: boolean
buttonName: string
onClick: (selected: boolean) => void
isButtonClicked: (selected: boolean) => void
onRemove: () => void
isButtonselected: boolean
maxLengthReached: boolean
isButtonSelected: boolean
isMaxLengthReached: boolean
}

const CustomSelectorButton = ({
isDarkMode,
buttonName,
onClick,
isButtonClicked,
onRemove,
isButtonselected: propIsButtonSelected,
maxLengthReached,
isButtonSelected: propIsButtonSelected,
isMaxLengthReached,
}: CustomSelectorButtonProps) => {
const defaultSettings = isDarkMode
? {
Expand All @@ -40,12 +40,12 @@ const CustomSelectorButton = ({
}, [propIsButtonSelected])

const handleButtonClick = () => {
if (maxLengthReached && !isButtonSelected) {
onClick && onClick(true)
if (isMaxLengthReached && !isButtonSelected) {
isButtonClicked && isButtonClicked(true)
return
}
setIsButtonSelected((prevState) => !prevState)
if (onClick) onClick(!isButtonSelected)
if (isButtonClicked) isButtonClicked(!isButtonSelected)
}

return (
Expand All @@ -61,7 +61,7 @@ const CustomSelectorButton = ({
>
{buttonName}
</StyledButton>
<RemoveButton onClick={onRemove}>
<StyledRemoveButton onClick={onRemove}>
<TiDelete
style={{
position: 'relative',
Expand All @@ -73,7 +73,7 @@ const CustomSelectorButton = ({
color: isDarkMode ? palette.GRAY300 : palette.BLACK,
}}
/>
</RemoveButton>
</StyledRemoveButton>
</StyledButtonWrapper>
)
}
Expand All @@ -83,7 +83,7 @@ const StyledButtonWrapper = styled.div`
align-items: center;
`

const RemoveButton = styled.button`
const StyledRemoveButton = styled.button`
margin-left: 8px;
background-color: transparent;
border: none;
Expand Down
6 changes: 3 additions & 3 deletions src/components/common/SelectorButtonContainer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ const SelectorButtonContainer = ({
key={index}
isDarkMode={isDarkMode}
buttonName={name}
onClick={(isSelected) => handleCustomButtonClick(isSelected)}
isButtonClicked={(isSelected) => handleCustomButtonClick(isSelected)}
onRemove={() => handleCustomButtonRemove(name)}
maxLengthReached={selectedCount >= maxLength}
isButtonselected={false}
isMaxLengthReached={selectedCount >= maxLength}
isButtonSelected={false}
/>
))}
{showAlert && (
Expand Down

0 comments on commit 470ae05

Please sign in to comment.