Skip to content
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

[DO NOT MERGE] feat/WEB-3065 limit theme to container #3356

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/prebuilt-react-integration/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/hls-player/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/hls-stats/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/hms-video-store/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions packages/hms-virtual-background/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/hms-whiteboard/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/react-icons/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/react-sdk/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions packages/roomkit-react/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/roomkit-react/src/Prebuilt/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ export const HMSPrebuilt = React.forwardRef<HMSPrebuiltRefType, HMSPrebuiltProps
sans: fontFamily,
},
}}
container={containerSelector}
>
<PIPProvider>
<Init />
Expand Down
12 changes: 9 additions & 3 deletions packages/roomkit-react/src/Theme/ThemeProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export type ThemeProviderProps = {
themeType?: string;
theme?: Theme;
aspectRatio?: { width: number; height: number };
container?: string;
};

const defaultContext = {
Expand All @@ -53,6 +54,7 @@ export const HMSThemeProvider: React.FC<React.PropsWithChildren<ThemeProviderPro
themeType,
theme: userTheme,
aspectRatio = defaultAspectRatio,
container = '',
children,
}) => {
const systemTheme = ThemeTypes.default;
Expand All @@ -64,13 +66,17 @@ export const HMSThemeProvider: React.FC<React.PropsWithChildren<ThemeProviderPro
if (!isBrowser) {
return updatedTheme;
}
let element = document.querySelector(container);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This throws an error if container is an empty string. Let's add a check

if (!element) {
element = document.documentElement;
}
if (previousClassName.current) {
document.documentElement.classList.remove(previousClassName.current);
element.classList.remove(previousClassName.current);
}
previousClassName.current = updatedTheme.className;
document.documentElement.classList.add(updatedTheme);
element.classList.add(updatedTheme);
return updatedTheme;
}, [userTheme, currentTheme, isBrowser]);
}, [userTheme, container, currentTheme, isBrowser]);

const toggleTheme = useCallback((themeToUpdateTo?: ThemeTypes) => {
if (themeToUpdateTo) {
Expand Down
4 changes: 2 additions & 2 deletions packages/roomkit-web/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.