Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 4 additions & 25 deletions src/wwElement.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
v-bind="properties"
class="ww-image-basic"
ww-responsive="ww-image-basic"
:style="style"
:class="{ '-link': hasLink && !isEditing }"
>
<div class="ww-image-basic-overlay"></div>
Expand All @@ -14,9 +13,6 @@

<script>
export default {
inject: {
componentStyle: { default: () => {} },
},
props: {
content: { type: Object, required: true },
wwElementState: { type: Object, required: true },
Expand Down Expand Up @@ -47,23 +43,6 @@ export default {
return this.isWeWeb ? `${wwLib.wwUtils.getCdnPrefix()}${this.url}` : this.url;
},

/* STYLE */
aspectRatio() {
const elementAspectRatio = this.componentStyle.aspectRatio;
if (elementAspectRatio && elementAspectRatio !== 'unset') {
return `${elementAspectRatio}`;
} else {
return 'unset';
}
},
style() {
return {
'--wwi-ar': this.aspectRatio,
'--wwi-of': this.content.objectFit,
'--wwi-f': this.content.filter,
'--wwi-o': this.content.overlay,
};
},
isEditing() {
/* wwEditor:start */
return this.wwEditorState.editMode === wwLib.wwEditorHelper.EDIT_MODES.EDITION;
Expand Down Expand Up @@ -97,7 +76,7 @@ export default {
left: 0;
right: 0;
bottom: 0;
background: var(--wwi-o);
background: var(--wwi-o, transparent);
pointer-events: none;
}

Expand All @@ -106,9 +85,9 @@ export default {
width: 100%;
height: 100%;
display: block;
aspect-ratio: var(--wwi-ar);
object-fit: var(--wwi-of);
filter: var(--wwi-f);
aspect-ratio: var(--wwi-ar, unset);
object-fit: var(--wwi-of, fill);
filter: var(--wwi-f, none);
image-rendering: -webkit-optimize-contrast;
}
}
Expand Down
20 changes: 20 additions & 0 deletions ww-config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
export default {
type: 'wwObject',
css({ style, content }) {
return [
{
property: '--wwi-ar',
value: style.aspectRatio,
},
{
property: '--wwi-of',
value: content.objectFit,
},
{
property: '--wwi-f',
value: content.filter,
},
{
property: '--wwi-o',
value: content.overlay,
},
];
},
options: {
sizable: true,
ignoredStyleProperties: ['overflow'],
Expand Down