File size: 1,757 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import React from "react";
import { Cell, Grid } from "@faceless-ui/css-grid";
import { Page } from "../../../payload-types";
import { BackgroundColor } from "../../BackgroundColor";
import { Gutter } from "../../Gutter";
import { CMSLink } from "../../Link";
import RichText from "../../RichText";

import classes from "./index.module.scss";

type Props = {
  ctaBackgroundColor?: "white" | "black";
  richText: {
    [k: string]: unknown;
  }[];
  links: {
    link: {
      type?: "reference" | "custom";
      newTab?: boolean;
      reference: {
        value: string | Page;
        relationTo: "pages";
      };
      url: string;
      label: string;
    };
    id?: string;
  }[];
  id?: string;
  blockName?: string;
  blockType: "cta";
};
export const CallToActionBlock: React.FC<Props> = ({
  ctaBackgroundColor,
  links,
  richText,
}) => {
  const oppositeBackgroundColor =
    ctaBackgroundColor === "white" ? "black" : "white";

  return (
    <Gutter>
      <BackgroundColor color={oppositeBackgroundColor}>
        <div className={classes.callToAction}>
          <Grid>
            <Cell cols={8} colsL={7} colsM={12}>
              <div>
                <RichText className={classes.richText} content={richText} />
              </div>
            </Cell>

            <Cell
              start={10}
              cols={3}
              startL={9}
              colsL={4}
              startM={1}
              colsM={12}
            >
              <div className={classes.linkGroup}>
                {(links || []).map(({ link }, i) => {
                  return <CMSLink key={i} {...link} />;
                })}
              </div>
            </Cell>
          </Grid>
        </div>
      </BackgroundColor>
    </Gutter>
  );
};