Skip to content

Commit

Permalink
Tray icon (#15)
Browse files Browse the repository at this point in the history
* Make focus keep the same layout

* Change issue template

* Tray icon

* Release 0.0.4
  • Loading branch information
manhtai authored Jul 27, 2021
1 parent 11d1478 commit e562713
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 42 deletions.
18 changes: 4 additions & 14 deletions .github/ISSUE_TEMPLATE/1-Bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,7 @@ labels: 'bug'

<!--- Include as many relevant details about the environment you experienced the bug in -->

- Node version :
- electron-react-boilerplate version or branch :
- Operating System and version :
- Link to your project :

<!---
❗️❗️ Also, please consider donating (https://opencollective.com/electron-react-boilerplate-594) ❗️❗️
Donations will ensure the following:
🔨 Long term maintenance of the project
🛣 Progress on the roadmap
🐛 Quick responses to bug reports and help requests
-->
- Node version:
- PlainBelt version or branch:
- Operating System and version:
- Link to your project:
10 changes: 0 additions & 10 deletions .github/ISSUE_TEMPLATE/2-Question.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,3 @@ labels: 'question'
## Summary

<!-- What do you need help with? -->

<!---
❗️❗️ Also, please consider donating (https://opencollective.com/electron-react-boilerplate-594) ❗️❗️
Donations will ensure the following:
🔨 Long term maintenance of the project
🛣 Progress on the roadmap
🐛 Quick responses to bug reports and help requests
-->
12 changes: 1 addition & 11 deletions .github/ISSUE_TEMPLATE/3-Feature_request.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
---
name: Feature request
about: You want something added to the boilerplate. 🎉
about: You want something added to PlainBelt. 🎉
labels: 'enhancement'
---

<!---
❗️❗️ Also, please consider donating (https://opencollective.com/electron-react-boilerplate-594) ❗️❗️
Donations will ensure the following:
🔨 Long term maintenance of the project
🛣 Progress on the roadmap
🐛 Quick responses to bug reports and help requests
-->
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
## Features

- [x] Multiple plain text tools
- [x] Tray icon
- [ ] Clipboard auto detection
- [ ] Tray icon for quick action
- [ ] Global hotkey

## Tools list

Expand Down
4 changes: 2 additions & 2 deletions src/App.global.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
}

input {
@apply rounded focus:ring-blue-500 focus:outline-none focus:ring-2;
@apply rounded focus:ring-blue-500 focus:outline-none focus:ring-2 focus:ring-inset;
}

textarea {
@apply rounded focus:ring-blue-500 focus:outline-none focus:ring-2;
@apply rounded focus:ring-blue-500 focus:outline-none focus:ring-2 focus:ring-inset;
}
}
2 changes: 1 addition & 1 deletion src/components/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const Main = () => {
{/* Left sidebar */}
<nav className="flex flex-col w-1/4 overflow-x-hidden overflow-y-auto bg-gray-300">
{/* Search */}
<div className="flex items-center px-3 mx-3 mt-6 space-x-1 text-gray-400 bg-gray-200 rounded-md focus-within:text-gray-600 focus-within:ring-2 focus-within:ring-blue-500">
<div className="flex items-center px-2 mx-3 mt-6 space-x-1 text-gray-400 bg-gray-200 rounded-md focus-within:text-gray-600 focus-within:ring-2 focus-within:ring-blue-500">
<FontAwesomeIcon icon="search" />
<input
type="text"
Expand Down
32 changes: 30 additions & 2 deletions src/main.dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@
import 'core-js/stable';
import 'regenerator-runtime/runtime';
import path from 'path';
import { app, BrowserWindow, dialog, ipcMain, shell } from 'electron';
import {
app,
BrowserWindow,
dialog,
ipcMain,
nativeTheme,
shell,
Tray,
} from 'electron';
import { autoUpdater } from 'electron-updater';
import log from 'electron-log';
import { FileFilter, IpcMainInvokeEvent } from 'electron/main';
Expand All @@ -29,6 +37,7 @@ export default class AppUpdater {
}

let mainWindow: BrowserWindow | null = null;
let tray = null;

if (process.env.NODE_ENV === 'production') {
const sourceMapSupport = require('source-map-support');
Expand Down Expand Up @@ -115,6 +124,25 @@ const createWindow = async () => {
new AppUpdater();
};

const getIcon = () => {
if (process.platform === 'win32') return '16x16.png';
if (nativeTheme.shouldUseDarkColors) return '16x16.png';
return '16x16.png';
};

const createTray = async () => {
tray = new Tray(path.join(__dirname, '../assets/icons', getIcon()));

tray.on('click', async () => {
if (mainWindow == null) {
await createWindow();
}
mainWindow?.show();
});

tray.setToolTip('PlainBelt');
};

/**
* Handlers events from React
*/
Expand Down Expand Up @@ -179,7 +207,7 @@ app.on('window-all-closed', () => {
}
});

app.whenReady().then(createWindow).catch(console.log);
app.whenReady().then(createWindow).then(createTray).catch(console.log);

app.on('activate', () => {
// On macOS it's common to re-create a window in the app when the
Expand Down
2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "plainbelt",
"productName": "plainbelt",
"version": "0.0.3",
"version": "0.0.4",
"description": "A toolbelt for all your plain text",
"main": "./main.prod.js",
"author": {
Expand Down

0 comments on commit e562713

Please sign in to comment.