Skip to content

Commit

Permalink
fix: cta props
Browse files Browse the repository at this point in the history
  • Loading branch information
sabrina-bongiovanni committed Nov 21, 2024
1 parent 121a166 commit 6f07049
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 35 deletions.
2 changes: 1 addition & 1 deletion packages/volto-blocks/news/4.internal
Original file line number Diff line number Diff line change
@@ -1 +1 @@
created component for ctas in blocks @sabrina-bongiovanni
Created component for ctas in blocks @sabrina-bongiovanni
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,14 @@ export default function Edit(props: CallToActionEditProps) {
{data.linkHref?.[0] && (
<CTA
href={data.linkHref ? data.linkHref[0]['@id'] : undefined}
linkTitle={data.linkTitle}
onClick={(e: React.SyntheticEvent<HTMLLinkElement>) => {
e.preventDefault();
}}
openLinkInNewTab={false}
{...data}
/>
>
{data.linkTitle}
</CTA>
)}
</Container>
</section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ export default function View({ data, className, style }: Props) {
{data.linkHref?.[0] && (
<CTA
href={data.linkHref ? data.linkHref[0]['@id'] : undefined}
linkTitle={data.linkTitle}
openLinkInNewTab={false}
{...data}
/>
>
{data.linkTitle}
</CTA>
)}
</Container>
</section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,14 @@ export default function Edit(props: CardWithImagesEditProps) {
{data.linkHref?.[0] && (
<CTA
href={data.linkHref ? data.linkHref[0]['@id'] : undefined}
linkTitle={data.linkTitle}
onClick={(e: React.SyntheticEvent<HTMLLinkElement>) => {
e.preventDefault();
}}
openLinkInNewTab={false}
{...data}
/>
>
{data.linkTitle}
</CTA>
)}
</div>
</Container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,12 @@ export default function View({ data, className, style }: Props) {
)}
{data.linkHref?.[0] && (
<CTA
href={
data.linkHref
? flattenToAppURL(data.linkHref[0]['@id'])
: undefined
}
linkTitle={data.linkTitle}
href={data.linkHref ? data.linkHref[0]['@id'] : undefined}
openLinkInNewTab={false}
{...data}
/>
>
{data.linkTitle}
</CTA>
)}
</div>
</Container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,14 @@ export default function Edit(props: IconsAndTextEditProps) {
{data.linkHref?.[0] && (
<CTA
href={data.linkHref ? data.linkHref[0]['@id'] : undefined}
linkTitle={data.linkTitle}
onClick={(e: React.SyntheticEvent<HTMLLinkElement>) => {
e.preventDefault();
}}
openLinkInNewTab={false}
{...data}
/>
>
{data.linkTitle}
</CTA>
)}
</Container>
</section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ export default function View({ data, className, style }: Props) {
{data.linkHref?.[0] && (
<CTA
href={data.linkHref ? data.linkHref[0]['@id'] : undefined}
linkTitle={data.linkTitle}
openLinkInNewTab={false}
{...data}
/>
>
{data.linkTitle}
</CTA>
)}
</Container>
</section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,14 @@ export default function Edit(props: PageIntroEditProps) {
{data.linkHref?.[0] && (
<CTA
href={data.linkHref ? data.linkHref[0]['@id'] : undefined}
linkTitle={data.linkTitle}
onClick={(e: React.SyntheticEvent<HTMLLinkElement>) => {
e.preventDefault();
}}
openLinkInNewTab={false}
{...data}
/>
>
{data.linkTitle}
</CTA>
)}
</div>
<div className={cx('block-pageintro-wide-col', styles.wide)}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ export default function View({ data, className, style }: Props) {
{data.linkHref?.[0] && (
<CTA
href={data.linkHref ? data.linkHref[0]['@id'] : undefined}
linkTitle={data.linkTitle}
openLinkInNewTab={false}
{...data}
/>
>
{data.linkTitle}
</CTA>
)}
</div>
<div className={cx('block-pageintro-wide-col', styles.wide)}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,14 @@ export default function Edit(props: TestimonialsEditProps) {
{data.linkHref?.[0] && (
<CTA
href={data.linkHref ? data.linkHref[0]['@id'] : undefined}
linkTitle={data.linkTitle}
onClick={(e: React.SyntheticEvent<HTMLLinkElement>) => {
e.preventDefault();
}}
openLinkInNewTab={false}
{...data}
/>
>
{data.linkTitle}
</CTA>
)}
</div>
</Container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,11 @@ export default function View({ data, className, style }: Props) {
{data.linkHref?.[0] && (
<CTA
href={data.linkHref ? data.linkHref[0]['@id'] : undefined}
linkTitle={data.linkTitle}
openLinkInNewTab={false}
{...data}
/>
>
{data.linkTitle}
</CTA>
)}
</div>
</Container>
Expand Down
10 changes: 1 addition & 9 deletions packages/volto-blocks/src/components/blocks/commons/CTA.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,9 @@ import { type ComponentProps } from 'react';
import { UniversalLink } from '@plone/volto/components';

const CTA = (props: ComponentProps<typeof UniversalLink>) => {
const { href, linkTitle, onClick, openLinkInNewTab } = props;
return (
<div className="blocks-cta">
<UniversalLink
href={href}
openLinkInNewTab={openLinkInNewTab}
onClick={onClick}
{...props}
>
{linkTitle}
</UniversalLink>
<UniversalLink {...props} />
</div>
);
};
Expand Down

0 comments on commit 6f07049

Please sign in to comment.