Skip to content

Commit 7b9d97a

Browse files
committed
feat(global): add max/min/quit buttons to example, rename hide to minimize + add maximize
1 parent 58e342e commit 7b9d97a

File tree

5 files changed

+46
-6
lines changed

5 files changed

+46
-6
lines changed

bridges/index.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,13 @@ export const electronBridge = {
1010
quit: (): void => {
1111
ipcRenderer.send("quit-app");
1212
},
13-
hide: (): void => {
14-
ipcRenderer.send("hide-app");
13+
14+
minimize: (): void => {
15+
ipcRenderer.send("minimize-app");
16+
},
17+
18+
maximize: (): void => {
19+
ipcRenderer.send("maximize-app");
1520
},
1621

1722
relaunch: (): void => {
@@ -32,7 +37,7 @@ export const electronBridge = {
3237

3338
contextBridge.exposeInMainWorld("electron", electronBridge);
3439

35-
export const storeBridge = createStoreBindings("config"); // "config" = the stores name
40+
export const storeBridge = createStoreBindings("config"); // "config" = the stores name
3641

3742
contextBridge.exposeInMainWorld("store", {
3843
...storeBridge,

src/app/ipc/main.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,18 @@ ipcMain.on("quit-app", () => {
44
app.quit();
55
});
66

7-
ipcMain.on("hide-app", () => {
7+
ipcMain.on("minimize-app", () => {
88
if (process.platform === "darwin") {
99
app.hide();
1010
return;
1111
}
1212
BrowserWindow.getFocusedWindow().minimize();
1313
});
1414

15+
ipcMain.on("maximize-app", () => {
16+
BrowserWindow.getFocusedWindow().maximize();
17+
});
18+
1519
ipcMain.on("relaunch-app", () => {
1620
app.relaunch();
1721
app.exit(0);

src/render/containers/HomePage/index.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const HomePage = () => {
2020
height={69}
2121
width={69}
2222
/>
23+
2324
<div className="font-bold mb-4">
2425
React + Tailwind + Electron + Redux = ♥
2526
</div>
@@ -63,7 +64,7 @@ const HomePage = () => {
6364
</button>
6465
</div>
6566

66-
<div className="flex flex-row text-pink-300 p-2">
67+
<div className="text-pink-300 p-2">
6768
<button
6869
onClick={async () => {
6970
window.electron.openPath(await window.store.getPath());
@@ -72,6 +73,24 @@ const HomePage = () => {
7273
Open Store
7374
</button>
7475
</div>
76+
77+
<div className="flex justify-center w-72">
78+
<button
79+
className="mac-red mr-auto w-24 text-right"
80+
onClick={window.electron.quit}
81+
>
82+
Exit / Quit
83+
</button>
84+
<button className="mac-orange w-24" onClick={window.electron.minimize}>
85+
Minimize
86+
</button>
87+
<button
88+
className="mac-green ml-auto w-24 text-left"
89+
onClick={window.electron.maximize}
90+
>
91+
Maximize
92+
</button>
93+
</div>
7594
</div>
7695
);
7796
};

src/render/index.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,15 @@
66
font-family: "Open Sans";
77
src: url(../../assets/fonts/OpenSans-Regular.ttf);
88
}
9+
10+
.mac-red {
11+
color: #ff605c;
12+
}
13+
14+
.mac-orange {
15+
color: #ffbd44;
16+
}
17+
18+
.mac-green {
19+
color: #00ca4e;
20+
}

tailwind.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ module.exports = {
88
extend: {},
99
},
1010
plugins: [],
11-
}
11+
};

0 commit comments

Comments
 (0)