-
Notifications
You must be signed in to change notification settings - Fork 1
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 #177 from choco-team/175-fe-qrcode-page
175 fe qrcode page
- Loading branch information
Showing
12 changed files
with
582 additions
and
811 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import React, { useState, useRef } from 'react'; | ||
import { FaSquare } from 'react-icons/fa'; | ||
import { | ||
TfiLayoutGrid4Alt, | ||
TfiLayoutGrid2Alt, | ||
TfiLayoutGrid3Alt, | ||
} from 'react-icons/tfi'; | ||
import { useReactToPrint } from 'react-to-print'; | ||
|
||
import useModal from '@Hooks/useModal'; | ||
|
||
import Button from '@Components/Button'; | ||
|
||
import * as S from './style'; | ||
import QrcodePrintPage from '../QrcodePrintPage'; | ||
|
||
const QrcodePrintOption: React.FC = () => { | ||
const [selectedSize, setSelectedSize] = useState<string>(''); | ||
const { closeModal } = useModal(); | ||
const [number, setNumber] = useState<number>(0); | ||
const componentRef = useRef(); | ||
|
||
const handleChangeNumber = (e: React.ChangeEvent<HTMLInputElement>) => { | ||
const newValue = parseInt(e.target.value, 10); | ||
|
||
if (!isNaN(newValue) && newValue >= 0) { | ||
setNumber(newValue); | ||
} | ||
}; | ||
const increment = () => setNumber((prevNumber) => prevNumber + 1); | ||
const decrement = () => { | ||
setNumber((prevNumber) => (prevNumber > 0 ? prevNumber - 1 : 0)); | ||
}; | ||
|
||
const handleSizeSelect = (size: string) => { | ||
setSelectedSize(size); | ||
}; | ||
|
||
const handleCancelBtn = () => { | ||
closeModal(); | ||
}; | ||
|
||
const handlePrintBtn = useReactToPrint({ | ||
content: () => componentRef.current, | ||
}); | ||
return ( | ||
<S.Container> | ||
<S.NumberSelectContainer> | ||
<S.NameSpan>개수 선택</S.NameSpan> | ||
<S.NumberContainer> | ||
<S.NumberInput | ||
type="number" | ||
value={number} | ||
onChange={handleChangeNumber} | ||
/> | ||
</S.NumberContainer> | ||
</S.NumberSelectContainer> | ||
|
||
<S.SizeSelectContainer> | ||
<S.NameSpan>크기 선택</S.NameSpan> | ||
{['5x8', '4x4', '2x2', '1x1'].map((size) => ( | ||
<S.SizeSelectButton | ||
key={size} | ||
onClick={() => handleSizeSelect(size)} | ||
isSelected={selectedSize === size} | ||
> | ||
{size === '5x8' && <TfiLayoutGrid4Alt />} | ||
{size === '4x4' && <TfiLayoutGrid3Alt />} | ||
{size === '2x2' && <TfiLayoutGrid2Alt />} | ||
{size === '1x1' && <FaSquare />} | ||
</S.SizeSelectButton> | ||
))} | ||
</S.SizeSelectContainer> | ||
<S.SmallButtonWrapper> | ||
<Button concept="text" variant="gray" onClick={handleCancelBtn}> | ||
취소 | ||
</Button> | ||
<Button onClick={handlePrintBtn}>인쇄</Button> | ||
<QrcodePrintPage ref={componentRef} /> | ||
</S.SmallButtonWrapper> | ||
</S.Container> | ||
); | ||
}; | ||
|
||
export default QrcodePrintOption; |
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,90 @@ | ||
import styled from 'styled-components'; | ||
|
||
export const Container = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
/* align-items: center; */ | ||
margin-top: 30px; | ||
padding: 20px; | ||
width: 100%; | ||
gap: 30px; | ||
`; | ||
|
||
export const NameSpan = styled.span` | ||
margin: 5px; | ||
border-radius: 2px; | ||
min-height: 24px; | ||
min-width: 96px; | ||
padding: 8px; | ||
color: black; | ||
align-self: flex-start; | ||
`; | ||
|
||
export const SizeSelectContainer = styled.div` | ||
display: flex; | ||
align-items: center; | ||
gap: 10px; | ||
`; | ||
export const NumberSelectContainer = styled.div` | ||
display: flex; | ||
align-items: center; | ||
gap: 10px; | ||
`; | ||
|
||
export const NumberContainer = styled.div` | ||
display: flex; | ||
align-items: center; | ||
border: solid 1px #ccc; | ||
border-radius: 2px; | ||
`; | ||
|
||
export const NumberInput = styled.input` | ||
width: 60px; | ||
text-align: center; | ||
`; | ||
|
||
export const NumberUpdownButton = styled.div` | ||
width: 20px; | ||
height: 20px; | ||
cursor: pointer; | ||
user-select: none; | ||
text-align: center; | ||
color: #f48d8d; | ||
`; | ||
|
||
export const SizeSelectButton = styled.div<{ isSelected: boolean }>` | ||
border: solid 1px ${(props) => (props.isSelected ? '#F17071' : '#ccc')}; | ||
background-color: ${(props) => | ||
props.isSelected ? '#fee3e2' : 'transparent'}; | ||
border-radius: 2px; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
width: 40px; | ||
height: 40px; | ||
cursor: pointer; | ||
&:hover { | ||
background-color: #fee3e2; | ||
border: 1px solid #fe6f61; | ||
} | ||
`; | ||
|
||
export const ListSpan = styled.span` | ||
margin: 5px; | ||
border-radius: 2px; | ||
min-height: 24px; | ||
min-width: 96px; | ||
padding: 8px; | ||
color: 'black'; | ||
`; | ||
export const SmallButtonWrapper = styled.div` | ||
display: flex; | ||
padding: 0; | ||
margin-top: 24px; | ||
align-items: flex-end; | ||
justify-content: flex-end; | ||
button { | ||
margin-right: 5px; | ||
} | ||
`; |
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,9 @@ | ||
import React, { useState } from 'react'; | ||
|
||
import * as S from './style'; | ||
|
||
function QrcodePrintPage() { | ||
return; | ||
} | ||
|
||
export default QrcodePrintPage; |
Empty file.
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
Oops, something went wrong.