Skip to content

Commit 6cb0a4d

Browse files
committed
feat: ajout fonction copie vers presse-papier sur les classes et les attributs
1 parent 070b8eb commit 6cb0a4d

File tree

4 files changed

+30
-6
lines changed

4 files changed

+30
-6
lines changed

assets/css/dsg_colors.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
.c-quaternary-200\:hover:hover {
3+
color: var(--dsg-colors-quaternary-200);
4+
}
5+
.c-secondary-200\:hover:hover {
6+
color: var(--dsg-colors-secondary-200);
7+
}
8+
.c-tertiary-200\:hover:hover {
9+
color: var(--dsg-colors-tertiary-200);
10+
}

assets/js/dsg.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,11 +344,19 @@ const dsg = {
344344
<div class="d-flex fd-column gap-1 | w-6t">
345345
<span class="d-flex fd-column">
346346
<span class="ff-lead-400 fs-1 tt-uppercase | c-secondary-700">CSS Classes</span>
347-
<code class="ff-mono fs-3 | c-secondary-500">${classes}</code>
347+
<code class="ff-mono fs-3 | c-secondary-500 c-secondary-200:hover | cur-pointer"
348+
title="Click to copy \n${classes} \nto clipboard"
349+
onclick="ui.copyToClipboard(this.innerText, true)">
350+
${classes}
351+
</code>
348352
</span>
349353
<span class="d-flex fd-column">
350354
<span class="ff-lead-400 fs-1 tt-uppercase | c-tertiary-700">Attribute</span>
351-
<code class="ff-mono fs-3 | c-tertiary-300">${attribute}</code>
355+
<code class="ff-mono fs-3 | c-tertiary-300 c-tertiary-200:hover | cur-pointer"
356+
title="Click to copy \n${attribute.replaceAll('"', '&quot;')} \nto clipboard"
357+
onclick="ui.copyToClipboard(this.innerText, true)">
358+
${attribute}
359+
</code>
352360
</span>
353361
</div>
354362
<span class="d-flex fd-column ai-end | w-6t">
@@ -360,7 +368,11 @@ const dsg = {
360368
docClassValueItem: function({className, value}) {
361369
return `
362370
<li class="d-flex ai-center jc-space-between gap-5 | fs-3">
363-
<code class="c-quaternary-500">${className}</code>
371+
<code class="c-quaternary-500 c-quaternary-200:hover | cur-pointer"
372+
title="Click to copy \n${className} \nto clipboard"
373+
onclick="ui.copyToClipboard(this.innerText, true)">
374+
${className}
375+
</code>
364376
<hr class="fg-1 | m-0 bb-0 bl-0 br-0 btwidth-1 btstyle-solid bcolor-primary-600">
365377
<strong class="ff-mono ta-right ws-nowrap | c-tertiary-500">${value}</strong>
366378
</li>

assets/js/ui.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ window.ui = {
1010
return id;
1111
},
1212

13-
copyToClipboard: function(textToCopy) {
13+
copyToClipboard: function(textToCopy, displayCopiedTextToNotif = false) {
14+
const notifText = displayCopiedTextToNotif ? `<div class="d-flex fd-column"><code class="fs-1">${textToCopy}</code><span>was copied to clipboard</span></div>` : `Copied to clipboard` ;
1415
if (navigator.clipboard !== undefined) {
1516
navigator.clipboard.writeText(textToCopy).then(
1617
function() {
1718
/* clipboard successfully set */
18-
ui.notifications.add('Copied to clipboard');
19+
ui.notifications.add(notifText);
1920
}
2021
)
2122
} else {
@@ -32,7 +33,7 @@ window.ui = {
3233
document.execCommand("copy");
3334
// Remove it from the body
3435
document.body.removeChild(aux);
35-
ui.notifications.add('Copied to clipboard');
36+
ui.notifications.add(notifText);
3637
}
3738
},
3839
notifications: {

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
<link rel="stylesheet" href="./assets/css/dsg_ellipsis.css">
6363
<link rel="stylesheet" href="./assets/css/dsg_forms.css">
6464
<link rel="stylesheet" href="./assets/css/dsg_animations.css">
65+
<link rel="stylesheet" href="./assets/css/dsg_colors.css">
6566
<link rel="stylesheet" href="./assets/css/monokai-sublime-customized.css">
6667
</head>
6768
<body class="m-0 | ff-lead-400 | bc-primary-700 c-primary-200">

0 commit comments

Comments
 (0)