Skip to content

Commit 0f7178e

Browse files
Merge pull request #24 from datacite/toast-cta
Add CTA icon for toast notices and don't display toast notices on smaller screen sizes
2 parents 9a45723 + 7d3d108 commit 0f7178e

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

source/javascripts/toast_notifications.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,11 @@
9393
text-decoration: none;
9494
}
9595
96-
.dc-toast__cta::after {
97-
content: '\u2192';
98-
font-size: 14px;
96+
.dc-toast__cta svg {
97+
width: 14px;
98+
height: 14px;
99+
flex-shrink: 0;
100+
fill: currentColor;
99101
}
100102
101103
.dc-toast__dismiss {
@@ -127,6 +129,12 @@
127129
transform: translateX(0);
128130
}
129131
}
132+
133+
@media (max-width: 640px) {
134+
.dc-toast-wrapper {
135+
display: none;
136+
}
137+
}
130138
`;
131139

132140
const ICONS = {
@@ -305,6 +313,14 @@
305313
cta.target = toast_cta_target || "_blank";
306314
cta.rel = "noopener noreferrer";
307315
cta.textContent = toast_cta_label;
316+
const ctaIcon = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
317+
ctaIcon.setAttribute('viewBox', '0 0 640 640');
318+
ctaIcon.setAttribute('aria-hidden', 'true');
319+
ctaIcon.setAttribute('focusable', 'false');
320+
const ctaPath = document.createElementNS('http://www.w3.org/2000/svg', 'path');
321+
ctaPath.setAttribute('d', 'M384 64C366.3 64 352 78.3 352 96C352 113.7 366.3 128 384 128L466.7 128L265.3 329.4C252.8 341.9 252.8 362.2 265.3 374.7C277.8 387.2 298.1 387.2 310.6 374.7L512 173.3L512 256C512 273.7 526.3 288 544 288C561.7 288 576 273.7 576 256L576 96C576 78.3 561.7 64 544 64L384 64zM144 160C99.8 160 64 195.8 64 240L64 496C64 540.2 99.8 576 144 576L400 576C444.2 576 480 540.2 480 496L480 416C480 398.3 465.7 384 448 384C430.3 384 416 398.3 416 416L416 496C416 504.8 408.8 512 400 512L144 512C135.2 512 128 504.8 128 496L128 240C128 231.2 135.2 224 144 224L224 224C241.7 224 256 209.7 256 192C256 174.3 241.7 160 224 160L144 160z');
322+
ctaIcon.appendChild(ctaPath);
323+
cta.appendChild(ctaIcon);
308324
textWrap.appendChild(cta);
309325
}
310326

0 commit comments

Comments
 (0)