|
1 |
| -import React from 'react'; |
2 |
| -import { cnb } from 'cnbuilder'; |
3 | 1 | 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'; |
7 | 2 | 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'; |
16 | 11 |
|
17 | 12 | export type SbCtaProps = {
|
18 | 13 | blok: SbBlokData & {
|
19 |
| - align?: string; |
| 14 | + align?: CtaAlignType; |
20 | 15 | link: SbLinkType;
|
21 | 16 | linkText?: string;
|
22 | 17 | 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; |
27 | 22 | rel?: string;
|
28 | 23 | srText?: string;
|
29 | 24 | }
|
30 | 25 | };
|
31 | 26 |
|
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 | + |
33 | 41 | if (!props.blok.linkText) {
|
34 | 42 | return null;
|
35 | 43 | }
|
36 | 44 |
|
37 | 45 | 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> |
66 | 60 | );
|
67 |
| -}); |
| 61 | +}; |
0 commit comments