-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8ab080f
commit a7ec7f4
Showing
6 changed files
with
132 additions
and
91 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,15 @@ | ||
import { renderHook, act } from '@testing-library/react'; | ||
|
||
/** | ||
* @jest-environment jsdom | ||
*/ | ||
|
||
test('useCount hook을 테스트한다.', () => { | ||
const { result } = renderHook(() => useCount()); | ||
|
||
act(() => { | ||
result.current.increase(); | ||
}); | ||
|
||
expect(result.current.count).toBe(1); | ||
}); |
97 changes: 21 additions & 76 deletions
97
frontend/src/components/optionList/WritingVoteOptionList/WritingVoteOption/index.tsx
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 |
---|---|---|
@@ -1,101 +1,46 @@ | ||
import React from 'react'; | ||
|
||
import { styled } from 'styled-components'; | ||
|
||
import OptionCancelButton from './OptionCancelButton'; | ||
import OptionUploadImageButton from './OptionUploadImageButton'; | ||
import * as S from './style'; | ||
|
||
interface WritingVoteOptionProps { | ||
text: string; | ||
isDeletable: boolean; | ||
handleDeleteOptionClick: () => void; | ||
imageUrl?: string; | ||
} | ||
|
||
const Container = styled.li` | ||
display: flex; | ||
gap: 10px; | ||
`; | ||
|
||
const OptionContainer = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
width: 100%; | ||
padding: 20px; | ||
border-radius: 4px; | ||
background-color: #e6e6e6; | ||
`; | ||
|
||
const ContentContainer = styled.div` | ||
display: flex; | ||
justify-content: space-between; | ||
width: 100%; | ||
`; | ||
|
||
const ContentTextArea = styled.textarea` | ||
width: 100%; | ||
margin-right: 10px; | ||
padding: 8px; | ||
font-size: 1.3rem; | ||
line-height: 2.4rem; | ||
background-color: #e6e6e6; | ||
resize: none; | ||
`; | ||
|
||
const ImageContainer = styled.div` | ||
width: 80%; | ||
margin-top: 20px; | ||
position: relative; | ||
`; | ||
|
||
const Image = styled.img` | ||
width: 100%; | ||
border-radius: 4px; | ||
aspect-ratio: 1/1; | ||
object-fit: cover; | ||
`; | ||
|
||
const ImageCancelWrapper = styled.div` | ||
position: absolute; | ||
top: 10px; | ||
right: 10px; | ||
`; | ||
|
||
export default function WritingVoteOption({ text, isDeletable, imageUrl }: WritingVoteOptionProps) { | ||
export default function WritingVoteOption({ | ||
text, | ||
isDeletable, | ||
handleDeleteOptionClick, | ||
imageUrl, | ||
}: WritingVoteOptionProps) { | ||
return ( | ||
<Container> | ||
<S.Container> | ||
{isDeletable && ( | ||
<div title="선택지 삭제하기"> | ||
<div title="선택지 삭제하기" onClick={handleDeleteOptionClick}> | ||
<OptionCancelButton /> | ||
</div> | ||
)} | ||
<OptionContainer> | ||
<ContentContainer> | ||
<ContentTextArea | ||
<S.OptionContainer> | ||
<S.ContentContainer> | ||
<S.ContentTextArea | ||
value={text} | ||
placeholder="내용을 입력해주세요." | ||
rows={2} | ||
maxLength={50} | ||
/> | ||
{!imageUrl && <OptionUploadImageButton />} | ||
</ContentContainer> | ||
</S.ContentContainer> | ||
{imageUrl && ( | ||
<ImageContainer> | ||
<Image src={imageUrl} alt={text} /> | ||
<ImageCancelWrapper> | ||
<S.ImageContainer> | ||
<S.Image src={imageUrl} alt={text} /> | ||
<S.ImageCancelWrapper> | ||
<OptionCancelButton /> | ||
</ImageCancelWrapper> | ||
</ImageContainer> | ||
</S.ImageCancelWrapper> | ||
</S.ImageContainer> | ||
)} | ||
</OptionContainer> | ||
</Container> | ||
</S.OptionContainer> | ||
</S.Container> | ||
); | ||
} |
59 changes: 59 additions & 0 deletions
59
frontend/src/components/optionList/WritingVoteOptionList/WritingVoteOption/style.ts
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 'styled-components'; | ||
|
||
export const Container = styled.li` | ||
display: flex; | ||
gap: 10px; | ||
`; | ||
|
||
export const OptionContainer = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
width: 100%; | ||
padding: 20px; | ||
border-radius: 4px; | ||
background-color: #e6e6e6; | ||
`; | ||
|
||
export const ContentContainer = styled.div` | ||
display: flex; | ||
justify-content: space-between; | ||
gap: 10px; | ||
width: 100%; | ||
`; | ||
|
||
export const ContentTextArea = styled.textarea` | ||
width: 100%; | ||
padding: 8px; | ||
font-size: 1.3rem; | ||
line-height: 2.4rem; | ||
background-color: #e6e6e6; | ||
resize: none; | ||
`; | ||
|
||
export const ImageContainer = styled.div` | ||
width: 80%; | ||
margin-top: 20px; | ||
position: relative; | ||
`; | ||
|
||
export const Image = styled.img` | ||
width: 100%; | ||
border-radius: 4px; | ||
aspect-ratio: 1/1; | ||
object-fit: cover; | ||
`; | ||
|
||
export const ImageCancelWrapper = styled.div` | ||
position: absolute; | ||
top: 10px; | ||
right: 10px; | ||
`; |
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
7 changes: 7 additions & 0 deletions
7
frontend/src/components/optionList/WritingVoteOptionList/style.ts
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,7 @@ | ||
import { styled } from 'styled-components'; | ||
|
||
export const Container = styled.ul` | ||
display: flex; | ||
flex-direction: column; | ||
gap: 20px; | ||
`; |