Skip to content

Commit 9a2140c

Browse files
committed
HeaderMaker v1.0.3
• Added toast notifications for errors and success messages • Various small updates Updated by: Pavlo Mytrovtsiy (Bump_Er)
1 parent 2c7d672 commit 9a2140c

File tree

6 files changed

+103
-56
lines changed

6 files changed

+103
-56
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
node_modules/
22
release-builds/
33
test/
4+
idea/
45

56
.DS_Store
67
Thumbs.db

.idea/workspace.xml

Lines changed: 27 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/pages/index.css

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ body, html {
1414
.container {
1515
max-width: 1000px;
1616
width: 100%;
17-
padding: 20px;
18-
background-color: white;
19-
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
20-
border-radius: 12px;
2117
display: flex;
2218
flex-direction: column;
2319
align-items: center;
@@ -220,6 +216,7 @@ textarea {
220216
align-items: flex-start;
221217
margin: 20px 0;
222218
width: 48%;
219+
margin-bottom: 1px;
223220
}
224221

225222
.button-row {
@@ -248,15 +245,13 @@ textarea {
248245
#status_successfully {
249246
display: flex;
250247
justify-content: center;
251-
margin-top: 20px;
252248
color: #28a745;
253249
font-weight: bold;
254250
}
255251

256252
#status_error {
257253
display: flex;
258254
justify-content: center;
259-
margin-top: 20px;
260255
color: #a72828;
261256
font-weight: bold;
262257
}
@@ -390,7 +385,7 @@ textarea {
390385
}
391386

392387
.template-item {
393-
background-color: #b8d1f3; /*Background Color for Item */
388+
background-color: #b8d1f3; /*Background Color for Items */
394389
border-radius: 8px;
395390
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
396391
overflow: hidden;
@@ -475,3 +470,37 @@ textarea {
475470
.version{
476471
margin-top: -20px;
477472
}
473+
474+
#toast-container {
475+
position: fixed;
476+
top: 20px;
477+
right: 20px;
478+
z-index: 9999;
479+
display: flex;
480+
flex-direction: column;
481+
gap: 10px;
482+
}
483+
484+
.toast {
485+
background-color: #333;
486+
color: #fff;
487+
padding: 15px;
488+
border-radius: 5px;
489+
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
490+
opacity: 0;
491+
transform: translateY(20px);
492+
transition: opacity 0.5s, transform 0.5s;
493+
}
494+
495+
.toast.show {
496+
opacity: 1;
497+
transform: translateY(0);
498+
}
499+
500+
.toast.success {
501+
background-color: #4caf50;
502+
}
503+
504+
.toast.error {
505+
background-color: #f44336;
506+
}

app/pages/index.html

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</div>
1515

1616
<h1>HeaderMaker</h1>
17-
<h2 class="version">v1.0.2</h2>
17+
<h2 class="version">v1.0.3</h2>
1818

1919
<button id="select-directory" class="button_select-folder">Select Folder</button>
2020

@@ -66,8 +66,7 @@ <h2>View</h2>
6666
</div>
6767
</div>
6868

69-
<div id="status_successfully"></div>
70-
<div id="status_error"></div>
69+
<div id="toast-container"></div>
7170
</div>
7271
</div>
7372

@@ -210,10 +209,9 @@ <h2>Select a Template</h2>
210209
</div>
211210
</div>
212211

213-
214212
<div id="info-modal" class="modal">
215213
<div class="modal-content">
216-
<h2>How to Remove a Header</h2>
214+
<h2>How to remove a Header</h2>
217215
<p>
218216
To remove a header from your files, enter the exact header text you want to delete into the <strong>Enter
219217
Header</strong> field.
@@ -230,7 +228,7 @@ <h2>How to Remove a Header</h2>
230228

231229
<div id="help-modal" class="modal">
232230
<div class="modal-content">
233-
<h2>How to Use HeaderMaker</h2>
231+
<h2>How to use HeaderMaker</h2>
234232
<p>
235233
Welcome to <strong>HeaderMaker</strong>, your go-to tool for adding custom headers to your files with ease. Follow
236234
these steps to get started:

app/pages/index.js

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ document.getElementById('select-directory').addEventListener('click', async () =
4545
window.selectedDirectoryPath = directoryPath;
4646

4747
document.getElementById('header-options').style.display = 'block';
48-
4948
document.getElementById('select-directory').style.display = 'none';
5049
}
5150
});
@@ -56,26 +55,21 @@ document.getElementById('add-headers').addEventListener('click', async () => {
5655
const directoryPath = window.selectedDirectoryPath;
5756

5857
if (!directoryPath) {
59-
document.getElementById('status_error').textContent = 'Please select a folder before adding headers.';
58+
showToast('error', 'Please select a folder before adding headers.');
6059
return;
6160
}
6261

6362
if (!header) {
64-
document.getElementById('status_error').textContent = 'Please enter a header!';
63+
showToast('error', 'Please enter a header!');
6564
return;
6665
}
6766
if (fileTypes.length === 0) {
68-
document.getElementById('status_error').textContent = 'Please select at least one file type!';
67+
showToast('error', 'Please select at least one file type!');
6968
return;
7069
}
7170

7271
await window.electron.addHeaders(directoryPath, header, fileTypes);
73-
document.getElementById('status_successfully').textContent = 'Headers added successfully!';
74-
document.getElementById('status_error').textContent = '';
75-
76-
setTimeout(() => {
77-
document.getElementById('status_successfully').textContent = '';
78-
}, 3000);
72+
showToast('success', 'Headers added successfully!');
7973
});
8074

8175
document.getElementById('remove-headers').addEventListener('click', async () => {
@@ -84,26 +78,21 @@ document.getElementById('remove-headers').addEventListener('click', async () =>
8478
const directoryPath = window.selectedDirectoryPath;
8579

8680
if (!directoryPath) {
87-
document.getElementById('status_error').textContent = 'Please select a folder before removing headers.';
81+
showToast('error', 'Please select a folder before removing headers.');
8882
return;
8983
}
9084

9185
if (!header) {
92-
document.getElementById('status_error').textContent = 'Please enter a header!';
86+
showToast('error', 'Please enter a header!');
9387
return;
9488
}
9589
if (fileTypes.length === 0) {
96-
document.getElementById('status_error').textContent = 'Please select at least one file type!';
90+
showToast('error', 'Please select at least one file type!');
9791
return;
9892
}
9993

10094
await window.electron.removeHeaders(directoryPath, header, fileTypes);
101-
document.getElementById('status_successfully').textContent = 'Headers removed successfully!';
102-
document.getElementById('status_error').textContent = '';
103-
104-
setTimeout(() => {
105-
document.getElementById('status_successfully').textContent = '';
106-
}, 3000);
95+
showToast('success', 'Headers removed successfully!');
10796
});
10897

10998
document.getElementById('back-to-menu').addEventListener('click', () => {
@@ -119,9 +108,6 @@ document.getElementById('back-to-menu').addEventListener('click', () => {
119108
document.getElementById('file-types').querySelectorAll('input[type=checkbox]').forEach(checkbox => {
120109
checkbox.checked = false;
121110
});
122-
123-
document.getElementById('status_successfully').textContent = '';
124-
document.getElementById('status_error').textContent = '';
125111
});
126112

127113
function updateHeaderPreview() {
@@ -219,3 +205,24 @@ document.addEventListener('DOMContentLoaded', function () {
219205
updateHeaderPreview();
220206
}
221207
});
208+
209+
function showToast(type, message) {
210+
const toastContainer = document.getElementById('toast-container');
211+
212+
const toast = document.createElement('div');
213+
toast.className = `toast ${type}`;
214+
toast.innerText = message;
215+
216+
toastContainer.appendChild(toast);
217+
218+
requestAnimationFrame(() => {
219+
toast.classList.add('show');
220+
});
221+
222+
setTimeout(() => {
223+
toast.classList.remove('show');
224+
setTimeout(() => {
225+
toastContainer.removeChild(toast);
226+
}, 500);
227+
}, 3000);
228+
}

forge.config.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
const { FusesPlugin } = require('@electron-forge/plugin-fuses');
22
const { FuseV1Options, FuseVersion } = require('@electron/fuses');
3+
const path = require('path');
4+
const iconPath = path.resolve(__dirname, 'app/assets/icon/icon.ico');
35

46
module.exports = {
57
packagerConfig: {
68
asar: true,
7-
icon: 'app/assets/icon/icon.ico',
9+
icon: iconPath,
810
},
911
rebuildConfig: {},
1012
makers: [
1113
{
1214
name: '@electron-forge/maker-squirrel',
13-
config: {},
15+
config: {
16+
icon: iconPath,
17+
},
1418
},
1519
{
1620
name: '@electron-forge/maker-zip',
@@ -30,8 +34,6 @@ module.exports = {
3034
name: '@electron-forge/plugin-auto-unpack-natives',
3135
config: {},
3236
},
33-
// Fuses are used to enable/disable various Electron functionality
34-
// at package time, before code signing the application
3537
new FusesPlugin({
3638
version: FuseVersion.V1,
3739
[FuseV1Options.RunAsNode]: false,

0 commit comments

Comments
 (0)