Skip to content

Commit

Permalink
Fix tray icon bug
Browse files Browse the repository at this point in the history
  • Loading branch information
manhtai committed Sep 1, 2021
1 parent 0ea0373 commit 719d5fe
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 12 deletions.
Binary file added .erb/assets/cron.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@

![Unix](./.erb/assets/unix.png)

### Cron Editor

![Cron](./.erb/assets/cron.png)

### Regex Tester

![Regex](./.erb/assets/regex.png)
Expand Down
Binary file added assets/tray.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 40 additions & 7 deletions src/components/cron/Cron.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,24 @@ import { clipboard } from 'electron';
import cronstrue from 'cronstrue';
import classNames from 'classnames';

const defaultCron = '29 8 * * *';
const examples = [
'* * * * * *',
'* * * * *',
'0 * * * *',
'0 */12 * * *',
'0 0 * * MON',
'0 0 * * 6,0',
'0 0 1 * *',
'0 0 1 1 *',
'0 0 1 */3 *',
'0 0 1 */6 *',
'0 0 1 1 *',
];

const CronEditor = () => {
const [input, setInput] = useState('* * * * *');
const [output, setOutput] = useState(cronstrue.toString('* * * * *'));
const [input, setInput] = useState(defaultCron);
const [output, setOutput] = useState(cronstrue.toString(defaultCron));
const [inputErr, setInputErr] = useState(false);

const handleChangeInput = (evt: { target: { value: string } }) =>
Expand Down Expand Up @@ -42,23 +57,24 @@ const CronEditor = () => {
<div className="flex items-center space-x-2">
<input
onChange={handleChangeInput}
className="flex-1 px-2 py-1 text-lg text-center bg-white rounded-md"
className="flex-1 px-2 py-1 text-center bg-white rounded-md"
value={input}
/>
</div>
</section>
<section
className={classNames({
'flex flex-col flex-shrink-0 text-center text-lg': true,
'flex flex-col flex-shrink-0 text-center text-base': true,
'text-blue-500': !inputErr,
'text-red-500': inputErr,
})}
>
{!inputErr && ''}
{!inputErr && '"'}
{output}
{!inputErr && ''}
{!inputErr && '"'}
</section>
<section className="flex flex-col items-center justify-start flex-1 opacity-70">
<section className="flex flex-col items-start justify-start flex-shrink-0 pt-2 space-y-4 border-t border-gray-300 opacity-70">
<p className="italic">Rules:</p>
<table>
<tbody>
<tr className="flex space-x-4">
Expand All @@ -80,6 +96,23 @@ const CronEditor = () => {
</tbody>
</table>
</section>
<section className="flex flex-col items-start justify-start flex-shrink-0 pt-2 space-y-4 border-t border-gray-300 opacity-70">
<p className="italic">Examples:</p>
<table>
<tbody>
{examples.map((c) => (
<tr
className="flex space-x-4 cursor-pointer"
key={c}
onClick={() => setInput(c)}
>
<th className="w-32 text-left">{c}</th>
<td>{cronstrue.toString(c)}</td>
</tr>
))}
</tbody>
</table>
</section>
</section>
</div>
);
Expand Down
8 changes: 4 additions & 4 deletions src/main.dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ const createWindow = async () => {
};

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

const showWindow = async () => {
Expand All @@ -146,7 +146,7 @@ const showWindow = async () => {
};

const createTray = async () => {
tray = new Tray(path.join(__dirname, '../assets/icons', getIcon()));
tray = new Tray(path.join(__dirname, '../assets', getIcon()));
tray.on('click', showWindow);
tray.setToolTip('PlainBelt');
};
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.13",
"version": "0.0.14",
"description": "A plain toolbelt for developers",
"main": "./main.prod.js",
"author": {
Expand Down

0 comments on commit 719d5fe

Please sign in to comment.