Skip to content

Commit c90e2fe

Browse files
authored
Add clear text button (#3)
1 parent 151609f commit c90e2fe

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

index.html

+15
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
<div class="header">
7171
<div class="left-controls">
7272
<span id="downloadButton" class="icon">Download</span>
73+
<span id="clearButton" class="icon">Clear</span>
7374
</div>
7475
</div>
7576

@@ -82,6 +83,7 @@
8283
const textarea = document.getElementById("editor");
8384
const icons = document.querySelectorAll(".icon");
8485
const downloadButton = document.getElementById("downloadButton");
86+
const clearButton = document.getElementById("clearButton");
8587

8688
// State Variables
8789
let buttonsHidden = false;
@@ -127,6 +129,18 @@
127129
URL.revokeObjectURL(a.href);
128130
};
129131

132+
const clearText = () => {
133+
textarea.style.transition = "opacity 0.3s";
134+
textarea.style.opacity = "0";
135+
136+
// Fade out, then fade in text
137+
setTimeout(() => {
138+
textarea.value = "";
139+
textarea.style.opacity = "1";
140+
localStorage.removeItem("shiroSavedText");
141+
}, 300);
142+
};
143+
130144
// Event Handlers
131145
const setupEventListeners = () => {
132146
// Text area events
@@ -144,6 +158,7 @@
144158

145159
// Button events
146160
downloadButton.addEventListener("click", downloadText);
161+
clearButton.addEventListener("click", clearText);
147162

148163
// Icon hover effects
149164
icons.forEach(icon => {

0 commit comments

Comments
 (0)