Skip to content

Commit ec8aeed

Browse files
committed
Improve toast design for desktop and mobile
1 parent cf2e54c commit ec8aeed

File tree

1 file changed

+57
-7
lines changed

1 file changed

+57
-7
lines changed

index.html

Lines changed: 57 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,20 +68,50 @@
6868

6969
/* Success message animation */
7070
.success-message {
71+
display: flex;
72+
align-items: center;
73+
justify-content: center;
7174
position: fixed;
75+
gap: 8px;
7276
bottom: 20px;
7377
left: 50%;
7478
transform: translateX(-50%);
7579
opacity: 0;
76-
transition: opacity 0.3s ease;
80+
transition: opacity 0.25s ease;
7781
pointer-events: none;
7882
z-index: 100;
83+
font-size: 16px;
84+
background-color: var(--color-success-subtle);
85+
color: var(--color-success-fg);
86+
padding: 12px;
87+
border-radius: 6px;
88+
border: 1px solid;
89+
border-color: var(--color-success-fg);
90+
box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.2);
91+
}
92+
93+
@media screen and (max-width: 768px) {
94+
.success-message {
95+
bottom: 0;
96+
width: 100vw;
97+
border: none;
98+
border-top: 1px solid;
99+
padding: 16px;
100+
border-radius: 0;
101+
justify-content: center;
102+
text-align: center;
103+
box-shadow: 1px 0px 8px rgba(0, 0, 0, 0.2);
104+
105+
& svg {
106+
display: none;
107+
}
108+
}
79109
}
80110

81111
.success-message.visible {
82112
opacity: 1;
83-
animation: fadeOutAfterDelay 2s ease-in forwards;
84-
animation-delay: 1s;
113+
animation: fadeOutAfterDelay 1s ease-in forwards;
114+
animation-delay: 2s;
85115
}
86116

87117
@keyframes fadeOutAfterDelay {
@@ -250,7 +280,9 @@ <h3 class="f4">
250280
<section></section>
251281

252282
<!-- Success Notification -->
253-
<div id="successMessage" class="success-message color-bg-success-emphasis color-fg-on-emphasis px-3 py-2 rounded-2 border Box-shadow">URL copied to clipboard!</div>
283+
<div id="successMessage" class="success-message Box-shadow">
284+
<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor"><path d="M8 16A8 8 0 1 1 8 0a8 8 0 0 1 0 16Zm3.78-9.72a.751.751 0 0 0-.018-1.042.751.751 0 0 0-1.042-.018L6.75 9.19 5.28 7.72a.751.751 0 0 0-1.042.018.751.751 0 0 0-.018 1.042l2 2a.75.75 0 0 0 1.06 0Z"></path></svg>
285+
</div>
254286
</main>
255287

256288
<script>
@@ -354,14 +386,14 @@ <h3 class="f4">
354386
* Copy URL to clipboard
355387
*/
356388
function copyURLToClipboard() {
357-
copyToClipboard(elements.urlOutput.value, "URL copied to clipboard!");
389+
copyToClipboard(elements.urlOutput.value, "URL copied to clipboard");
358390
}
359391

360392
/**
361393
* Copy markdown to clipboard
362394
*/
363395
function copyMarkdownToClipboard() {
364-
copyToClipboard(generateMarkdown(), "Button markdown code copied!");
396+
copyToClipboard(generateMarkdown(), "Button markdown code copied");
365397
}
366398

367399
/**
@@ -416,7 +448,25 @@ <h3 class="f4">
416448
* @param {string} message - Message to display
417449
*/
418450
function showSuccessMessage(message) {
419-
elements.successMessage.textContent = message;
451+
// Create SVG icon element
452+
const svgIcon = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
453+
svgIcon.setAttribute('width', '16');
454+
svgIcon.setAttribute('height', '16');
455+
svgIcon.setAttribute('viewBox', '0 0 16 16');
456+
svgIcon.setAttribute('fill', 'currentColor');
457+
458+
const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
459+
path.setAttribute('d', 'M8 16A8 8 0 1 1 8 0a8 8 0 0 1 0 16Zm3.78-9.72a.751.751 0 0 0-.018-1.042.751.751 0 0 0-1.042-.018L6.75 9.19 5.28 7.72a.751.751 0 0 0-1.042.018.751.751 0 0 0-.018 1.042l2 2a.75.75 0 0 0 1.06 0Z');
460+
svgIcon.appendChild(path);
461+
462+
// Clear existing content
463+
elements.successMessage.innerHTML = '';
464+
465+
// Add SVG and message text
466+
elements.successMessage.appendChild(svgIcon);
467+
elements.successMessage.appendChild(document.createTextNode(' ' + message));
468+
469+
// Show the message
420470
elements.successMessage.classList.add('visible');
421471
setTimeout(() => {
422472
elements.successMessage.classList.remove('visible');

0 commit comments

Comments
 (0)