Skip to content
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

style: businessCardContainer 공통 컴포넌트 #56

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 112 additions & 0 deletions src/components/common/BusinessCardContainer/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import styled from '@emotion/styled'
import { useState } from 'react'
import { TiDelete } from 'react-icons/ti'

import camera from '@/assets/images/camera.svg'
import { palette } from '@/styles/palette'

import Spacing from '../Spacing'
import { Text } from '../Text'

type BusinessCardContainerProps = {
isDarkMode: boolean
}

const BusinessCardContainer = ({ isDarkMode }: BusinessCardContainerProps) => {
const [uploadedImage, setUploadedImage] = useState<string | null>(null)

const handleImageUpload = (event: React.ChangeEvent<HTMLInputElement>) => {
if (!uploadedImage) {
const file = event.target.files?.[0]
const reader = new FileReader()

reader.onloadend = () => {
setUploadedImage(reader.result as string)
}

if (file) {
reader.readAsDataURL(file)
}
}
}

const handleRemoveImage = () => {
setUploadedImage(null)
}

return (
<Wrapper>
<Text
font={'Body_20'}
fontWeight={700}
letterSpacing={-1}
textColor={isDarkMode ? palette.WHITE : palette.BLACK}
>
{'명함사진 업로드'}
Comment on lines +39 to +45
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍👍

</Text>
<Spacing size={10} />
<ImageContainer>
{uploadedImage ? (
<>
<StyledImage src={uploadedImage} alt={'Uploaded'} />
<TiDelete
style={{
position: 'absolute',
top: -10,
right: -15,
width: 24,
height: 24,
cursor: 'pointer',
color: isDarkMode ? palette.GRAY300 : palette.BLACK,
}}
onClick={handleRemoveImage}
/>
</>
) : (
<label style={{ cursor: 'pointer' }}>
<input type={'file'} onChange={handleImageUpload} style={{ display: 'none' }} />
<Placeholder>
<CameraIcon src={camera} alt={'Upload Placeholder'} />
</Placeholder>
</label>
)}
</ImageContainer>
</Wrapper>
)
}

const Wrapper = styled.div`
position: relative;
width: 300px;
`

const Placeholder = styled.div`
width: 88px;
height: 88px;
background-color: ${palette.WHITE};
border-radius: 10px;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
`

const ImageContainer = styled.div`
width: 88px;
position: relative;
`

const StyledImage = styled.img`
width: 88px;
height: 88px;
object-fit: cover;
position: relative;
border-radius: 10px;
`

const CameraIcon = styled.img`
width: 38px;
height: 38px;
`

export default BusinessCardContainer
2 changes: 1 addition & 1 deletion src/components/common/SelectorButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

return (
<StyledButton
backgroundColor={backgroundColor}

Check failure on line 50 in src/components/common/SelectorButton/index.tsx

View workflow job for this annotation

GitHub Actions / build

Type '{ children: string; backgroundColor: string; textColor: string; onClick: () => void; }' is not assignable to type 'IntrinsicAttributes & { theme?: Theme | undefined; as?: ElementType<any> | undefined; } & SelectorButtonProps & ClassAttributes<...> & ButtonHTMLAttributes<...>'.
textColor={currentTextColor}
onClick={handleButtonClick}
>
Expand All @@ -56,7 +56,7 @@
)
}

const StyledButton = styled.button<{ backgroundColor: string; textColor: string }>`
const StyledButton = styled.button<SelectorButtonProps>`
margin: 8px;
height: 36px;
padding: 10px 15px 10px 15px;
Expand All @@ -64,7 +64,7 @@
cursor: pointer;
border: none;
border-radius: 10px;
background-color: ${(props) => props.backgroundColor};

Check failure on line 67 in src/components/common/SelectorButton/index.tsx

View workflow job for this annotation

GitHub Actions / build

Property 'backgroundColor' does not exist on type '{ theme?: Theme | undefined; as?: ElementType<any> | undefined; } & ClassAttributes<HTMLButtonElement> & ButtonHTMLAttributes<HTMLButtonElement> & SelectorButtonProps & { ...; }'.
transition: background-color 0.3s;
&:hover {
opacity: 0.9;
Expand All @@ -72,7 +72,7 @@
&:focus {
outline: none;
}
color: ${(props) => props.textColor};

Check failure on line 75 in src/components/common/SelectorButton/index.tsx

View workflow job for this annotation

GitHub Actions / build

Property 'textColor' does not exist on type '{ theme?: Theme | undefined; as?: ElementType<any> | undefined; } & ClassAttributes<HTMLButtonElement> & ButtonHTMLAttributes<HTMLButtonElement> & SelectorButtonProps & { ...; }'.
display: inline-block;
vertical-align: middle;
line-height: 1;
Expand Down
4 changes: 3 additions & 1 deletion src/components/common/Text/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ export const Text = styled.div<{
font: KeyOfTypo
fontWeight: number
letterSpacing: number
textColor?: string
}>`
${({ font, fontWeight, letterSpacing }) => {
${({ font, fontWeight, letterSpacing, textColor }) => {
const fontFunc = typo[font]
return css`
${fontFunc(fontWeight, letterSpacing)}
color: ${textColor};
`
}}
`
Loading