Skip to content

Commit 28c7460

Browse files
committed
test
1 parent 12b2469 commit 28c7460

File tree

1 file changed

+42
-48
lines changed

1 file changed

+42
-48
lines changed

components/Storyblok/SbCtaLink.tsx

Lines changed: 42 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,61 @@
1-
import React from 'react';
2-
import { cnb } from 'cnbuilder';
31
import { storyblokEditable, type SbBlokData } from '@storyblok/react/rsc';
4-
import { SbLink } from '@/components/Storyblok/partials/SbLink';
5-
import { SrOnlyText } from '@/components/Typography';
6-
import { type SbLinkType } from './Storyblok.types';
72
import {
8-
ctaLinkColors,
9-
ctaLinkStyles,
10-
ctaSizes,
11-
type CtaLinkStylesType,
12-
type CtaLinkColorsType,
13-
type CtaSizesType,
14-
type LinkIconsType,
15-
} from '@/utilities/datasource';
3+
CtaLink,
4+
type CtaAlignType,
5+
type CtaButtonStyleType,
6+
type CtaButtonSizeType,
7+
type CtaTextColorType,
8+
type CtaIconType,
9+
} from '@/components/Cta';
10+
import { type SbLinkType } from './Storyblok.types';
1611

1712
export type SbCtaProps = {
1813
blok: SbBlokData & {
19-
align?: string;
14+
align?: CtaAlignType;
2015
link: SbLinkType;
2116
linkText?: string;
2217
isButton?: boolean;
23-
linkButtonStyle?: CtaLinkStylesType;
24-
linkButtonSize?: CtaSizesType;
25-
linkIcon?: LinkIconsType;
26-
linkTextColor?: CtaLinkColorsType;
18+
linkButtonStyle?: CtaButtonStyleType;
19+
linkButtonSize?: CtaButtonSizeType;
20+
linkTextColor?: CtaTextColorType;
21+
linkIcon?: CtaIconType;
2722
rel?: string;
2823
srText?: string;
2924
}
3025
};
3126

32-
export const SbCtaLink = React.forwardRef<HTMLAnchorElement, SbCtaProps>((props, ref) => {
27+
export const SbCtaLink = (props: SbCtaProps) => {
28+
const {
29+
linkText,
30+
link,
31+
isButton,
32+
rel,
33+
srText,
34+
align,
35+
linkButtonStyle,
36+
linkButtonSize,
37+
linkIcon,
38+
linkTextColor,
39+
} = props.blok;
40+
3341
if (!props.blok.linkText) {
3442
return null;
3543
}
3644

3745
return (
38-
<div {...storyblokEditable(props.blok)} className={`ood-cta block text-${props.blok.align}`}>
39-
<SbLink
40-
ref={ref}
41-
link={props.blok.link}
42-
classes={cnb(props.blok.linkIcon,
43-
'text-18 md:text-20',
44-
{
45-
[
46-
`text-digital-red hocus:text-sky-dark hocus:underline
47-
${ctaLinkColors[props.blok.linkTextColor]}`
48-
]: !props.blok.isButton,
49-
[
50-
`pt-11 px-30 pb-12 font-sans
51-
inline-block w-auto border-none font-regular
52-
no-underline transition-colors hocus:underline
53-
${ctaLinkStyles?.[props.blok.linkButtonStyle]}
54-
${ctaSizes?.[props.blok.linkButtonSize]}`
55-
]: props.blok.isButton,
56-
},
57-
)}
58-
attributes={props.blok.rel ? {rel: props.blok.rel} : {}}
59-
>
60-
{props.blok.linkText}
61-
{props.blok.srText && (
62-
<SrOnlyText>{props.blok.srText}</SrOnlyText>
63-
)}
64-
</SbLink>
65-
</div>
46+
<CtaLink
47+
{...storyblokEditable(props.blok)}
48+
sbLink={link}
49+
isButton={isButton}
50+
buttonStyle={linkButtonStyle}
51+
buttonSize={linkButtonSize || 'default'}
52+
textColor={linkTextColor}
53+
icon={linkIcon}
54+
align={align || 'left'}
55+
srText={srText}
56+
rel={rel}
57+
>
58+
{linkText}
59+
</CtaLink>
6660
);
67-
});
61+
};

0 commit comments

Comments
 (0)