Skip to content

Commit b7e4be2

Browse files
authored
Merge pull request #13632 from ethereum/tw-use-rtl-flip
feat: adds twFlipForRtl cn export to useRtlFlip
2 parents 8443e92 + e9014b3 commit b7e4be2

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/hooks/useRtlFlip.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,24 @@ import type { Lang } from "@/lib/types"
55
import { isLangRightToLeft } from "@/lib/utils/translations"
66

77
type UseDirection = {
8-
flipForRtl: "scaleX(-1)" | undefined
8+
/** @deprecated */
9+
flipForRtl: "scaleX(-1)" | undefined // transform (deprecated)
10+
twFlipForRtl: "-scale-x-1" | "" // className
911
isRtl: boolean
1012
direction: "ltr" | "rtl"
1113
}
1214

1315
/**
1416
* Custom hook that determines the direction and transformation for right-to-left (RTL) languages.
1517
* @example const { flipForRtl } = useRtlFlip(); transform={flipForRtl}
16-
* @returns An object containing the CSS transformation, RTL flag, and direction.
18+
* @returns An object containing the Tailwind className, RTL flag, and direction.
1719
*/
1820
export const useRtlFlip = (): UseDirection => {
1921
const { locale } = useRouter()
2022
const isRtl = isLangRightToLeft(locale as Lang)
2123
return {
22-
flipForRtl: isRtl ? "scaleX(-1)" : undefined,
24+
flipForRtl: isRtl ? "scaleX(-1)" : undefined, // transform (deprecated)
25+
twFlipForRtl: isRtl ? "-scale-x-1" : "", // className (preferred)
2326
isRtl,
2427
direction: isRtl ? "rtl" : "ltr",
2528
}

0 commit comments

Comments
 (0)