UNPKG

@progress/sitefinity-nextjs-sdk

Version:

Provides OOB widgets developed using the Next.js framework, which includes an abstraction layer for Sitefinity communication. Additionally, it offers an expanded API, typings, and tools for further development and integration.

29 lines (28 loc) 2.87 kB
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime"; import { StyleGenerator } from '../styling/style-generator.service'; import { htmlAttributes, generateAnchorAttrsFromLink, getCustomAttributes } from '../../editor/widget-framework/attributes'; import { classNames } from '../../editor/utils/classNames'; import { Tracer } from '@progress/sitefinity-nextjs-sdk/diagnostics/empty'; export async function CallToAction(props) { const { span } = Tracer.traceWidget(props, false); const properties = { ...props.model.Properties }; const dataAttributes = htmlAttributes(props); const defaultClass = classNames('d-flex align-items-center', properties.CssClass); const positionClass = StyleGenerator.getAlignmentClasses(properties.Position && properties.Position.CTA ? properties.Position.CTA.Alignment : 'Left'); const marginClass = properties.Margins && StyleGenerator.getMarginClasses(properties.Margins); dataAttributes['className'] = classNames(defaultClass, positionClass, marginClass); const primaryAnchorAttributes = generateAnchorAttrsFromLink(properties.PrimaryActionLink); const secondaryAnchorAttributes = generateAnchorAttrsFromLink(properties.SecondaryActionLink); const wrapperCustomAttributes = getCustomAttributes(properties.Attributes, 'Wrapper'); const primaryCustomAttributes = getCustomAttributes(properties.Attributes, 'Primary'); const secondaryCustomAttributes = getCustomAttributes(properties.Attributes, 'Secondary'); const primaryClass = properties.Style && properties.Style.Primary ? properties.Style.Primary.DisplayStyle : 'Primary'; const primaryButtonClass = StyleGenerator.getButtonClasses(primaryClass); const secondaryClass = properties.Style && properties.Style.Secondary ? properties.Style.Secondary.DisplayStyle : 'Secondary'; const secondaryButtonClass = StyleGenerator.getButtonClasses(secondaryClass); return (_jsxs(_Fragment, { children: [_jsxs("div", { ...dataAttributes, ...wrapperCustomAttributes, children: [props.model.Properties.PrimaryActionLabel && _jsx("a", { ...primaryAnchorAttributes, className: classNames('me-3', primaryButtonClass), "data-call-to-action": true, "sfdi-trigger": "click", "sfdi-predicate": "Call to action", "sfdi-object": props.model.Properties.PrimaryActionLabel, ...primaryCustomAttributes, children: props.model.Properties.PrimaryActionLabel }), props.model.Properties.SecondaryActionLabel && _jsx("a", { ...secondaryAnchorAttributes, className: secondaryButtonClass, "data-call-to-action": true, "sfdi-trigger": "click", "sfdi-predicate": "Call to action", "sfdi-object": props.model.Properties.SecondaryActionLabel, ...secondaryCustomAttributes, children: props.model.Properties.SecondaryActionLabel })] }), Tracer.endSpan(span)] })); }