-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(react-storybook-addon): make withFluentProvider decorator config…
…urable to be used for VR tests (#25162)
- Loading branch information
1 parent
025e074
commit ca05778
Showing
6 changed files
with
94 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 16 additions & 2 deletions
18
packages/react-components/react-storybook-addon/src/hooks.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,34 @@ | ||
import { useGlobals as useStorybookGlobals, Args as StorybookArgs } from '@storybook/api'; | ||
import { useGlobals as useStorybookGlobals, Args as StorybookArgs, Parameters } from '@storybook/api'; | ||
import { StoryContext as StorybookContext } from '@storybook/addons'; | ||
|
||
import { THEME_ID } from './constants'; | ||
import { ThemeIds } from './theme'; | ||
|
||
export interface FluentStoryContext extends StorybookContext { | ||
globals: FluentGlobals; | ||
parameters: FluentParameters; | ||
} | ||
|
||
/** | ||
* Extends the storybook globals object to include fluent specific propoerties | ||
* Extends the storybook globals object to include fluent specific properties | ||
*/ | ||
export interface FluentGlobals extends StorybookArgs { | ||
[THEME_ID]?: ThemeIds; | ||
} | ||
|
||
/** | ||
* Extends the storybook parameters object to include fluent specific properties | ||
*/ | ||
export interface FluentParameters extends Parameters { | ||
dir?: 'ltr' | 'rtl'; | ||
fluentTheme?: ThemeIds; | ||
mode?: 'default' | 'vr-test'; | ||
} | ||
|
||
export function useGlobals(): [FluentGlobals, (newGlobals: FluentGlobals) => void] { | ||
return useStorybookGlobals(); | ||
} | ||
|
||
export function parameters(options?: FluentParameters) { | ||
return { dir: 'ltr', fluentTheme: 'web-light', mode: 'default', ...options }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export type { FluentGlobals, FluentStoryContext } from './hooks'; | ||
export type { FluentGlobals, FluentParameters, FluentStoryContext } from './hooks'; | ||
export type { ThemeIds } from './theme'; | ||
export { themes } from './theme'; | ||
export { THEME_ID } from './constants'; | ||
export { parameters } from './hooks'; |