header.tsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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='mx-2 mt-2 flex items-center'>
  14. <div className='flex-1'>
  15. <button
  16. onClick={handleOpenYearMonthPicker}
  17. 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'
  18. >
  19. <span>{`${months[currentDate.month()]} ${currentDate.year()}`}</span>
  20. <RiArrowDownSLine className='h-4 w-4 text-text-tertiary' />
  21. </button>
  22. </div>
  23. <button
  24. onClick={onClickPrevMonth}
  25. className='rounded-lg p-1.5 hover:bg-state-base-hover'
  26. >
  27. <RiArrowUpSLine className='h-[18px] w-[18px] text-text-secondary' />
  28. </button>
  29. <button
  30. onClick={onClickNextMonth}
  31. className='rounded-lg p-1.5 hover:bg-state-base-hover'
  32. >
  33. <RiArrowDownSLine className='h-[18px] w-[18px] text-text-secondary' />
  34. </button>
  35. </div>
  36. )
  37. }
  38. export default React.memo(Header)