42 lines
1.3 KiB
TypeScript
Raw Normal View History

2025-02-19 10:56:18 +08:00
import React, { type FC } from 'react'
import { RiArrowDownSLine, RiArrowUpSLine } from '@remixicon/react'
import type { DatePickerHeaderProps } from '../types'
import { useMonths } from '../hooks'
const Header: FC<DatePickerHeaderProps> = ({
handleOpenYearMonthPicker,
currentDate,
onClickNextMonth,
onClickPrevMonth,
}) => {
const months = useMonths()
return (
<div className='mx-2 mt-2 flex items-center'>
2025-02-19 10:56:18 +08:00
<div className='flex-1'>
<button
onClick={handleOpenYearMonthPicker}
className='system-md-semibold flex items-center gap-x-0.5 rounded-lg px-2 py-1.5 text-text-primary hover:bg-state-base-hover'
2025-02-19 10:56:18 +08:00
>
<span>{`${months[currentDate.month()]} ${currentDate.year()}`}</span>
<RiArrowDownSLine className='h-4 w-4 text-text-tertiary' />
2025-02-19 10:56:18 +08:00
</button>
</div>
<button
onClick={onClickPrevMonth}
className='rounded-lg p-1.5 hover:bg-state-base-hover'
2025-02-19 10:56:18 +08:00
>
<RiArrowUpSLine className='h-[18px] w-[18px] text-text-secondary' />
2025-02-19 10:56:18 +08:00
</button>
<button
onClick={onClickNextMonth}
className='rounded-lg p-1.5 hover:bg-state-base-hover'
2025-02-19 10:56:18 +08:00
>
<RiArrowDownSLine className='h-[18px] w-[18px] text-text-secondary' />
2025-02-19 10:56:18 +08:00
</button>
</div>
)
}
export default React.memo(Header)