import * as React from "react";
import { get, startCase, uniqueId } from "lodash";

import { style } from "./style";
import { default as defaultData } from "./data.json";
import { ImagePlaceholder, ImagePlaceholderTypes } from "../../Placeholders";

import { doIShow, combineData, lorem } from "../../utils";

import theme from "../../theme";

import {
  Block,
  Section,
  Headline,
  Text,
  Container,
  Button,
  Grid,
  GridItem,
} from "@sc/plugins/webcomponents/v2";

type LayoutProps = {
  data: any;
};

const Layout: React.FC<LayoutProps> = ({ data }) => {
  const initialContent = {
    main_headline: {
      html: "Headline Goes Here",
    },
    sub_headline: {
      html: "Sub Headline Text Content Goes Here",
    },
  };

  const content = combineData(initialContent, defaultData, data);

  return (
    <Block>
      <Section style={style.SECTION}>
        <Container
          style={{
            ...style.SECTION_INNER,
            maxWidth: get(data, "section.pageMargin"),
          }}
        >
          <Grid spacing={5}>
            <GridItem xs={4}>
              <ImagePlaceholder
                type={ImagePlaceholderTypes.NONE}
                style={{ backgroundColor: theme.backgroundColor }}
              />
            </GridItem>
            <GridItem xs={8}>
              <Headline style={style.HEADLINE}>
                Free Download: {startCase(lorem.generateWords(4))}
              </Headline>
              <Headline style={style.SUBHEADLINE}>
                How to {startCase(lorem.generateWords(12))}
              </Headline>
              <Button
                style={{ ...style.BUTTON.style, marginTop: 40 }}
                caption1="DOWNLOAD NOW"
                caption1style={style.BUTTON.caption1}
              />
              <Text style={{ ...style.TEXT, fontSize: "10pt" }}>
                {lorem.generateSentences(1)}
              </Text>
            </GridItem>
          </Grid>
        </Container>
      </Section>
    </Block>
  );
};

export default Layout;
