Skip to content
This repository was archived by the owner on May 4, 2023. It is now read-only.

Commit ca3a134

Browse files
feat: added about modal
1 parent 59a86c9 commit ca3a134

File tree

5 files changed

+109
-0
lines changed

5 files changed

+109
-0
lines changed

src/main/main.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ ipcMain.on('ipc-example', async (event, arg) => {
3131
event.reply('ipc-example', msgTemplate('pong'));
3232
});
3333

34+
ipcMain.on('app-version', async (event) => {
35+
event.reply('app-version', app.getVersion());
36+
});
37+
3438
if (process.env.NODE_ENV === 'production') {
3539
const sourceMapSupport = require('source-map-support');
3640
sourceMapSupport.install();

src/main/preload.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { contextBridge, ipcRenderer, IpcRendererEvent } from 'electron';
22

33
export type Channels =
44
| 'ipc-example'
5+
| 'app-version'
56
| 'minimizeApp'
67
| 'maximizeApp'
78
| 'closeApp';
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
import { useEffect, useState } from 'react';
2+
import {
3+
Modal,
4+
ModalOverlay,
5+
ModalContent,
6+
ModalHeader,
7+
ModalCloseButton,
8+
ModalBody,
9+
Text,
10+
Link,
11+
IconButton,
12+
useDisclosure,
13+
Image,
14+
} from '@chakra-ui/react';
15+
import { QuestionMarkCircleIcon } from '@codiga/components';
16+
import CodigaLogo from '../Layout/CodigaIcon.png';
17+
18+
export default function AboutApp() {
19+
const { isOpen, onOpen, onClose } = useDisclosure();
20+
const [appVersion, setAppVersion] = useState('0.0.0');
21+
22+
useEffect(() => {
23+
window.electron.ipcRenderer.once('app-version', (arg) => {
24+
setAppVersion(arg as string);
25+
});
26+
window.electron.ipcRenderer.sendMessage('app-version', ['']);
27+
}, []);
28+
29+
return (
30+
<>
31+
<IconButton
32+
aria-label="about-app"
33+
onClick={onOpen}
34+
variant="ghost"
35+
h="28px"
36+
minW="28px"
37+
fontSize="12px"
38+
icon={<QuestionMarkCircleIcon />}
39+
_focus={{
40+
boxShadow: 'none',
41+
}}
42+
/>
43+
44+
<Modal isOpen={isOpen} onClose={onClose} isCentered>
45+
<ModalOverlay
46+
bg="neutral.0"
47+
_dark={{ bg: 'base.dark' }}
48+
opacity="0.8 !important"
49+
/>
50+
51+
<ModalContent>
52+
<ModalHeader justifyContent="flex-end">
53+
<ModalCloseButton />
54+
</ModalHeader>
55+
56+
<ModalBody
57+
d="flex"
58+
flexDir="column"
59+
alignItems="center"
60+
gridGap="space_16"
61+
>
62+
<Link
63+
isExternal
64+
_focus={{ boxShadow: 'none' }}
65+
href="https://www.codiga.io/"
66+
>
67+
<Image src={CodigaLogo} h="48px" mx="auto" />
68+
</Link>
69+
70+
<Text size="sm">
71+
<Link
72+
isExternal
73+
variant="subtle"
74+
color="inherit"
75+
_focus={{ boxShadow: 'none' }}
76+
href="https://github.com/codiga/code-snippets-manager"
77+
>
78+
Codiga Code Snippets Manager
79+
</Link>
80+
</Text>
81+
82+
<Text size="sm">
83+
<Link
84+
isExternal
85+
variant="subtle"
86+
color="inherit"
87+
_focus={{ boxShadow: 'none' }}
88+
href="https://github.com/codiga/code-snippets-manager/releases/latest"
89+
>
90+
Version {appVersion}
91+
</Link>
92+
</Text>
93+
94+
<Text size="sm">Copyright © 2022 Codiga</Text>
95+
</ModalBody>
96+
</ModalContent>
97+
</Modal>
98+
</>
99+
);
100+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from './AboutApp';

src/renderer/components/Layout/Titlebar.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { getAvatarUrl } from '../../utils/userUtils';
1010

1111
import TitlebarButtonsMac from './TitlebarButtonsMac';
1212
import TitlebarButtonsWin from './TitlebarButtonsWin';
13+
import AboutApp from '../AboutApp';
1314

1415
type TitlebarProps = {
1516
openLoginModal: () => void;
@@ -38,6 +39,8 @@ export default function Titlebar({ openLoginModal, isOnline }: TitlebarProps) {
3839
{/* we show windows buttons, connecting text or CTA/Avatar here */}
3940
<Flex sx={{ '-webkit-app-region': 'no-drag' }}>
4041
<Flex alignItems="center" gridGap="space_16" mr="space_16">
42+
<AboutApp />
43+
4144
{isOnline ? (
4245
<>
4346
<Link

0 commit comments

Comments
 (0)