File tree Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ import type { ThemeProviderProps } from "next-themes/dist/types"
3
3
4
4
import { COLOR_MODE_STORAGE_KEY } from "@/lib/constants"
5
5
6
+ import { useLocaleDirection } from "@/hooks/useLocaleDirection"
7
+
6
8
/**
7
9
* Primary theming wrapper for use with color mode. Uses the theme provider
8
10
* from `next-themes`.
@@ -11,6 +13,8 @@ import { COLOR_MODE_STORAGE_KEY } from "@/lib/constants"
11
13
* primary decorator to Storybook.
12
14
*/
13
15
const ThemeProvider = ( { children } : Pick < ThemeProviderProps , "children" > ) => {
16
+ useLocaleDirection ( )
17
+
14
18
return (
15
19
< NextThemesProvider
16
20
attribute = "data-theme"
Original file line number Diff line number Diff line change 1
- import { useEffect , useState } from "react"
1
+ import { useEffect } from "react"
2
2
import { useRouter } from "next/router"
3
3
4
4
import { Lang } from "@/lib/types"
@@ -9,15 +9,11 @@ import { isLangRightToLeft } from "@/lib/utils/translations"
9
9
* Custom hook that sets the DOM direction based on the locale,
10
10
* responding to changes in the locale without requiring refresh.
11
11
*/
12
- export const useLocaleDirection = ( ) : string => {
13
- const [ direction , setDirection ] = useState < "ltr" | "rtl" > ( "ltr" )
12
+ export const useLocaleDirection = ( ) => {
14
13
const { locale } = useRouter ( )
15
14
16
15
useEffect ( ( ) => {
17
16
const dir = isLangRightToLeft ( locale as Lang ) ? "rtl" : "ltr"
18
17
document . documentElement . setAttribute ( "dir" , dir )
19
- setDirection ( dir )
20
18
} , [ locale ] )
21
-
22
- return direction
23
19
}
You can’t perform that action at this time.
0 commit comments