Skip to content

Commit

Permalink
test: re-implement tests using perform
Browse files Browse the repository at this point in the history
  • Loading branch information
cristinecula committed Dec 8, 2023
1 parent 93fed9c commit 03273d3
Show file tree
Hide file tree
Showing 7 changed files with 545 additions and 238 deletions.
42 changes: 30 additions & 12 deletions cosmoz-image-viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const renderCosmozImageViewer = ({
onPrintPdf,
detach,
detached,
syncDetachedState,
}) =>
detached
? nothing
Expand All @@ -70,8 +71,12 @@ const renderCosmozImageViewer = ({
${when(
shouldShow(host.showNav, total, 2),
() => html`
<button class="nav" @click=${previousImage}>${leftArrow}</button>
<button class="nav" @click=${nextImage}>${rightArrow}</button>
<button class="nav" name="prev" @click=${previousImage}>
${leftArrow}
</button>
<button class="nav" name="next" @click=${nextImage}>
${rightArrow}
</button>
`,
)}
<div class="flex"></div>
Expand All @@ -97,16 +102,28 @@ const renderCosmozImageViewer = ({
${launch}
</button>`,
)}
<button
class="nav"
@click=${onDownloadPdf}
title="${_('Download images')}"
>
${fileDownload}
</button>
<button class="nav" @click=${onPrintPdf} title="${_('Print images')}">
${printFile}
</button>
${when(
shouldShow(true, total),
() =>
html`<button
class="nav"
@click=${onDownloadPdf}
title="${_('Download images')}"
>
${fileDownload}
</button>`,
)}
${when(
shouldShow(true, total),
() =>
html`<button
class="nav"
@click=${onPrintPdf}
title="${_('Print images')}"
>
${printFile}
</button>`,
)}
${when(
shouldShow(host.showFullscreen, total),
() =>
Expand Down Expand Up @@ -147,6 +164,7 @@ const renderCosmozImageViewer = ({
@close=${closeFullscreen}
.currentImageIndex=${currentImageIndex}
@current-image-index-changed=${syncImageIndex}
@detached-changed=${syncDetachedState}
?show-detach=${host.showDetach}
?loop=${host.loop}
></cosmoz-image-viewer>`,
Expand Down
7 changes: 5 additions & 2 deletions lib/hooks/use-cosmoz-image-viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,15 @@ const onImageError = (e) => {
loop: host.loop,
onDetach: () => setDetached(true),
onClose: () => setDetached(false),
});
}),
syncDetachedState = (ev) => setDetached(ev.detail.value);

useNotifyProperty('currentImageIndex', index, [index]);

useEffect(() => {
host.toggleAttribute('hidden', detached);
}, [detached]);

useNotifyProperty('detached', detached, [detached]);
useImperativeApi({ syncState: detach }, [detach]);

return {
Expand All @@ -92,6 +94,7 @@ const onImageError = (e) => {
onPrintPdf: () => print({ images }),
detached,
detach,
syncDetachedState,
};
};

Expand Down
169 changes: 162 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
}
},
"dependencies": {
"@neovici/cfg": "^1.42.0",
"@neovici/cfg": "^1.43.0",
"@neovici/cosmoz-i18next": "^3.2.2",
"@neovici/cosmoz-slider": "^4.0.0",
"@neovici/cosmoz-utils": "^5.0.0",
Expand Down
Loading

0 comments on commit 03273d3

Please sign in to comment.