image icon indicating copy to clipboard operation
image copied to clipboard

chore: upgrade components to composition API

Open Diizzayy opened this issue 1 year ago • 2 comments

This PR upgrades the NuxtImg and NuxtPicture components to use the Composition API, and exposes a new useImage composable with the same behavior of the $img utility.

Other changes:

  • the nuxt-img component now supports preload

Diizzayy avatar Jul 15 '22 09:07 Diizzayy

Deploy Preview for nuxt-image-v1 canceled.

Name Link
Latest commit db7f982a8bdef1186edca4df465e555a48159963
Latest deploy log https://app.netlify.com/sites/nuxt-image-v1/deploys/63138640780710000a18ac48

netlify[bot] avatar Jul 15 '22 09:07 netlify[bot]

Would be nice adding the example directly to docs. Don't know if that should go to a separate PR? :)

<script lang="ts" setup>
const { generate } = useImage()
const bg = computed(() => {
  const imgUrl = generate('/images/colors.jpg', {
    width: 300,
    height: 300,
    quality: 80
  })
  return `url('${imgUrl}')`
})
</script>```

AndersNielsen85 avatar Jul 19 '22 09:07 AndersNielsen85

@AndersNielsen85 I changed back usage to $img = useImage() ($img is a function with attached props)

pi0 avatar Sep 03 '22 16:09 pi0

Thanks for helping on this. Nice changes ❤️

@pi0 no problem, happy to help.

Diizzayy avatar Sep 03 '22 16:09 Diizzayy