-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #163 from holochain-apps/fix/display-close-on-ligh…
…tbox refactor(ui): extract lightbox logic to its own component
- Loading branch information
Showing
2 changed files
with
44 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<script lang="ts"> | ||
import BiggerPicture from 'bigger-picture'; | ||
import 'bigger-picture/css'; | ||
export let btnClass = ""; | ||
export let src = ""; | ||
export let alt = ""; | ||
let biggerPicture = BiggerPicture({ | ||
target: document.body | ||
}); | ||
function show(e: PointerEvent | MouseEvent) { | ||
const targetImg = e.target as HTMLImageElement; | ||
biggerPicture.open({ | ||
items: [ | ||
{ | ||
// Because we don't know the original image dimensions, | ||
// we scale by 10x and let bigger-picture handle constaining within window | ||
// TODO: use the original image dimensions either by publishing to DHT or determining after downloading image | ||
width: targetImg.width * 10, | ||
height: targetImg.height * 10, | ||
img: src, | ||
} | ||
] | ||
}) | ||
} | ||
</script> | ||
|
||
<button on:click={(e) => show(e)} class={btnClass}}> | ||
<img {src} {alt} class="object-cover" /> | ||
</button> | ||
|
||
<style> | ||
:global(.bp-zoomed.bp-small .bp-controls) { | ||
opacity: 1 !important; | ||
} | ||
:global(.bp-close) { | ||
z-index: 50; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters