-
Notifications
You must be signed in to change notification settings - Fork 287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(nuxt-img): add custom
slot for full control of rendering
#1626
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! :)
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1626 +/- ##
==========================================
- Coverage 62.87% 62.78% -0.09%
==========================================
Files 79 79
Lines 3539 3547 +8
Branches 413 413
==========================================
+ Hits 2225 2227 +2
- Misses 1285 1291 +6
Partials 29 29 β View full report in Codecov by Sentry. |
I added the custom prop which acts similarly to the NuxtLink custom prop. I also updated the docs to show how to create custom placeholders with it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great - this is very promising!
Would you be able to add some tests? π
I'll be honest, I'm fairly new to unit testing, but I have some experience with Cypress. I added a test to check if the placeholder functionality and attribute fallthrough work as expected when the custom prop is set, and it seems they do. |
@danielroe is this okay or should I add more tests? |
src/runtime/components/NuxtImg.vue
Outdated
...imgAttrs, | ||
...attrs, | ||
}, | ||
isLoaded: isImageLoaded, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks perfect now, just one change - I think let's not expose isImageLoaded
as this can be misleading - on server load the load may take place before hydration and this will never end up being set to true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if it's significant, weΒ could also open a new PR to implement the functionality - maybe through an approach similar to error handling?
custom
slot for full control of rendering
π Linked issue
resolves #1307
β Type of change
π Description
This PR add a placeholder slot for NuxtImg component