Skip to content

Commit

Permalink
fix: handle direction in Storybook for active direction effect on mod…
Browse files Browse the repository at this point in the history
…al and tooltip
  • Loading branch information
mrbadri committed Mar 10, 2024
1 parent 8f107db commit e120f30
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/storybook/.storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React , { useEffect }from "react";
import {themes} from "@storybook/theming";
import {NextUIProvider} from "@nextui-org/system/src/provider";
import type {Preview} from "@storybook/react";
Expand All @@ -10,6 +10,10 @@ const decorators: Preview["decorators"] = [
const direction =
// @ts-ignore
locale && new Intl.Locale(locale)?.textInfo?.direction === "rtl" ? "rtl" : undefined;

useEffect(() => {
document.documentElement.style.setProperty("--direction", direction || "ltr");
}, [direction]);

return (
<NextUIProvider locale={locale}>
Expand Down
8 changes: 8 additions & 0 deletions packages/storybook/.storybook/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
@tailwind components;
@tailwind utilities;

:root {
--direction: ltr;
}

body {
direction: var(--direction);
}

h1 {
@apply text-4xl font-bold !text-foreground;
}
Expand Down

0 comments on commit e120f30

Please sign in to comment.