Skip to content

Commit cd58475

Browse files
committed
Use template string for copy button
Addresses #883 (comment)
1 parent 354e3ca commit cd58475

File tree

1 file changed

+17
-21
lines changed

1 file changed

+17
-21
lines changed

docs/.eleventy.js

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -136,29 +136,25 @@ module.exports = function(eleventyConfig) {
136136

137137
// Copy button shortcode
138138
eleventyConfig.addLiquidShortcode("copybutton", function(name) {
139-
var checkmarkIcon = Icons["Checkmark"];
140-
var copyIcon = Icons["Copy"];
141139
var tooltipId = "tooltip-" + (name || Math.floor(Math.random() * 1000));
142140

143-
var output = '';
144-
output += '<button'
145-
output += ' class="s-btn s-btn__muted s-btn__icon ps-absolute t8 r8"';
146-
output += ' data-action="clipboard#copy"';
147-
output += ' data-s-tooltip-placement="top"';
148-
output += ' data-controller="s-tooltip"';
149-
output += ' aria-describedby="' + tooltipId + '"';
150-
output += '>';
151-
output += '<span class="d-none" data-show-on-copy>' + checkmarkIcon + '</span>';
152-
output += '<span data-hide-on-copy>' + copyIcon + '</span>';
153-
output += '</button>'
154-
output += '<div class="s-popover s-popover__tooltip"';
155-
output += ' id="' + tooltipId + '"';
156-
output += ' role="tooltip"';
157-
output += ' aria-hidden="true">';
158-
output += '<div class="s-popover--arrow"></div>';
159-
output += '<span class="d-none" data-show-on-copy>Copied</span>';
160-
output += '<span data-hide-on-copy>Copy</span>';
161-
output += '</div>';
141+
var output = `<button
142+
class="s-btn s-btn__muted s-btn__icon ps-absolute t8 r8"
143+
data-action="clipboard#copy"
144+
data-s-tooltip-placement="top"
145+
data-controller="s-tooltip"
146+
aria-describedby="${tooltipId}">
147+
<span class="d-none" data-show-on-copy>${Icons["Checkmark"]}</span>
148+
<span data-hide-on-copy>${Icons["Copy"]}</span>
149+
</button>
150+
<div class="s-popover s-popover__tooltip"
151+
id="${tooltipId}"
152+
role="tooltip"
153+
aria-hidden="true">
154+
<div class="s-popover--arrow"></div>
155+
<span class="d-none" data-show-on-copy>Copied</span>
156+
<span data-hide-on-copy>Copy</span>
157+
</div>`;
162158

163159
return output;
164160
});

0 commit comments

Comments
 (0)