-
Notifications
You must be signed in to change notification settings - Fork 31
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
trial using context for renderingTarget #8704
Merged
Merged
Changes from 2 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
8342952
trial using context for renderingTarget
cemms1 a2a5b54
refactor: one context to rule them all
cemms1 cac99e7
Merge branch 'main' into cemms1/use-context-for-rendering-target
cemms1 91cfa08
ensure rendering target is reflected in layout stories context
cemms1 1f24871
Merge branch 'main' into cemms1/use-context-for-rendering-target
cemms1 fbe778c
docs: add new react context proposal adr and rename adr sub dirs
cemms1 8414c5f
docs: add storybook docs to help explain context and/or decorators
cemms1 d92d8da
add context hook to improve ease of use of context object
cemms1 c3bfe7a
Merge branch 'main' into cemms1/use-context-for-rendering-target
cemms1 174def7
ensure useContext hook cannot be used outside of relevant provider
cemms1 9d41ac0
move provider down tree and prevent direct context use
cemms1 6ac0184
remove console.log
cemms1 095689e
rename context to config, simplify implementation, add islands support
cemms1 4bf6dec
test: add test for config context and mock for other tests
cemms1 9d34771
ignore linting issue for context with comment
cemms1 9162e02
copy lint config from AR to detect react version
cemms1 7006f21
Merge branch 'main' into cemms1/use-context-for-rendering-target
cemms1 7ae529d
docs: update react context ADR to remove ban on use within islands, s…
cemms1 55a5b21
improve docs, and readability by renaming config type
cemms1 40af5aa
move provider higher up the tree and include other pages
cemms1 06b26df
test: fix tests
cemms1 52f5edf
Merge branch 'main' into cemms1/use-context-for-rendering-target
cemms1 2a0d92a
docs: update jsdoc descriptions for page components
cemms1 5cd1902
docs: clarify context docs and update status, moving existing doc to …
cemms1 0b278e5
docs: spelling
cemms1 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
19 changes: 19 additions & 0 deletions
19
dotcom-rendering/.storybook/decorators/renderingContextDecorator.js
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { RenderingContext } from '../../src/components/RenderingContext'; | ||
|
||
const defaultContext = { target: 'Web' }; | ||
|
||
export const RenderingContextDecorator = ( | ||
Story, | ||
{ args: { renderingContext } }, | ||
) => { | ||
const context = { ...defaultContext, ...renderingContext }; | ||
|
||
// For easy debugging | ||
console.log('Storybook rendering context: \n', context); | ||
|
||
return ( | ||
<RenderingContext.Provider value={context}> | ||
<Story /> | ||
</RenderingContext.Provider> | ||
); | ||
}; | ||
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
Oops, something went wrong.
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.
This Storybook decorator wraps all stories in a
<RenderingContext.Provider>
component, with the default value of the context provided which can be overridden at component level