Comments (2)
목적
react-datepicker 라이브러리 의존성 제거
작업 스케줄
- DatePicker 컴포넌트 스타일 구현 시도
- DatePicker 컴포넌트 기능 구현 시도
- DateRangePicker 컴포넌트 스타일 구현 시도
- DateRangePicker 컴포넌트 기능 구현 시도
- 설계 구상
- 만들어진 DatePicker 컴포넌트를 이용해서 DateRangePicker 스타일 구현
- 만들어진 DatePicker 컴포넌트를 이용해서 DateRangePicker 기능 구현
- DatePicker 컴포넌트에 props를 전달받아 레인지 기능을 사용 할 수 있도록 구현
필요한 정보
- forwardRef 정의, 인자, 제네릭
- date-fns
- Omit
from react-libraries.
📌 예시 코드
기본 타입
import { Fragment } from 'react'
import { Controller } from 'react-hook-form'
import { useTheme } from '@emotion/react'
import { useFormSearch } from '@musma/react-utils'
import { DateTime } from 'luxon'
import { DatePicker, SearchForm } from './components'
const Component = () => {
const theme = useTheme()
const { control, onSubmit, handleSubmit, getValues } = useFormSearch({
useFormProps: {
defaultValues: {
date: DateTime.now().setZone('Asia/Seoul'),
},
},
fetchAPI() {
const { date } = getValues()
console.log('date', date)
},
})
return (
<Fragment>
<SearchForm onSubmit={handleSubmit(onSubmit)}>
{/* DatePicker 기본 타입 */}
<Controller
name="date"
control={control}
render={({ field }) => {
return <DatePicker label="기본 타입" {...field} />
}}
/>
</SearchForm>
</Fragment>
)
}
export default Component
레인지 타입 - default값이 필요한 경우
import { Fragment } from 'react'
import { Controller } from 'react-hook-form'
import { useTheme } from '@emotion/react'
import { useFormSearch } from '@musma/react-utils'
import { DateTime } from 'luxon'
import { DatePicker, SearchForm } from './components'
const Component = () => {
const theme = useTheme()
const { control, onSubmit, handleSubmit, getValues } = useFormSearch({
useFormProps: {
defaultValues: {
date: [
DateTime.now().setZone('Asia/Seoul'),
DateTime.now().setZone('Asia/Seoul'),
],
},
},
fetchAPI() {
const { date } = getValues()
console.log('date', date)
},
})
return (
<Fragment>
<SearchForm onSubmit={handleSubmit(onSubmit)}>
{/* DatePicker 레인지 타입 (defaultValue O) */}
<Controller
name="date"
control={control}
render={({ field: { value, ...rest } }) => {
const [startDate, endDate] = value
return (
<DatePicker
label="레인지 타입(디폴트 o)"
startDate={startDate}
endDate={endDate}
selectRange={true}
{...rest}
/>
)
}}
/>
</SearchForm>
</Fragment>
)
}
export default Component
레인지 타입 - default값이 필요하지 않은 경우
import { Fragment } from 'react'
import { Controller } from 'react-hook-form'
import { useTheme } from '@emotion/react'
import { useFormSearch } from '@musma/react-utils'
import { DateTime } from 'luxon'
import { DatePicker, SearchForm } from './components'
const Component = () => {
const theme = useTheme()
const { control, onSubmit, handleSubmit, getValues } = useFormSearch({
useFormProps: {
defaultValues: {
date: [null, null]
},
},
fetchAPI() {
const { date } = getValues()
console.log('date', date)
},
})
return (
<Fragment>
<SearchForm onSubmit={handleSubmit(onSubmit)}>
{/* DatePicker 레인지 타입 (defaultValue O) */}
<Controller
name="date"
control={control}
render={({ field: { value, ...rest } }) => {
const [startDate, endDate] = value
return (
<DatePicker
label="레인지 타입(디폴트 o)"
startDate={startDate}
endDate={endDate}
selectRange={true}
{...rest}
/>
)
}}
/>
</SearchForm>
</Fragment>
)
}
export default Component
영문 달력으로 변경
<DatePicker i18n="en" {...rest} />
from react-libraries.
Related Issues (20)
- useFormSearch 기능 수정
- useFormSearch, getFileSize 수정
- useFormSearch InitPageable props 추가
- pagination 버그 수정 HOT 1
- NPM 퍼블릭 배포 HOT 2
- eslint-config-react comment HOT 1
- useFullScreen bug HOT 1
- DateRangePicker 수정사항
- Flex , Table, Typography component 기능 추가 및 수정
- Docs 정리
- [FEATURE] 멀티 테마 기능 HOT 2
- [BUG] 한 페이지 안에서 두 개의 useFormSearch를 사용할 때, formState가 겹치는 문제
- [FEATURE] 화면에서 숫자를 표시할 때, 숫자 사이의 콤마를 찍는 유틸 함수 추가
- [FEATURE] NavBar에 폴딩(Folding) 기능 추가하기 HOT 2
- [BUG] 디자인 시스템 오적용 수정
- [BUG] 일부 기능 수정
- [BUG] 크롬 콘솔 내 aria-hidden 에러 메시지
- [BUG] 모달 overflow 현상 HOT 2
- [BUG] input 컴포넌트들의 border color가 다름
- [BUG] Select 컴포넌트 내 selected option 폰트색이 검정색임
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-libraries.