feat: Filtre les boutons
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Simon 2023-05-03 17:38:21 +02:00
parent c85fdc8d27
commit 4c3d796b17
1 changed files with 9 additions and 7 deletions

View File

@ -138,9 +138,15 @@ const saveAs = (blob, fileName) => {
const sharing = ref(false); const sharing = ref(false);
async function share() { async function share() {
sharing.value = true; sharing.value = true;
const filter = (node) => {
const exclusionClasses = ["btn"];
return !exclusionClasses.some((classname) =>
node.classList?.contains(classname)
);
};
const body = document.querySelector("body"); const body = document.querySelector("body");
body.classList.add("print"); body.classList.add("print");
const dataUrl = await toPng(body); const dataUrl = await toPng(body, { filter: filter });
body.classList.remove("print"); body.classList.remove("print");
saveAs(dataUrl, "my-node.png"); saveAs(dataUrl, "my-node.png");
sharing.value = false; sharing.value = false;
@ -197,11 +203,7 @@ async function share() {
</li> </li>
</ul> </ul>
</div> </div>
<button <button class="btn download" @click="() => share()" v-if="!sharing">
class="btn download no-print"
@click="() => share()"
v-if="!sharing"
>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 36 36"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 36 36">
<path <path
fill="#D99E82" fill="#D99E82"
@ -221,7 +223,7 @@ async function share() {
/> />
</svg> </svg>
</button> </button>
<button class="btn spin no-print" v-if="sharing"> <button class="btn spin" v-if="sharing">
<img src="/spin.svg" /> <img src="/spin.svg" />
</button> </button>
</div> </div>