bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/app/service.js
2024-07-02 14:58:58 -03:00

50 lines
1.0 KiB
JavaScript

import DarkReader from 'darkreader';
import Styled from './styles';
import logger from '/imports/startup/client/logger';
import useMeeting from '../../core/hooks/useMeeting';
export function useMeetingIsBreakout() {
const { data: meeting } = useMeeting((m) => ({
isBreakout: m.isBreakout,
}));
return meeting && meeting.isBreakout;
}
export const setDarkTheme = (value) => {
if (value && !DarkReader.isEnabled()) {
DarkReader.enable(
{ brightness: 100, contrast: 90 },
{
invert: [Styled.DtfInvert],
ignoreInlineStyle: [Styled.DtfCss],
ignoreImageAnalysis: [Styled.DtfImages],
},
);
logger.info(
{
logCode: 'dark_mode',
},
'Dark mode is on.',
);
}
if (!value && DarkReader.isEnabled()) {
DarkReader.disable();
logger.info(
{
logCode: 'dark_mode',
},
'Dark mode is off.',
);
}
};
export const isDarkThemeEnabled = () => DarkReader.isEnabled();
export default {
setDarkTheme,
isDarkThemeEnabled,
useMeetingIsBreakout,
};