Skip to content

Commit

Permalink
fix(tablekit-input): add rtl support
Browse files Browse the repository at this point in the history
Part of #93
  • Loading branch information
Dmitry Finogeev authored and wahidfarid committed May 10, 2022
1 parent 296c8aa commit 12d910c
Show file tree
Hide file tree
Showing 7 changed files with 703 additions and 263 deletions.
2 changes: 1 addition & 1 deletion .storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const mainConfig = require('@tablecheck/scripts/config/storybook.main');

module.exports = {
...mainConfig,
addons: [...mainConfig.addons, 'storybook-dark-mode'],
addons: [...mainConfig.addons, 'storybook-dark-mode', 'storybook-rtl-addon'],
stories: [
'../pages/**/*.stories.mdx',
'../packages/**/src/*.stories.mdx',
Expand Down
13 changes: 10 additions & 3 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { themes } from '@storybook/theming';
import { LocaleCode } from '@tablecheck/locales';
import * as React from 'react';
import { useDarkMode } from 'storybook-dark-mode';
import { useDirection } from 'storybook-rtl-addon';

import { ThemeProvider, CLASSIC_COLORS, DARK_COLORS } from '../packages/theme';

Expand Down Expand Up @@ -64,8 +66,9 @@ export const parameters = {
};

export const decorators = [
(story: () => JSX.Element): JSX.Element => {
(story: () => JSX.Element, context): JSX.Element => {
const isDark = useDarkMode();
const direction = useDirection(context);
const theme = {
isDark,
colors: isDark
Expand All @@ -76,8 +79,12 @@ export const decorators = [
}
};
return (
<ThemeProvider theme={theme} isDark={isDark}>
{story()}
<ThemeProvider
theme={theme}
isDark={isDark}
locale={direction === 'rtl' ? LocaleCode.Arabic : LocaleCode.English}
>
<div dir={direction}>{story()}</div>
</ThemeProvider>
);
}
Expand Down
Loading

0 comments on commit 12d910c

Please sign in to comment.