Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/el3um4s/renderer-for-electron-window-controls
Allow the renderer to close, minimize and maximize the window (for desktop Electron)
https://github.com/el3um4s/renderer-for-electron-window-controls
Last synced: about 4 hours ago
JSON representation
Allow the renderer to close, minimize and maximize the window (for desktop Electron)
- Host: GitHub
- URL: https://github.com/el3um4s/renderer-for-electron-window-controls
- Owner: el3um4s
- License: mit
- Created: 2022-08-17T13:26:07.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-01-09T03:56:21.000Z (over 1 year ago)
- Last Synced: 2024-09-20T00:02:51.414Z (5 days ago)
- Language: TypeScript
- Size: 323 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Renderer for Electron: Window Controls
Allow the renderer to close, minimize and maximize the window (for desktop Electron)
NPM link: [@el3um4s/renderer-for-electron-window-controls](https://www.npmjs.com/package/@el3um4s/renderer-for-electron-window-controls)
Use [@el3um4s/ipc-for-electron](https://www.npmjs.com/package/@el3um4s/ipc-for-electron) and [@el3um4s/ipc-for-electron-window-controls](https://www.npmjs.com/package/@el3um4s/ipc-for-electron-window-controls) to allow communication between Electron and a web page
### Install and use the package
To use the package in a project:
```bash
npm i @el3um4s/ipc-for-electron @el3um4s/ipc-for-electron-window-controls @el3um4s/renderer-for-electron-window-controls
```Then the `preload.ts` file:
```ts
import { generateContextBridge } from "@el3um4s/ipc-for-electron";
import windowControls from "@el3um4s/ipc-for-electron-window-controls";const listAPI = [windowControls];
generateContextBridge(windowControls);
```In the renderer file:
```ts
import windowControls from "@el3um4s/renderer-for-electron-window-controls";windowControls.minimize();
windowControls.maximize();
windowControls.unmaximize();
windowControls.close();
```In the renderer you can use:
```ts
globalThis.ipc.windowControls.send("minimize", null);
globalThis.ipc.windowControls.send("maximize", null);
globalThis.ipc.windowControls.send("unmaximize", null);
globalThis.ipc.windowControls.send("close", null);
```### API: Electron Side
- `minimize` - Minimize the window
- `maximize` - Maximize the window
- `unmaximize` - Unmaximize the window
- `close` - Close the window### API: Renderer Side - Request
`minimize = (options: { apiKey?: string }): void`
example:
```ts
import windowControls from "@el3um4s/renderer-for-electron-window-controls";windowControls.minimize();
````maximize = (options: { apiKey?: string }): void`
example:
```ts
import windowControls from "@el3um4s/renderer-for-electron-window-controls";windowControls.maximize({ apiKey: "my-api-key" });
````unmaximize = (options: { apiKey?: string }): void`
example:
```ts
import windowControls from "@el3um4s/renderer-for-electron-window-controls";windowControls.unmaximize();
````close = (options: { apiKey?: string }): void`
example:
```ts
import windowControls from "@el3um4s/renderer-for-electron-window-controls";windowControls.close();
```### Types
**DefaultApiKey**
```ts
type DefaultApiKey = "ipc";
```