Skip to content

Commit 3a5be1f

Browse files
committed
add directional button to toolbar
1 parent 7d9f753 commit 3a5be1f

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

packages/styleguide/.storybook/preview.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,19 @@ export const globalTypes = {
177177
showName: true,
178178
},
179179
},
180+
direction: {
181+
name: 'Direction',
182+
description: 'Text direction (LTR or RTL)',
183+
defaultValue: 'ltr',
184+
toolbar: {
185+
icon: 'arrowright',
186+
items: [
187+
{ value: 'ltr', title: 'Left-to-Right (LTR)', icon: 'arrowright' },
188+
{ value: 'rtl', title: 'Right-to-Left (RTL)', icon: 'arrowleft' },
189+
],
190+
showName: true,
191+
},
192+
},
180193
};
181194

182195
export const decorators = [withEmotion];

packages/styleguide/.storybook/theming/GamutThemeProvider.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@ type GlobalsContext = {
3535
colorMode: 'light' | 'dark';
3636
theme: keyof typeof themeMap;
3737
logicalProps: 'true' | 'false';
38+
direction: 'ltr' | 'rtl';
3839
};
3940
};
4041

4142
export const withEmotion = (Story: any, context: GlobalsContext) => {
4243
const colorMode = context.globals.colorMode ?? 'light';
4344
const selectedTheme = context.globals.theme;
4445
const useLogicalProperties = context.globals.logicalProps !== 'false';
46+
const direction = context.globals.direction ?? 'ltr';
4547
const background = corePalette[themeBackground[colorMode]];
4648
const storyRef = useRef<HTMLDivElement>(null);
4749
const currentTheme = themeMap[selectedTheme];
@@ -67,7 +69,7 @@ export const withEmotion = (Story: any, context: GlobalsContext) => {
6769
bg={themeBackground[colorMode]}
6870
ref={storyRef}
6971
>
70-
{Story()}
72+
<div dir={direction}>{Story()}</div>
7173
</Background>
7274
</GamutProvider>
7375
);
@@ -84,7 +86,7 @@ export const withEmotion = (Story: any, context: GlobalsContext) => {
8486
bg={themeBackground[colorMode]}
8587
ref={storyRef}
8688
>
87-
{Story()}
89+
<div dir={direction}>{Story()}</div>
8890
</Background>
8991
</GamutProvider>
9092
);

0 commit comments

Comments
 (0)