@acorel/contentful-integration
Version:
Contentful integration with SAP Composable Storefront by Acorel
32 lines (27 loc) • 1.03 kB
text/typescript
import {Component, HostBinding} from '@angular/core';
import {CmsComponentData} from "@spartacus/storefront";
import {CmsContentfulContentSlotComponent} from "../../contentful.models";
import {Router} from "@angular/router";
import {Observable} from "rxjs";
import {tap} from "rxjs/operators";
({
selector: 'cx-contentful-content-slot',
templateUrl: './contentful-content-slot.component.html',
styleUrls: []
})
export class ContentfulContentSlotComponent {
('class') styleClasses: string | undefined;
('style') innerStyle: string | undefined;
data$: Observable<CmsContentfulContentSlotComponent> = this.component.data$.pipe(
tap((data) => (this.styleClasses = 'slot-' + data?.style?.toLowerCase())),
tap((data) => {
if (data?.backgroundColor) {
this.innerStyle='background-color: ' + data.backgroundColor;
}
})
);
constructor(
public component: CmsComponentData<CmsContentfulContentSlotComponent>,
protected router: Router
) {}
}