-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cms): cms three columns element (#500)
- Loading branch information
1 parent
8b91b59
commit 003d2cb
Showing
4 changed files
with
94 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,45 @@ | ||
const slotsMap = { | ||
"product-box": "CmsSwProductCart", | ||
"product-slider": "SwProductSlider", | ||
image: "SwImage", | ||
text: "SwTextSlot", | ||
"vimeo-video": "SwVimeoVideo", | ||
"youtube-video": "SwYoutubeVideo", | ||
"product-listing": "SwProductListingSlot", | ||
"category-navigation": "SwCategoryNavigationSlot", // waiting for navigation hydration, and domething wrong with accordion | ||
"sidebar-filter": "SwCategorySidebarFilter" | ||
}; | ||
'product-box': 'CmsSwProductCart', | ||
'product-slider': 'SwProductSlider', | ||
image: 'SwImage', | ||
text: 'SwTextSlot', | ||
'vimeo-video': 'SwVimeoVideo', | ||
'youtube-video': 'SwYoutubeVideo', | ||
'product-listing': 'SwProductListingSlot', | ||
'category-navigation': 'SwCategoryNavigationSlot', // waiting for navigation hydration, and domething wrong with accordion | ||
'sidebar-filter': 'SwCategorySidebarFilter', | ||
'image-bubble-row': 'SwImageBubbleRow' | ||
} | ||
|
||
const excludedSlots = ['image-bubble-row'] | ||
|
||
export function getComponentBy(content) { | ||
if (!content) return; | ||
const isSlot = !!content.slot; | ||
let componentName = isSlot ? slotsMap[content.type] : "SwSlots"; | ||
if (!componentName) componentName = "SwNoComponent"; | ||
return () => import(`@shopware-pwa/default-theme/components/cms/elements/${componentName}`); | ||
if (!content) return | ||
const isSlot = | ||
!!content.slot || !!excludedSlots.find(slot => slot === content.type) | ||
let componentName = isSlot ? slotsMap[content.type] : 'SwSlots' | ||
if (!componentName) componentName = 'SwNoComponent' | ||
return () => | ||
import( | ||
`@shopware-pwa/default-theme/components/cms/elements/${componentName}` | ||
) | ||
} | ||
|
||
export const setContentOrder = content => { | ||
const newContent = JSON.parse(JSON.stringify(content)) | ||
const slotsArr = [] | ||
newContent.slots.forEach(slot => { | ||
switch (slot.slot) { | ||
case 'left': | ||
slotsArr[0] = slot | ||
break | ||
case 'right': | ||
slotsArr[2] = slot | ||
break | ||
default: | ||
slotsArr[1] = slot | ||
} | ||
}) | ||
newContent.slots = slotsArr | ||
return newContent | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,8 +45,4 @@ export default { | |
display: flex; | ||
justify-content: center; | ||
} | ||
::v-deep .sf-image__img { | ||
width: 100%; | ||
} | ||
</style> |
53 changes: 53 additions & 0 deletions
53
packages/default-theme/components/cms/elements/SwImageBubbleRow.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<template> | ||
<div class="sw-image-bubble-row"> | ||
<SwImage v-for="image in slots.slots" :key="image.id" :content="image"/> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import SwImage from "./SwImage"; | ||
import { setContentOrder } from "../cmsNameMapper"; | ||
import { reactive } from "@vue/composition-api"; | ||
export default { | ||
name: 'SwImageBubbleRow', | ||
components: { | ||
SwImage, | ||
}, | ||
props: { | ||
content: { | ||
type: Object, | ||
default: () => ({}) | ||
} | ||
}, | ||
setup(props) { | ||
const slots = reactive(setContentOrder(props.content)) | ||
return {slots} | ||
} | ||
}; | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
@import '~@storefront-ui/vue/styles.scss'; | ||
.sw-image-bubble-row { | ||
display: flex; | ||
flex-direction: column; | ||
margin: var(--spacer-extra-big) 0; | ||
@include for-desktop { | ||
flex-direction: row; | ||
justify-content: space-around; | ||
} | ||
} | ||
::v-deep .sf-image { | ||
border-radius: 50%; | ||
margin: var(--spacer-small); | ||
& img { | ||
height: 300px; | ||
width: 300px; | ||
object-fit: cover; | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters