header.tsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import React, { type FC } from 'react'
  2. import { RiArrowDownSLine, RiArrowUpSLine } from '@remixicon/react'
  3. import type { DatePickerHeaderProps } from '../types'
  4. import { useMonths } from '../hooks'
  5. const Header: FC<DatePickerHeaderProps> = ({
  6. handleOpenYearMonthPicker,
  7. currentDate,
  8. onClickNextMonth,
  9. onClickPrevMonth,
  10. }) => {
  11. const months = useMonths()
  12. return (
  13. <div className='flex items-center mx-2 mt-2'>
  14. <div className='flex-1'>
  15. <button
  16. onClick={handleOpenYearMonthPicker}
  17. className='flex items-center gap-x-0.5 px-2 py-1.5 rounded-lg hover:bg-state-base-hover text-text-primary system-md-semibold'
  18. >
  19. <span>{`${months[currentDate.month()]} ${currentDate.year()}`}</span>
  20. <RiArrowDownSLine className='w-4 h-4 text-text-tertiary' />
  21. </button>
  22. </div>
  23. <button
  24. onClick={onClickNextMonth}
  25. className='p-1.5 hover:bg-state-base-hover rounded-lg'
  26. >
  27. <RiArrowDownSLine className='w-[18px] h-[18px] text-text-secondary' />
  28. </button>
  29. <button
  30. onClick={onClickPrevMonth}
  31. className='p-1.5 hover:bg-state-base-hover rounded-lg'
  32. >
  33. <RiArrowUpSLine className='w-[18px] h-[18px] text-text-secondary' />
  34. </button>
  35. </div>
  36. )
  37. }
  38. export default React.memo(Header)