-
Notifications
You must be signed in to change notification settings - Fork 2.9k
feat(react-provider): add applyStylesTo prop for theme token styling control #33632
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
Closed
dmytrokirpa
wants to merge
8
commits into
microsoft:master
from
dmytrokirpa:feat/add-apply-styles-to-body
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8db6df5
feat(react-provider): add applyStylesTo prop for theme token styling …
dmytrokirpa 0f0b5fa
update api.md
dmytrokirpa 4da12cf
fix lint
dmytrokirpa 5c1b0e6
Merge branch 'master' into feat/add-apply-styles-to-body
dmytrokirpa fde68b4
fix typo
dmytrokirpa 7e639e1
udpate test
dmytrokirpa c024dc3
fix typo
dmytrokirpa 9291c31
Merge branch 'master' into feat/add-apply-styles-to-body
dmytrokirpa 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
7 changes: 7 additions & 0 deletions
7
change/@fluentui-react-provider-5a31a189-02e4-434d-969d-974f758f5b17.json
This file contains hidden or 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,7 @@ | ||
| { | ||
| "type": "patch", | ||
| "comment": "feat: allow to apply FluentProvider's tokens to body element", | ||
| "packageName": "@fluentui/react-provider", | ||
| "email": "dmytrokirpa@microsoft.com", | ||
| "dependentChangeType": "patch" | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
35 changes: 35 additions & 0 deletions
35
...omponents/react-provider/stories/src/Provider/FluentProviderApplyStylesToBody.stories.tsx
This file contains hidden or 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,35 @@ | ||
| import * as React from 'react'; | ||
| import { tokens, FluentProvider, webDarkTheme, makeStyles, makeStaticStyles } from '@fluentui/react-components'; | ||
|
|
||
| const useGlobalStyles = makeStaticStyles({ | ||
| body: { | ||
| backgroundColor: tokens.colorNeutralBackground2, | ||
| color: tokens.colorNeutralForeground1, | ||
| fontSize: tokens.fontSizeBase500, | ||
| }, | ||
| h1: { | ||
| fontSize: tokens.fontSizeBase500, | ||
| }, | ||
| }); | ||
|
|
||
| const useLocalStyles = makeStyles({ | ||
| provider: { | ||
| backgroundColor: 'none', | ||
| }, | ||
| }); | ||
|
|
||
| /** | ||
| * The `applyStylesTo` controls whether theme tokens should be applied to FluentProvider or document body, | ||
| * which can be useful for global styles. | ||
| */ | ||
| export const ApplyStylesToBody = () => { | ||
| const styles = useLocalStyles(); | ||
|
|
||
| useGlobalStyles(); | ||
|
|
||
| return ( | ||
| <FluentProvider applyStylesTo="body" className={styles.provider} theme={webDarkTheme}> | ||
| <h1>Document body and this element styled with global styles and theme tokens</h1> | ||
| </FluentProvider> | ||
| ); | ||
| }; |
This file contains hidden or 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,11 +1,12 @@ | ||
| import { Meta } from '@storybook/react'; | ||
| import type { Meta } from '@storybook/react'; | ||
|
|
||
| import { FluentProvider } from '@fluentui/react-components'; | ||
| import descriptionMd from './FluentProviderDescription.md'; | ||
| import bestPracticesMd from './FluentProviderBestPractices.md'; | ||
|
|
||
| export { Default } from './FluentProviderDefault.stories'; | ||
| export { Dir } from './FluentProviderDir.stories'; | ||
| export { ApplyStylesToBody } from './FluentProviderApplyStylesToBody.stories'; | ||
| export { ApplyStylesToPortals } from './FluentProviderApplyStylesToPortals.stories'; | ||
| export { Nested } from './FluentProviderNested.stories'; | ||
| export { Frame } from './FluentProviderFrame.stories'; | ||
|
|
@@ -19,5 +20,8 @@ export default { | |
| component: [descriptionMd, bestPracticesMd].join('\n'), | ||
| }, | ||
| }, | ||
| reactStorybookAddon: { | ||
| disabledDecorators: ['FluentProvider'], | ||
|
Contributor
Author
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. Disabled the |
||
| }, | ||
| }, | ||
| } as Meta; | ||
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.
Uh oh!
There was an error while loading. Please reload this page.