Skip to content

Commit 1545524

Browse files
committed
feat: adds twFlipForRtl cn export to useRtlFlip
1 parent 2fb4687 commit 1545524

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/hooks/useRtlFlip.ts

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

77
type UseDirection = {
8-
flipForRtl: "scaleX(-1)" | undefined
8+
flipForRtl: "scaleX(-1)" | undefined // transform (deprecated)
9+
twFlipForRtl: "-scale-x-1" | undefined // className
910
isRtl: boolean
1011
direction: "ltr" | "rtl"
1112
}
1213

1314
/**
1415
* Custom hook that determines the direction and transformation for right-to-left (RTL) languages.
1516
* @example const { flipForRtl } = useRtlFlip(); transform={flipForRtl}
16-
* @returns An object containing the CSS transformation, RTL flag, and direction.
17+
* @returns An object containing the Tailwind className, RTL flag, and direction.
1718
*/
1819
export const useRtlFlip = (): UseDirection => {
1920
const { locale } = useRouter()
2021
const isRtl = isLangRightToLeft(locale as Lang)
2122
return {
22-
flipForRtl: isRtl ? "scaleX(-1)" : undefined,
23+
flipForRtl: isRtl ? "scaleX(-1)" : undefined, // transform (deprecated)
24+
twFlipForRtl: isRtl ? "-scale-x-1" : undefined, // className (preferred)
2325
isRtl,
2426
direction: isRtl ? "rtl" : "ltr",
2527
}

0 commit comments

Comments
 (0)