-
Notifications
You must be signed in to change notification settings - Fork 102
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(default-theme): Improve SwImage component with srcset #1887
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
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.
good start! :)
take a closer look at Optional Chaining and look more closely at Vue's Composition API, so we'll have logic inside the setup
method
imgUrl() { | ||
return getResizedImage(this.getMedia && this.getMedia.url) | ||
imagesUrl() { | ||
return this.getMedia ? this.getMedia.thumbnails : [] |
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.
return this.getMedia ? this.getMedia.thumbnails : [] | |
return this.getMedia?.thumbnails ?? [] |
setup(props, { root }) { | ||
const width = (props.imageWidth && props.imageWidth + "px") || "100%" | ||
const height = (props.imageHeight && props.imageHeight + "px") || "100%" | ||
return { | ||
placeholder: getPlaceholderImage(width, height), | ||
} | ||
}, | ||
computed: { | ||
srcsets () { | ||
return this.srcset ? this.srcset.map(item => ({ |
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.
let's move these computed properties to setup method, example:
const srcsets = computed(() => props.srcset?.map(item => ({
src: item.url,
width: item.width,
resolution: item.width
}) ?? []
)
33b2600
to
7d02980
Compare
…eat/improve-swimage-with-srcset
💙 shopware-pwa-test-europe-west1-gcp-storefrontcloud-io successfully deployed at https://4bcba761eed8f37e370250ddbda0f8bd9025f925.shopware-pwa-test.preview.europe-west1.gcp.storefrontcloud.io |
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 PR closes #1884
Changes
srcset
for SwImage component.Checklist