Skip to content

Commit

Permalink
feat(cms): handle media objects
Browse files Browse the repository at this point in the history
  • Loading branch information
Maciej Kucmus committed Nov 12, 2019
1 parent 5427bf0 commit 34e1210
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 26 deletions.
6 changes: 6 additions & 0 deletions packages/default-theme/sfui.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@
// $button-padding: 5px !default;
// global override including scoped componentss
// $button-padding: 50px;/* Here you can override global SCSS variables */
/* Here you can override global SCSS variables */

// global override excluding scoped components
// $button-padding: 5px !default;
// global override including scoped componentss
// $button-padding: 50px;
1 change: 1 addition & 0 deletions packages/vue
Submodule vue added at df1554
16 changes: 15 additions & 1 deletion test-page/src/components/cms/elements/SwGenericBlock.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<component :is="getComponent" :content="content" />
<component :is="getComponent" :content="content" :style="slotStyles"/>
</template>

<script>
Expand All @@ -15,6 +15,20 @@ export default {
computed: {
getComponent() {
return getComponentBy(this.content);
},
backgroundMediaMode() {
return this.content.backgroundMediaMode;
},
backgroundMediaMode() {
return this.content.backgroundMediaMode;
},
slotStyles() {
const {
backgroundMedia
} = this.content;
return {
backgroundImage: backgroundMedia ? `url(${backgroundMedia.url})` : null,
};
}
}
};
Expand Down
36 changes: 20 additions & 16 deletions test-page/src/components/cms/elements/SwImage.vue
Original file line number Diff line number Diff line change
@@ -1,35 +1,39 @@
<template>
<div class="sw-image">
<!-- <SfImage :content="getCmsSlot" /> -->
<h3>image but no content</h3>
<SfImage :src="imgUrl" :title="title" :alt="alt" :lazy="lazyLoad" />
</div>
</template>

<script>
// import {
// SfImage
// } from "@storefront-ui/vue";
import {
SfImage
} from "@storefront-ui/vue";
export default {
components: {
// SfImage
SfImage
},
props: {
content: {
type: Object,
default: () => ({})
}
},
computed: {}
computed: {
imgUrl() {
return this.content.data.media.url || ""
},
alt() {
return this.content.data.media.alt || ""
},
title() {
return this.content.data.media.title || ""
},
lazyLoad() {
return true;
}
}
};
</script>

<style lang="scss" scoped>
.sw-image {
border: 1px dashed #ff000a;
h3 {
padding: 10px;
color: #ff000a;
}
}
</style>
<style lang="scss" scoped></style>
9 changes: 0 additions & 9 deletions test-page/src/components/cms/elements/SwSlots.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,6 @@ export default {
const key = this.isBlock ? "blocks" : "slots";
return this.content && this.content[key] ? this.content[key] : [];
},
backgroundMediaId() {
return this.content.backgroundMediaId;
},
backgroundMedia() {
return this.content.backgroundMedia;
},
backgroundMediaMode() {
return this.content.backgroundMediaMode;
},
slotStyles() {
const {
marginTop,
Expand Down

0 comments on commit 34e1210

Please sign in to comment.