Skip to content

Commit

Permalink
feat: support modifiers prop for components (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
flozero authored Jan 25, 2021
1 parent 63aaa8a commit 6fe9e8f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/runtime/components/nuxt-img.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export default {
quality: { type: [Number, String], required: false, default: undefined },
background: { type: String, required: false, default: undefined },
fit: { type: String, required: false, default: undefined },
modifiers: { type: Object, required: false, default: undefined },
// options
preset: { type: String, required: false, default: undefined },
Expand All @@ -50,11 +51,12 @@ export default {
return this.$img(this.src, {
provider: this.provider,
preset: this.preset,
modifiers: this.modifiers
modifiers: this.nModifiers
}).url
},
modifiers () {
nModifiers () {
return {
...this.modifiers,
width: this.width,
height: this.height,
format: this.format,
Expand Down
9 changes: 7 additions & 2 deletions src/runtime/components/nuxt-picture.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export default {
quality: { type: [Number, String], required: false, default: undefined },
background: { type: String, required: false, default: undefined },
fit: { type: String, required: false, default: undefined },
modifiers: { type: Object, required: false, default: undefined },
// options
preset: { type: String, required: false, default: undefined },
Expand Down Expand Up @@ -122,8 +123,9 @@ export default {
}
return formats[this.nFormat] || this.originalFormat
},
modifiers () {
nModifiers () {
return {
...this.modifiers,
format: this.format,
quality: this.quality,
background: this.background,
Expand Down Expand Up @@ -194,7 +196,10 @@ export default {
sizes: this.sizes,
width: this.nWidth,
height: this.nHeight,
modifiers: { ...this.modifiers, format }
modifiers: {
...this.nModifiers,
format
}
})
return {
Expand Down

0 comments on commit 6fe9e8f

Please sign in to comment.