Skip to content

Commit f60f33d

Browse files
committed
minor style improve
1 parent 8e6c8cb commit f60f33d

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

app/index.html

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
<body>
1010
<title>Image encoder</title>
1111

12-
<div id="input-container">
12+
<div id="input-container" class="container">
1313
<div id="secret-container">
1414
<div id="drop-zone" style="display: none;">
1515
<p>Drag and drop an image file here.</p>
1616
<p>Supported formats: PNG, JPEG, BMP, ...</p>
1717
</div>
1818

19-
<label>Select an image file.</label>
19+
<label>Select an image file</label>
2020
<input type="file" id="fileInput" accept="image/*" required>
2121
<br>
2222
<label for="secretInput">Secret:</label>
@@ -36,14 +36,14 @@
3636
</div>
3737
</div>
3838

39-
<div id="output-container">
40-
<div id="downloadBtnContainer">
41-
<button id="downloadBtn" style="display: none;">Download Image</button>
39+
<div id="output-container" class="container">
40+
<div id="error"></div>
41+
<div id="downloadBtnContainer" style="display: none">
42+
<button id="downloadBtn">Download Image</button>
4243
</div>
43-
<label id="hint">Enter a secret and select an image file to encode / decode.</label>
44+
<label id="hint">Enter a secret and select an image file to encode / decode</label>
4445
<div id="inputImg"></div>
4546
<div id="output"></div>
46-
<div id="error"></div>
4747
</div>
4848

4949
<div id="footer">
@@ -71,6 +71,7 @@
7171
const hintLabel = document.getElementById('hint');
7272
const encodeButton = document.getElementById('encodeButton');
7373
const decodeButton = document.getElementById('decodeButton');
74+
const downloadBtnContainer = document.getElementById('downloadBtnContainer');
7475
const downloadBtn = document.getElementById('downloadBtn');
7576
const errorDiv = document.getElementById('error');
7677
const worker = new Worker('./worker.js', { type: 'module' });
@@ -109,8 +110,8 @@
109110
outputDiv.innerHTML = '';
110111
errorDiv.textContent = '';
111112
errorDiv.style.display = 'none';
112-
downloadBtn.style.display = 'none';
113-
hintLabel.textContent = 'Enter a secret and select an image file to encode / decode.';
113+
downloadBtnContainer.style.display = 'none';
114+
hintLabel.textContent = 'Enter a secret and select an image file to encode / decode';
114115
}
115116

116117
async function showImage(imBlob) {
@@ -124,11 +125,12 @@
124125
imgElem.alt = 'Image';
125126
outputDiv.appendChild(imgElem);
126127

127-
downloadBtn.style.display = 'block';
128+
downloadBtnContainer.style.display = 'block';
128129
downloadBtn.onclick = () => {
129130
const a = document.createElement('a');
130131
a.href = url;
131-
a.download = 'image.png';
132+
const timeName = new Date().toISOString().replace(/[:.]/g, '-');
133+
a.download = `img-${timeName}.png`;
132134
document.body.appendChild(a);
133135
a.click();
134136
document.body.removeChild(a);

app/style.css

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ body {
88
margin-left: auto;
99
}
1010

11+
.container {
12+
max-width: 100%;
13+
padding: 1rem;
14+
border-radius: 0.5rem;
15+
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
16+
}
17+
1118
div#drop-zone {
1219
border: 2px dashed #ccc;
1320
border-radius: 0.5rem;
@@ -27,25 +34,18 @@ div#secret-container {
2734
div#input-container {
2835
display: flex;
2936
flex-direction: column;
30-
max-width: 100%;
31-
padding: 0.5rem;
3237
margin-top: 0.5rem;
33-
border-radius: 0.2rem;
3438

3539
gap: 0.5rem;
3640
transition: all 0.3s ease-in-out;
37-
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
3841
}
3942

4043
div#output-container {
4144
margin-top: 1rem;
4245
display: flex;
4346
flex-direction: column;
44-
max-width: 100%;
47+
justify-content: center;
4548
background-color: whitesmoke;
46-
padding: 0.5rem;
47-
border-radius: 0.2rem;
48-
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
4949
gap: 0.25rem;
5050
}
5151

0 commit comments

Comments
 (0)