Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ulixee
GitHub Repository: ulixee/secret-agent
Path: blob/main/replay/frontend/src/models/OverlayStore.ts
1029 views
1
import { ipcRenderer, remote } from 'electron';
2
import { getTheme } from '~shared/utils/themes';
3
import settings from '~frontend/lib/settings';
4
5
export class OverlayStore {
6
public get theme() {
7
return getTheme(settings.theme);
8
}
9
10
public get cssVars() {
11
const dialogLightForeground = this.theme.dialogLightForeground;
12
return {
13
'--dropdownBackgroundColor': this.theme.dropdownBackgroundColor,
14
'--menuItemHoverBackgroundColor': dialogLightForeground
15
? 'rgba(255, 255, 255, 0.06)'
16
: 'rgba(0, 0, 0, 0.03)',
17
};
18
}
19
20
public constructor(hideOnBlur = true) {
21
if (hideOnBlur) {
22
window.addEventListener('blur', () => {
23
this.hide();
24
});
25
}
26
}
27
28
public get webContentsId() {
29
return remote.getCurrentWebContents().id;
30
}
31
32
public hide() {
33
ipcRenderer.send('overlay:hide', this.webContentsId);
34
}
35
}
36
37