-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(react-storybook-addon): make withFluentProvider decorator configurable to be used for VR tests #25162
Merged
TristanWatanabe
merged 27 commits into
microsoft:master
from
TristanWatanabe:add-VrTestVariants-decorator
Oct 25, 2022
Merged
feat(react-storybook-addon): make withFluentProvider decorator configurable to be used for VR tests #25162
Changes from 20 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
0157f8f
implement withFluentVRTestVariants decorator
TristanWatanabe d00208f
update test to include new decorator
TristanWatanabe c797198
update typings
TristanWatanabe bda9ea4
fix: typing and update API
TristanWatanabe dcfcde3
Add usage of decorator to README
TristanWatanabe 794bd7f
remove unneed peerDep
TristanWatanabe f306846
fix: typing
TristanWatanabe fb87708
Update API
TristanWatanabe 7bf1873
revert additions to react-storybook package
TristanWatanabe ed168ee
delete withFluentVrTestVariants
TristanWatanabe d3765ac
remove withFluentVrTestVariant
TristanWatanabe 1f26987
feat: withFluentProvider now accepts fluentTheme and dir
TristanWatanabe 66c95ef
Add exported theme constants
TristanWatanabe ab22cd5
feat: add isVrTest parameter
TristanWatanabe 060d696
Revert "Add usage of decorator to README"
TristanWatanabe 18c3e6d
update ReadMe
TristanWatanabe 14847d9
Add constants and FluentParameters to exports
TristanWatanabe 20091d7
Update API
TristanWatanabe e840ba7
Revert "Update API"
TristanWatanabe 21eba2e
Revert "fix: typing and update API"
TristanWatanabe 81de523
feedback: don't export constants, export FluentParameter type
TristanWatanabe b5f3788
feedback: replace isVrTest param with more dynamic mode param
TristanWatanabe 4842eb9
feedback: add parameters identity function and export
TristanWatanabe 8317329
Update API
TristanWatanabe 55836b6
Update README
TristanWatanabe 1559515
Merge branch 'master' into add-VrTestVariants-decorator
TristanWatanabe d888f92
remove unintended prettier changes
TristanWatanabe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
14 changes: 12 additions & 2 deletions
14
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,30 @@ | ||
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; | ||
isVrTest?: boolean; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: boolean flags doesn't scale well. what about -isVrTest?: boolean;
+context?: 'vr-test' | 'default' There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. replaced with |
||
} | ||
|
||
export function useGlobals(): [FluentGlobals, (newGlobals: FluentGlobals) => void] { | ||
return useStorybookGlobals(); | ||
} |
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,4 @@ | ||
export type { FluentGlobals, FluentStoryContext } from './hooks'; | ||
export type { FluentGlobals, FluentParameters, FluentStoryContext } from './hooks'; | ||
export type { ThemeIds } from './theme'; | ||
export { themes } from './theme'; | ||
export { themes, TEAMS_DARK, TEAMS_HIGH_CONTRAST, TEAMS_LIGHT, WEB_DARK, WEB_LIGHT } from './theme'; | ||
export { THEME_ID } from './constants'; |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: hmm best API is no API or very limited API surface 🙌.
we don't need these tokens for sake of setting fluent theme.
We can instead leverage one or both of the following approaches:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two options combined to provide TS typing via intellisense are definitely much better solutions than constant tokens! I've made the change to add a
parameters
function and have removed the constants in favor of exporting aFluentParameters
type.