Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cta): feature image duplication issue #11264

Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,27 @@ export const Default = (args) => {
: ((childCta as HTMLElement).innerText = customVideoTitle);
}
}
if (ctaType !== 'video') {
const childCta = document.querySelector('c4d-cta')?.shadowRoot!.children[0];
const headingComponent =
childCta?.shadowRoot?.querySelector('c4d-card-heading') ||
childCta?.querySelector('c4d-card-heading');
headingComponent && !duration
? (duration = headingComponent!.textContent!.match(/\((.*)\)/)?.pop())
: null;
if (headingComponent?.textContent) {
duration
? (headingComponent!.textContent = `${heading} (${duration})`)
: (headingComponent!.textContent = heading);
}
}

const childCta = document.querySelector('c4d-cta')?.shadowRoot!.children[0];
childCta?.setAttribute('href', href);

const childCtaRoot = document.querySelector('c4d-cta')?.shadowRoot;
const ctaFeatured = childCtaRoot?.querySelector('c4d-feature-cta');
const c4dImage = ctaFeatured?.querySelectorAll('c4d-image') || [];
const c4dHeading = ctaFeatured?.querySelectorAll('c4d-card-heading') || [];
return html`
${ctaStyle === 'button'
? html`
Expand Down Expand Up @@ -153,16 +170,26 @@ export const Default = (args) => {
: ''}
${ctaStyle === 'feature'
? html`
${ctaType !== 'video'
? html` <c4d-card-heading>${heading}</c4d-card-heading> `
${c4dHeading?.length < 1
? html`
${ctaType !== 'video'
? html`
<c4d-card-heading>${heading}</c4d-card-heading>
`
: ''}
`
: ''}
${ctaType !== CTA_TYPE.VIDEO || customThumbnail
${c4dImage?.length < 1
? html`
<c4d-image
slot="image"
alt="Image alt text"
default-src="${imgLg1x1}">
</c4d-image>
${ctaType !== CTA_TYPE.VIDEO || customThumbnail
? html`
<c4d-image
slot="image"
alt="Image alt text"
default-src="${imgLg1x1}">
</c4d-image>
`
: ''}
`
: ''}
<c4d-feature-cta-footer
Expand Down
Loading