Skip to content

Commit

Permalink
fix: position popup (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulclindo authored Dec 1, 2023
1 parent bc2051d commit 8dcfa1d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ root.render(
<React.StrictMode>
<style>{themeStyle}</style>
<IntlProvider locale={locale} messages={langMessages}>
<div className="shadow-4xl fixed right-[2px] top-[120px] z-[1500000000] overflow-hidden">
<div className="shadow-4xl fixed right-[2px] top-[80px] z-[1500000000] overflow-hidden">
<ActionButton />
</div>
</IntlProvider>
Expand Down
37 changes: 23 additions & 14 deletions apps/shinkai-visor/src/components/popup/popup-embeder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const baseContainer = document.createElement('shinkai-popup-root');
baseContainer.style.position = 'fixed';
baseContainer.style.height = '640px';
baseContainer.style.width = '400px';
baseContainer.style.top = '120px';
baseContainer.style.top = '80px';
baseContainer.style.right = '56px';
baseContainer.style.zIndex = '1500000000';
baseContainer.style.pointerEvents = 'none';
Expand Down Expand Up @@ -57,16 +57,25 @@ htmlRoot.addEventListener('click', function (ev) {

let isVisible = false;

chrome.runtime.onMessage.addListener(async (message: ServiceWorkerInternalMessage, sender: chrome.runtime.MessageSender) => {
switch (message.type) {
case ServiceWorkerInternalMessageType.ContentScriptBridge:
if (message.data.type === ContentScriptBridgeMessageType.TogglePopupVisibility) {
isVisible = message.data.data !== undefined ? message.data.data : !isVisible;
baseContainer.style.pointerEvents = isVisible ? 'auto' : 'none';
}
break;
default:
break;
}
iframe.contentWindow?.postMessage({ message, sender }, srcUrlResolver('/'));
});
chrome.runtime.onMessage.addListener(
async (
message: ServiceWorkerInternalMessage,
sender: chrome.runtime.MessageSender,
) => {
switch (message.type) {
case ServiceWorkerInternalMessageType.ContentScriptBridge:
if (
message.data.type ===
ContentScriptBridgeMessageType.TogglePopupVisibility
) {
isVisible =
message.data.data !== undefined ? message.data.data : !isVisible;
baseContainer.style.pointerEvents = isVisible ? 'auto' : 'none';
}
break;
default:
break;
}
iframe.contentWindow?.postMessage({ message, sender }, srcUrlResolver('/'));
},
);

0 comments on commit 8dcfa1d

Please sign in to comment.