Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Commit

Permalink
feat(plugins): context for plugin slots (#832)
Browse files Browse the repository at this point in the history
  • Loading branch information
patzick authored Jun 2, 2020
1 parent baf1c9c commit 9d0ccd4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
8 changes: 7 additions & 1 deletion packages/cli/src/templates/plugins/SwPluginSlot.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<template>
<component :is="getComponent" :name="name"> <slot /> </component>
<component :is="getComponent" :name="name" :slotContext="slotContext">
<slot />
</component>
</template>
<script>
import Vue from "vue"
Expand All @@ -26,6 +28,10 @@ export default {
type: String,
default: "",
},
slotContext: {
type: Object,
default: null
}
},
setup() {
const { showPluginSlots } = usePlugins();
Expand Down
7 changes: 5 additions & 2 deletions packages/default-theme/components/SwProductDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
:tier-prices="getTierPrices"
/>
</div>
<SwPluginSlot name="product-page-description">
<SwPluginSlot name="product-page-description" :slotContext="product">
<p
class="product-details__description desktop-only"
v-html="description"
Expand Down Expand Up @@ -50,7 +50,10 @@
class="product-details__add-to-cart"
@click="addToCart"
/>
<SwPluginSlot name="product-page-add-to-cart-button-after" />
<SwPluginSlot
name="product-page-add-to-cart-button-after"
:slotContext="product"
/>
<div class="product-details__action desktop-only">
<SwButton class="sf-button--text product-details__action-button"
>Save for later</SwButton
Expand Down
4 changes: 2 additions & 2 deletions packages/default-theme/components/views/ProductView.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<template>
<div v-if="product" id="product">
<SwPluginSlot name="product-page-details-before" />
<SwPluginSlot name="product-page-details-before" :slotContext="product" />
<div class="product">
<SwProductGallery :product="product" class="product__gallery" />
<div class="product__description">
<SwProductDetails :product="product" :page="page" />
</div>
</div>
<SwPluginSlot name="product-page-details-after" />
<SwPluginSlot name="product-page-details-after" :slotContext="product" />
<div class="products__recomendations">
<div class="products-recomendations__section">
<SwProductCarousel />
Expand Down
2 changes: 1 addition & 1 deletion packages/default-theme/layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<SwPluginSlot name="page-top" />
<SwHeader />
<SwPluginSlot name="top-header-after" />
<SwPluginSlot name="breadcrumbs">
<SwPluginSlot name="breadcrumbs" :slotContext="getBreadcrumbs" >
<SfBreadcrumbs
v-show="getBreadcrumbs.length > 0"
:breadcrumbs="getBreadcrumbs"
Expand Down

1 comment on commit 9d0ccd4

@vercel
Copy link

@vercel vercel bot commented on 9d0ccd4 Jun 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.