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

Suggest Chrome Extension Installation Popup #1318

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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: 2 additions & 0 deletions desktop-app/src/renderer/AppContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import DeviceManager from './components/DeviceManager';
import KeyboardShortcutsManager from './components/KeyboardShortcutsManager';
import { ReleaseNotes } from './components/ReleaseNotes';
import { Sponsorship } from './components/Sponsorship';
import { ChromePopup } from './components/ChromePopup';
import { AboutDialog } from './components/AboutDialog';

if ((navigator as any).userAgentData.platform === 'Windows') {
Expand Down Expand Up @@ -52,6 +53,7 @@ const AppContent = () => {
<ViewComponent />
<ReleaseNotes />
<Sponsorship />
<ChromePopup />
<AboutDialog />
</ThemeProvider>
</Provider>
Expand Down
77 changes: 77 additions & 0 deletions desktop-app/src/renderer/components/ChromePopup/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { useEffect, useMemo, useState } from 'react';

import { IPC_MAIN_CHANNELS } from 'common/constants';

import Modal from '../Modal';
import Icon from '../../assets/img/logo.png';
import Button from '../Button';

export const ChromePopup = () => {
const [isOpen, setIsOpen] = useState(false);

useEffect(() => {
const usesChromeMs = window.electron.store.get('chromePopup.usesChrome');
if (usesChromeMs === undefined || usesChromeMs === true) {
setIsOpen(true);
}
}, []);

const onClose = () => {
setIsOpen(false);
};

return (
<Modal
title={
<div className="flex flex-col items-center gap-2 border-b border-slate-500 pb-2">
<div className="flex w-full justify-center">
<img src={Icon} alt="Logo" width={64} />
</div>
<div>Do you have our Chrome Extension?</div>
</div>
}
isOpen={isOpen}
onClose={onClose}
>
<div className="max-w-lg">
<p className="pb-4 text-center">
Responsively Helper on the Chrome Web Store
<br />
<br />
Open your current Chrome browser page in the Responsively App
seamlessly!
</p>
<div className="mt-4 flex justify-center">
<div className="flex gap-1">
<Button
onClick={() => {
window.electron.ipcRenderer.sendMessage(
IPC_MAIN_CHANNELS.OPEN_EXTERNAL,
{
url: `https://chromewebstore.google.com/detail/responsively-helper/jhphiidjkooiaollfiknkokgodbaddcj`,
}
);
window.electron.store.set('chromePopup.usesChrome', true);
Copy link
Contributor

Choose a reason for hiding this comment

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

usesChrome is a bit vague, I would name this something like hasSeenChromeExtensionPopUp

onClose();
}}
Comment on lines +47 to +56
Copy link
Contributor

Choose a reason for hiding this comment

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

it is best practice to declare a new function outside of the onclick and then call it as in:
onClick={handleDownload}

If you declare a function inline in onClick={}, it will be recreated on every render. This can have performance implications

isTextButton
isPrimary
>
Download Extension
</Button>
<Button
onClick={() => {
window.electron.store.set('chromePopup.usesChrome', false);
onClose();
}}
isTextButton
isPrimary
>
I do not use Chrome
Copy link
Contributor

Choose a reason for hiding this comment

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

I would change the text to "No, thank you", in order to cover more cases, like the person doesn't want it or they want to close the popup

</Button>
</div>
</div>
</div>
</Modal>
);
};
6 changes: 6 additions & 0 deletions desktop-app/src/renderer/components/InfoPopups/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { useEffect, useState } from 'react';
import { isReleaseNotesUnseen, ReleaseNotes } from '../ReleaseNotes';
import { Sponsorship } from '../Sponsorship';
import { ChromePopup } from '../ChromePopup';

export const InfoPopups = () => {
const [showReleaseNotes, setShowReleaseNotes] = useState<boolean>(false);
const [showSponsorship, setShowSponsorship] = useState<boolean>(false);
const [showChromePopup, setShowChromePopup] = useState<boolean>(false);

useEffect(() => {
(async () => {
Expand All @@ -13,6 +15,7 @@ export const InfoPopups = () => {
return;
}
setShowSponsorship(true);
setShowChromePopup(true);
})();
}, []);

Expand All @@ -23,6 +26,9 @@ export const InfoPopups = () => {
if (showSponsorship) {
return <Sponsorship />;
}
if (showChromePopup) {
return <ChromePopup />;
}

return null;
};
Loading