File tree Expand file tree Collapse file tree
packages/gamut/src/DatePicker/DatePickerCalendar/Calendar Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import { MiniChevronLeftIcon } from '@codecademy/gamut-icons' ;
1+ import {
2+ MiniChevronLeftIcon ,
3+ MiniChevronRightIcon ,
4+ } from '@codecademy/gamut-icons' ;
5+ import { useElementDir } from '@codecademy/gamut-styles' ;
26import * as React from 'react' ;
37
48import { IconButton } from '../../../Button' ;
@@ -17,6 +21,7 @@ export const CalendarNavLastMonth: React.FC<CalendarNavProps> = ({
1721 const resolvedLocale = useResolvedLocale ( locale ) ;
1822 const { lastMonth } = getRelativeMonthLabels ( resolvedLocale ) ;
1923 const buttonRef = React . useRef < HTMLButtonElement > ( null ) ;
24+ const isRtl = useElementDir ( buttonRef ) === 'rtl' ;
2025
2126 const handleClick = ( e : React . MouseEvent ) => {
2227 const lastMonth = new Date (
@@ -43,7 +48,7 @@ export const CalendarNavLastMonth: React.FC<CalendarNavProps> = ({
4348 alignSelf = "flex-start"
4449 aria-label = { lastMonth }
4550 data-calendar-month-nav
46- icon = { MiniChevronLeftIcon }
51+ icon = { isRtl ? MiniChevronRightIcon : MiniChevronLeftIcon }
4752 ref = { buttonRef }
4853 size = "small"
4954 tip = { lastMonth }
Original file line number Diff line number Diff line change 1- import { MiniChevronRightIcon } from '@codecademy/gamut-icons' ;
1+ import {
2+ MiniChevronLeftIcon ,
3+ MiniChevronRightIcon ,
4+ } from '@codecademy/gamut-icons' ;
5+ import { useElementDir } from '@codecademy/gamut-styles' ;
26import * as React from 'react' ;
37
48import { IconButton } from '../../../Button' ;
@@ -17,6 +21,7 @@ export const CalendarNavNextMonth: React.FC<CalendarNavProps> = ({
1721 const resolvedLocale = useResolvedLocale ( locale ) ;
1822 const { nextMonth } = getRelativeMonthLabels ( resolvedLocale ) ;
1923 const buttonRef = React . useRef < HTMLButtonElement > ( null ) ;
24+ const isRtl = useElementDir ( buttonRef ) === 'rtl' ;
2025
2126 const handleClick = ( e : React . MouseEvent ) => {
2227 const nextMonth = new Date (
@@ -43,7 +48,7 @@ export const CalendarNavNextMonth: React.FC<CalendarNavProps> = ({
4348 alignSelf = "flex-end"
4449 aria-label = { nextMonth }
4550 data-calendar-month-nav
46- icon = { MiniChevronRightIcon }
51+ icon = { isRtl ? MiniChevronLeftIcon : MiniChevronRightIcon }
4752 ref = { buttonRef }
4853 size = "small"
4954 tip = { nextMonth }
You can’t perform that action at this time.
0 commit comments