Skip to content

Commit

Permalink
feat(components): blurhashSize prop
Browse files Browse the repository at this point in the history
  • Loading branch information
johannschopplich committed Apr 20, 2023
1 parent 32648a1 commit 8fe56cc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
6 changes: 4 additions & 2 deletions packages/react/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ export function LazyImage({ autoSizes, blurhash, blurhashSize }: Props) {

useEffect(() => {
if (target.current) {
const cleanup = lazyLoad(target.current, { blurhashSize })
const cleanup = lazyLoad(target.current, {
blurhash,
blurhashSize,
})
return () => {
cleanup()
}
Expand All @@ -23,7 +26,6 @@ export function LazyImage({ autoSizes, blurhash, blurhashSize }: Props) {
return (
<img
ref={target}
data-blurhash={blurhash}
data-sizes={autoSizes ? 'auto' : undefined}
loading="lazy"
/>
Expand Down
1 change: 0 additions & 1 deletion packages/react/src/react-env.d.ts

This file was deleted.

11 changes: 7 additions & 4 deletions packages/vue/src/components/LazyImage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@
import { onBeforeUnmount, onMounted, ref } from 'vue'
import { lazyLoad } from 'unlazy'
defineProps<{
blurhash?: string
const props = defineProps<{
autoSizes?: boolean
blurhash?: string
blurhashSize?: number
}>()
const target = ref<HTMLImageElement | undefined>()
onMounted(() => {
if (target.value) {
const cleanup = lazyLoad(target.value)
const cleanup = lazyLoad(target.value, {
blurhash: props.blurhash,
blurhashSize: props.blurhashSize,
})
onBeforeUnmount(cleanup)
}
})
Expand All @@ -20,7 +24,6 @@ onMounted(() => {
<template>
<img
ref="target"
:data-blurhash="blurhash"
:data-sizes="autoSizes ? 'auto' : undefined"
loading="lazy"
>
Expand Down

0 comments on commit 8fe56cc

Please sign in to comment.