Skip to content

Commit

Permalink
Feature/#205 DatePicker 구현 (#209)
Browse files Browse the repository at this point in the history
* chore: react-datepicker 추가

#205

* feat: DatePicker 구현

#205

* refactor: 폴더 이름 변경

#205

* fix: _focus 대신 _groupFocusWithin 사용

#205

* feat: wrapperClassName 추가하여 부모 너비 따라가도록 설정

#205
  • Loading branch information
yeonddori authored May 16, 2024
1 parent fe30cab commit 78a0e43
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 1 deletion.
100 changes: 100 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"jotai": "^2.6.1",
"next": "14.0.4",
"react": "^18",
"react-datepicker": "^6.6.0",
"react-dom": "^18",
"react-icons": "^5.0.1",
"react-textarea-autosize": "^8.5.3",
Expand Down
36 changes: 36 additions & 0 deletions src/components/StyledDatePicker/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Input, InputGroup, Icon, InputRightElement, Box } from '@chakra-ui/react';
import DatePicker from 'react-datepicker';
import { BiCalendar } from 'react-icons/bi';
import 'react-datepicker/dist/react-datepicker.css';

import './style.css';
import { StyledDatePickerProps } from './types';

const StyledDatePicker = ({ label, selectedDate, onChange }: StyledDatePickerProps) => {
return (
<Box w="100%" role="group">
<DatePicker
selected={selectedDate}
onChange={onChange}
wrapperClassName="styled_date_picker"
customInput={
<InputGroup w="100%">
<Input
textStyle="bold_xl"
_hover={{ cursor: 'pointer' }}
_placeholder={{ color: 'white' }}
placeholder={label}
readOnly
value={selectedDate ? selectedDate.toLocaleDateString() : ''}
/>
<InputRightElement _hover={{ cursor: 'pointer' }}>
<Icon as={BiCalendar} textStyle="bold_xl" mr="5" color="gray.50" />
</InputRightElement>
</InputGroup>
}
/>
</Box>
);
};

export default StyledDatePicker;
3 changes: 3 additions & 0 deletions src/components/StyledDatePicker/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.styled_date_picker {
width: 100%;
}
5 changes: 5 additions & 0 deletions src/components/StyledDatePicker/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface StyledDatePickerProps {
label: string;
selectedDate: Date | null;
onChange: (date: Date | null) => void;
}
2 changes: 1 addition & 1 deletion src/theme/components/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const Input = defineMultiStyleConfig({
bg: 'orange_light',
color: 'white',
rounded: '2xl',
_focus: {
_groupFocusWithin: {
borderColor: 'orange',
bg: 'orange',
},
Expand Down

0 comments on commit 78a0e43

Please sign in to comment.