Skip to content

Commit 719d5fe

Browse files
committed
Fix tray icon bug
1 parent 0ea0373 commit 719d5fe

File tree

8 files changed

+49
-12
lines changed

8 files changed

+49
-12
lines changed

.erb/assets/cron.png

689 KB
Loading

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535

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

38+
### Cron Editor
39+
40+
![Cron](./.erb/assets/cron.png)
41+
3842
### Regex Tester
3943

4044
![Regex](./.erb/assets/regex.png)

assets/tray.png

663 Bytes
Loading

assets/[email protected]

1.01 KB
Loading

assets/[email protected]

1.39 KB
Loading

src/components/cron/Cron.tsx

+40-7
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,24 @@ import { clipboard } from 'electron';
33
import cronstrue from 'cronstrue';
44
import classNames from 'classnames';
55

6+
const defaultCron = '29 8 * * *';
7+
const examples = [
8+
'* * * * * *',
9+
'* * * * *',
10+
'0 * * * *',
11+
'0 */12 * * *',
12+
'0 0 * * MON',
13+
'0 0 * * 6,0',
14+
'0 0 1 * *',
15+
'0 0 1 1 *',
16+
'0 0 1 */3 *',
17+
'0 0 1 */6 *',
18+
'0 0 1 1 *',
19+
];
20+
621
const CronEditor = () => {
7-
const [input, setInput] = useState('* * * * *');
8-
const [output, setOutput] = useState(cronstrue.toString('* * * * *'));
22+
const [input, setInput] = useState(defaultCron);
23+
const [output, setOutput] = useState(cronstrue.toString(defaultCron));
924
const [inputErr, setInputErr] = useState(false);
1025

1126
const handleChangeInput = (evt: { target: { value: string } }) =>
@@ -42,23 +57,24 @@ const CronEditor = () => {
4257
<div className="flex items-center space-x-2">
4358
<input
4459
onChange={handleChangeInput}
45-
className="flex-1 px-2 py-1 text-lg text-center bg-white rounded-md"
60+
className="flex-1 px-2 py-1 text-center bg-white rounded-md"
4661
value={input}
4762
/>
4863
</div>
4964
</section>
5065
<section
5166
className={classNames({
52-
'flex flex-col flex-shrink-0 text-center text-lg': true,
67+
'flex flex-col flex-shrink-0 text-center text-base': true,
5368
'text-blue-500': !inputErr,
5469
'text-red-500': inputErr,
5570
})}
5671
>
57-
{!inputErr && ''}
72+
{!inputErr && '"'}
5873
{output}
59-
{!inputErr && ''}
74+
{!inputErr && '"'}
6075
</section>
61-
<section className="flex flex-col items-center justify-start flex-1 opacity-70">
76+
<section className="flex flex-col items-start justify-start flex-shrink-0 pt-2 space-y-4 border-t border-gray-300 opacity-70">
77+
<p className="italic">Rules:</p>
6278
<table>
6379
<tbody>
6480
<tr className="flex space-x-4">
@@ -80,6 +96,23 @@ const CronEditor = () => {
8096
</tbody>
8197
</table>
8298
</section>
99+
<section className="flex flex-col items-start justify-start flex-shrink-0 pt-2 space-y-4 border-t border-gray-300 opacity-70">
100+
<p className="italic">Examples:</p>
101+
<table>
102+
<tbody>
103+
{examples.map((c) => (
104+
<tr
105+
className="flex space-x-4 cursor-pointer"
106+
key={c}
107+
onClick={() => setInput(c)}
108+
>
109+
<th className="w-32 text-left">{c}</th>
110+
<td>{cronstrue.toString(c)}</td>
111+
</tr>
112+
))}
113+
</tbody>
114+
</table>
115+
</section>
83116
</section>
84117
</div>
85118
);

src/main.dev.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,9 @@ const createWindow = async () => {
133133
};
134134

135135
const getIcon = () => {
136-
if (process.platform === 'win32') return '16x16.png';
137-
if (nativeTheme.shouldUseDarkColors) return '16x16.png';
138-
return '16x16.png';
136+
if (process.platform === 'win32') return 'tray.png';
137+
if (nativeTheme.shouldUseDarkColors) return 'tray.png';
138+
return 'tray.png';
139139
};
140140

141141
const showWindow = async () => {
@@ -146,7 +146,7 @@ const showWindow = async () => {
146146
};
147147

148148
const createTray = async () => {
149-
tray = new Tray(path.join(__dirname, '../assets/icons', getIcon()));
149+
tray = new Tray(path.join(__dirname, '../assets', getIcon()));
150150
tray.on('click', showWindow);
151151
tray.setToolTip('PlainBelt');
152152
};

src/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "plainbelt",
33
"productName": "PlainBelt",
4-
"version": "0.0.13",
4+
"version": "0.0.14",
55
"description": "A plain toolbelt for developers",
66
"main": "./main.prod.js",
77
"author": {

0 commit comments

Comments
 (0)