-
Notifications
You must be signed in to change notification settings - Fork 0
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
afa03d8
commit f89b7bb
Showing
3 changed files
with
91 additions
and
0 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,40 @@ | ||
import React, { useState } from 'react'; | ||
import * as S from './DaterangePicker.style'; | ||
|
||
const DaterangePicker = () => { | ||
const [startDate, setStartDate] = useState(new Date()); | ||
const [endDate, setEndDate] = useState(new Date()); | ||
|
||
const handleDateChange = (date, type) => { | ||
if (type === 'start') { | ||
setStartDate(date); | ||
} else if (type === 'end') { | ||
setEndDate(date); | ||
} | ||
}; | ||
|
||
return ( | ||
<> | ||
<S.Wrapper> | ||
<S.Container> | ||
<S.Label>행사 기간</S.Label> | ||
<S.StyledDatePicker | ||
onSelect={(date) => handleDateChange(date, 'start')} | ||
selected={startDate} | ||
dateFormat="yyyy-MM-dd" | ||
placeholderText={startDate} | ||
/> | ||
<S.TildeIcon /> | ||
<S.StyledDatePicker | ||
onSelect={(date) => handleDateChange(date, 'end')} | ||
selected={endDate} | ||
dateFormat="yyyy-MM-dd" | ||
placeholderText={endDate} | ||
/> | ||
</S.Container> | ||
</S.Wrapper> | ||
</> | ||
); | ||
}; | ||
|
||
export default DaterangePicker; |
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,50 @@ | ||
import { BREAKPOINTS } from '@/styles'; | ||
import DatePicker from 'react-datepicker'; | ||
import { PiTildeBold } from 'react-icons/pi'; | ||
import styled from 'styled-components'; | ||
|
||
export const Wrapper = styled.div` | ||
position: relative; | ||
display: inline-block; | ||
`; | ||
|
||
export const Container = styled.div` | ||
display: flex; | ||
flex-wrap: wrap; | ||
justify-content: end; | ||
align-items: center; | ||
gap: 10px; | ||
`; | ||
|
||
export const Label = styled.div` | ||
display: flex; | ||
color: #6b6b6b; | ||
font-size: 20px; | ||
@media (max-width: ${BREAKPOINTS[1]}px) { | ||
display: none; | ||
} | ||
`; | ||
|
||
export const StyledDatePicker = styled(DatePicker)` | ||
border: none; | ||
background-color: #f8f8f8; | ||
padding: 10px 0 10px 20px; | ||
height: 24px; | ||
width: 128px; | ||
font-size: 18px; | ||
position: relative; | ||
border-radius: 10px; | ||
&:focus { | ||
outline: none; | ||
} | ||
`; | ||
|
||
export const TildeIcon = styled(PiTildeBold)` | ||
color: #2f7cef; | ||
@media (max-width: ${BREAKPOINTS[1]}px) { | ||
display: none; | ||
} | ||
`; |
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 @@ | ||
export { default as DaterangePicker } from './DaterangePicker'; |