Skip to content

Commit 54784d8

Browse files
authored
[Storyboook] Fix theme snippet by making alternative rtl snippet fix (#3932)
* Fix theme snippet by making alternative rtl snippet fix * Update BaseComposite.tsx Signed-off-by: Patrick Latter <73612854+palatter@users.noreply.github.com> * Update BaseComposite.tsx Signed-off-by: Patrick Latter <73612854+palatter@users.noreply.github.com> * Update BaseComposite.tsx Signed-off-by: Patrick Latter <73612854+palatter@users.noreply.github.com> * Fix rtl for call and callwithchat snippets * Change files * Duplicate change files for beta release --------- Signed-off-by: Patrick Latter <73612854+palatter@users.noreply.github.com>
1 parent 328c6e2 commit 54784d8

30 files changed

Lines changed: 80 additions & 30 deletions
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "patch",
3+
"area": "fix",
4+
"workstream": "",
5+
"comment": "Fix theme snippet by making alternative rtl snippet fix",
6+
"packageName": "@azure/communication-react",
7+
"email": "73612854+palatter@users.noreply.github.com",
8+
"dependentChangeType": "patch"
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "patch",
3+
"area": "fix",
4+
"workstream": "",
5+
"comment": "Fix theme snippet by making alternative rtl snippet fix",
6+
"packageName": "@azure/communication-react",
7+
"email": "73612854+palatter@users.noreply.github.com",
8+
"dependentChangeType": "patch"
9+
}

packages/react-components/src/theming/FluentThemeProvider.tsx

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ const defaultTheme: Theme = {
4848

4949
/** Theme context for library's react components */
5050
const ThemeContext = createContext<Theme>(defaultTheme);
51-
const SingleUsageCheckContext = createContext<boolean>(false);
5251

5352
/**
5453
* Provider to apply a Fluent theme across this library's react components.
@@ -61,28 +60,15 @@ const SingleUsageCheckContext = createContext<boolean>(false);
6160
export const FluentThemeProvider = (props: FluentThemeProviderProps): JSX.Element => {
6261
const { fluentTheme, rtl, children } = props;
6362

64-
/**
65-
* Pass only the children if we previously wrapped.
66-
* This is to prevent the provider from being applied
67-
* multiple times and wiping out configuration like RTL
68-
* FluentThemeProvider
69-
*/
70-
const alreadyWrapped = useSingleUsageCheck();
71-
if (alreadyWrapped) {
72-
return <>{children}</>;
73-
}
74-
7563
let fluentV8Theme: Theme = mergeThemes(defaultTheme, fluentTheme);
7664
fluentV8Theme = mergeThemes(fluentV8Theme, { rtl });
7765

7866
return (
79-
<SingleUsageCheckContext.Provider value={true}>
80-
<ThemeContext.Provider value={fluentV8Theme}>
81-
<ThemeProvider theme={fluentV8Theme} className={wrapper}>
82-
{children}
83-
</ThemeProvider>
84-
</ThemeContext.Provider>
85-
</SingleUsageCheckContext.Provider>
67+
<ThemeContext.Provider value={fluentV8Theme}>
68+
<ThemeProvider theme={fluentV8Theme} className={wrapper}>
69+
{children}
70+
</ThemeProvider>
71+
</ThemeContext.Provider>
8672
);
8773
};
8874

@@ -92,10 +78,3 @@ export const FluentThemeProvider = (props: FluentThemeProviderProps): JSX.Elemen
9278
* @public
9379
*/
9480
export const useTheme = (): Theme => useContext(ThemeContext);
95-
96-
/**
97-
* This is used to prevent the provider from being applied multiple times.
98-
*
99-
* @private
100-
*/
101-
const useSingleUsageCheck = (): boolean => useContext(SingleUsageCheckContext);

packages/storybook/stories/CallComposite/BasicExample.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const BasicStory = (args: ArgsFrom<typeof storyControls>, context): JSX.Element
4444
{containerProps ? (
4545
<ContosoCallContainer
4646
fluentTheme={context.theme}
47+
rtl={context.globals.rtl === 'rtl'}
4748
displayName={args.displayName}
4849
{...containerProps}
4950
callInvitationURL={args.callInvitationURL}

packages/storybook/stories/CallComposite/CustomDataModelExample.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const CustomDataModelStory = (args: ArgsFrom<typeof storyControls>, context): JS
4444
{containerProps ? (
4545
<CustomDataModelExampleContainer
4646
fluentTheme={context.theme}
47+
rtl={context.globals.rtl === 'rtl'}
4748
displayName={args.displayName}
4849
avatarInitials={args.avatarInitials}
4950
{...containerProps}

packages/storybook/stories/CallComposite/JoinExistingCall.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const JoinExistingCallStory = (args: ArgsFrom<typeof storyControls>, context): J
3232
{areAllKnobsSet ? (
3333
<ContosoCallContainer
3434
fluentTheme={context.theme}
35+
rtl={context.globals.rtl === 'rtl'}
3536
locator={args.callLocator}
3637
userId={{ communicationUserId: args.userId }}
3738
token={args.token}

packages/storybook/stories/CallComposite/JoinExistingCallWithCTE.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const JoinExistingCallAsTeamsUserStory = (args: ArgsFrom<typeof storyControls>,
3131
{areAllKnobsSet ? (
3232
<ContosoCTECallContainer
3333
fluentTheme={context.theme}
34+
rtl={context.globals.rtl === 'rtl'}
3435
locator={args.callLocator}
3536
userId={{ microsoftTeamsUserId: args.userId }}
3637
token={args.token}

packages/storybook/stories/CallComposite/Start1toNCall.stories.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const Start1toNCallStory = (args: ArgsFrom<typeof storyControls>, context): JSX.
3434
<div style={args.calleeToken ? { width: '65%' } : { width: '100%' }}>
3535
<ContosoCallContainer1toN
3636
fluentTheme={context.theme}
37+
rtl={context.globals.rtl === 'rtl'}
3738
locator={[args.calleeUserId]}
3839
userId={{ communicationUserId: args.userId }}
3940
token={args.token}
@@ -46,6 +47,7 @@ const Start1toNCallStory = (args: ArgsFrom<typeof storyControls>, context): JSX.
4647
<div style={{ width: '35%' }}>
4748
<ContosoCallContainer1toNInbound
4849
fluentTheme={context.theme}
50+
rtl={context.globals.rtl === 'rtl'}
4951
userId={{ communicationUserId: args.calleeUserId }}
5052
token={args.calleeToken}
5153
locale={compositeLocale(locale)}

packages/storybook/stories/CallComposite/StartPSTNCall.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const StartPSTNCallStory = (args: ArgsFrom<typeof storyControls>, context): JSX.
3535
<ContosoCallContainerPSTN
3636
alternateCallerId={args.alternateCallerId}
3737
fluentTheme={context.theme}
38+
rtl={context.globals.rtl === 'rtl'}
3839
locator={args.callLocator}
3940
userId={{ communicationUserId: args.userId }}
4041
token={args.token}

packages/storybook/stories/CallComposite/ThemeExample.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ const ThemeExampleStory = (args: ArgsFrom<typeof storyControls>, context): JSX.E
5454
<ContosoCallContainer
5555
displayName={args.displayName}
5656
fluentTheme={theme}
57+
rtl={context.globals.rtl === 'rtl'}
5758
{...containerProps}
5859
callInvitationURL={args.callInvitationURL}
5960
locale={compositeLocale(locale)}

0 commit comments

Comments
 (0)