let's get IT with DAVINA ๐ป
react-datepicker ๋ณธ๋ฌธ
- Calender/style.jsx
import styled from "styled-components";
export const DatePickerContainer = styled.div`
display: flex;
input {
cursor: pointer;
background-color: transparent;
width: 100%;
height: 65px;
border: none;
padding: 40px 20px 13px 20px;
&:hover {
border-radius: 8px;
border: 2px solid ${(props) => props.theme.darkBlack};
}
}
.react-datepicker__day--keyboard-selected,
.react-datepicker__month-text--keyboard-selected,
.react-datepicker__quarter-text--keyboard-selected,
.react-datepicker__year-text--keyboard-selected {
border-radius: 50%;
background-color: ${(props) => props.theme.pointColor};
}
.react-datepicker__day--selected,
.react-datepicker__day--range-end,
.react-datepicker__day--in-selecting-range,
.react-datepicker__day--in-range,
.react-datepicker__day--selecting-range-end {
border-radius: 50%;
background-color: ${(props) => props.theme.pointColor};
}
.react-datepicker__day:hover,
.react-datepicker__month-text:hover,
.react-datepicker__quarter-text:hover,
.react-datepicker__year-text:hover {
border-radius: 50%;
}
`;
export const InOutBox = styled.div`
position: relative;
width: 50%;
border-right: ${({ first }) => (first ? "1px" : "0px")} solid #b0b0b0;
border-bottom: 1px solid #b0b0b0;
`;
export const FixedText = styled.div`
position: absolute;
z-index: 1;
left: 11%;
top: 23%;
font-size: 14px;
font-weight: bold;
`;
- Calender/Calender.jsx
import React from "react";
import DatePicker from "react-datepicker";
import "react-datepicker/dist/react-datepicker.css";
import { ko } from "date-fns/esm/locale";
import { DatePickerContainer, FixedText, InOutBox } from "./style";
export default function Calender({
startDate,
endDate,
setStartDate,
setEndDate,
}) {
return (
<>
<DatePickerContainer>
<InOutBox first>
<FixedText>์ฒดํฌ์ธ</FixedText>
<DatePicker
dateFormat={"yyyy.MM.dd"}
locale={ko}
minDate={new Date()}
selected={startDate}
onChange={(date) => setStartDate(date)}
selectsStart
startDate={startDate}
endDate={endDate}
monthsShown={2}
withPortal
placeholderText="๋ ์ง ์ ํ"
/>
</InOutBox>
<InOutBox>
<FixedText>์ฒดํฌ์์</FixedText>
<DatePicker
dateFormat={"yyyy.MM.dd"}
locale={ko}
minDate={new Date()}
selected={endDate}
onChange={(date) => setEndDate(date)}
selectsEnd
startDate={startDate}
endDate={endDate}
monthsShown={2}
withPortal
placeholderText="๋ ์ง ์ ํ"
/>
</InOutBox>
</DatePickerContainer>
</>
);
}
TRY-1. ๋๋ฒ์งธ DatePicker์ minDate={startDate}๋ก ์์ฑ์ ๋ฃ์ด์ ์ฒดํฌ์์ ์ผ์๋ ์์๋ ์ง ์ดํ๋ง ์ ํ ๊ฐ๋ฅํ๊ฒ ํ๋ ค ํ์ผ๋, ์ฒดํฌ์์ ๋ฌ๋ ฅ์ ๋จผ์ ์ ํํ ๊ฒฝ์ฐ ์์๋ ์ง๊ฐ ์ ํ๋์ด์์ง ์์ ์ด์ ๋ ์ง๋ฅผ ์ ํํ ์ ์์์..๊ผฌ์..
TRY-2. startDate๋ฅผ new Date()๋ก ํด์ ์ค๋๋ ์ง๋ถํฐ ์์ํ์ผ๋ endDate์๋ ๋์ผํ๊ฒ minDate์ new Date()๋ก ์ค์ ์ค๋ ๋ ์ง ์ดํ๋ง ์ ํ ๊ฐ๋ฅํ๊ฒ ํจ์ผ๋ก์จ ํด๊ฒฐ..
'DEV_IN > CSS' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
div์ img ๋ฃ๊ธฐ (props) (0) | 2023.02.09 |
---|---|
๊ธ์ ์ ์ด๊ณผ์? (0) | 2023.02.09 |
Position (0) | 2023.02.09 |
GMT/UTC time ํ์ โ2023-02-02โ format์ผ๋ก change (0) | 2023.02.08 |
React-Styled Components (0) | 2023.02.08 |
Comments