Skip to content

Commit

Permalink
chore: Calendar内にHeadingが存在しないため、Sectionでのマークアップを辞める
Browse files Browse the repository at this point in the history
  • Loading branch information
AtsushiM committed Jan 29, 2025
1 parent 058d87b commit 46cea3f
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions packages/smarthr-ui/src/components/Calendar/Calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import dayjs from 'dayjs'
import React, {
ComponentProps,
MouseEvent,
PropsWithChildren,
forwardRef,
useCallback,
useEffect,
Expand All @@ -16,7 +17,6 @@ import { tv } from 'tailwind-variants'
import { Button } from '../Button'
import { FaCaretDownIcon, FaCaretUpIcon, FaChevronLeftIcon, FaChevronRightIcon } from '../Icon'
import { Cluster } from '../Layout'
import { Section } from '../SectioningContent'

import { CalendarTable } from './CalendarTable'
import { YearPicker } from './YearPicker'
Expand All @@ -32,7 +32,7 @@ type Props = {
/** 選択された日付 */
value?: Date
}
type ElementProps = Omit<ComponentProps<'section'>, keyof Props>
type ElementProps = Omit<ComponentProps<'div'>, keyof Props>
type DayJsType = ReturnType<typeof dayjs>

const calendar = tv({
Expand Down Expand Up @@ -109,9 +109,8 @@ export const Calendar = forwardRef<HTMLDivElement, Props & ElementProps>(
() => ({
prev: currentMonth.subtract(1, 'month'),
next: currentMonth.add(1, 'month'),
year: currentMonth.year(),
month: currentMonth.month() + 1,
date: currentMonth.toDate(),
yearMonthStr: `${currentMonth.year()}${currentMonth.month() + 1}月`,
}),
[currentMonth],
)
Expand All @@ -130,12 +129,11 @@ export const Calendar = forwardRef<HTMLDivElement, Props & ElementProps>(
}, [])

return (
// eslint-disable-next-line smarthr/a11y-heading-in-sectioning-content
<Section {...props} ref={ref} className={styles.container}>
<div {...props} ref={ref} className={styles.container}>
<header className={styles.header}>
<div className={styles.yearMonth}>
{calculatedCurrentMonth.year}{calculatedCurrentMonth.month}
</div>
<YearMonthRender className={styles.yearMonth}>
{calculatedCurrentMonth.yearMonthStr}
</YearMonthRender>
<YearSelectButton
aria-expanded={isSelectingYear}
aria-controls={yearPickerId}
Expand Down Expand Up @@ -167,11 +165,15 @@ export const Calendar = forwardRef<HTMLDivElement, Props & ElementProps>(
selected={isValidValue ? value : null}
/>
</div>
</Section>
</div>
)
},
)

const YearMonthRender = React.memo<PropsWithChildren<{ className: string }>>(
({ children, className }) => <div className={className}>{children}</div>,
)

const YearSelectButton = React.memo<{
'aria-expanded': boolean
'aria-controls': string
Expand Down

0 comments on commit 46cea3f

Please sign in to comment.