import * as React from "react";
import { get } from "lodash";
import Icon from "@material-ui/core/Icon";

import { style } from "./style";
import { default as defaultData } from "./data.json";

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

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

import { ImagePlaceholder, ImagePlaceholderTypes } from "../../Placeholders";
import theme from "../../theme";

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"),
          }}
        >
          <Container
            style={{
              maxWidth: 700,
              margin: "0 auto",
              textAlign: "center",
              padding: 50,
            }}
          >
            {doIShow(content, "pre_headline") && (
              <Headline
                name="Pre Headline"
                id="pre_headline"
                style={{
                  ...style.PRE_HEADLINE,
                  ...get(content, "pre_headline.style", {}),
                }}
              >
                {get(content, "pre_headline.html", "...")}
              </Headline>
            )}
            {doIShow(content, "main_headline") && (
              <Headline
                name="Main Headline"
                id="main_headline"
                style={{
                  ...style.HEADLINE,
                  ...get(content, "main_headline.style", {}),
                }}
              >
                {get(content, "main_headline.html", "...")}
              </Headline>
            )}
            {doIShow(content, "cta_button") && (
              <Button
                style={style.BUTTON.style}
                caption1="Get Started asd asd"
                caption1style={style.BUTTON.caption1}
              />
            )}
          </Container>
          <Grid spacing={5} style={{ textAlign: "left", marginTop: 150 }}>
            <GridItem xs={4}>
              <Grid spacing={2}>
                <GridItem xs={3}>
                  <Icon style={style.ICON}>more</Icon>
                </GridItem>
                <GridItem xs={9}>
                  <Text
                    style={{
                      ...style.TEXT,
                      textAlign: "left",
                      fontWeight: "bold" as "bold",
                      padding: 0,
                      paddingBottom: 10,
                    }}
                  >
                    Feature
                  </Text>
                  <Text
                    style={{ ...style.TEXT, textAlign: "left", padding: 0 }}
                  >
                    It's true.  asd ad Getting results is much easier than you think
                  </Text>
                </GridItem>
              </Grid>
            </GridItem>
            <GridItem xs={4}>
              <Grid spacing={2}>
                <GridItem xs={3}>
                  <Icon style={style.ICON}>more</Icon>
                </GridItem>
                <GridItem xs={9}>
                  <Text
                    style={{
                      ...style.TEXT,
                      textAlign: "left",
                      fontWeight: "bold" as "bold",
                      padding: 0,
                      paddingBottom: 10,
                    }}
                  >
                    Feature
                  </Text>
                  <Text
                    style={{ ...style.TEXT, textAlign: "left", padding: 0 }}
                  >
                    It's true. Getting results is much easier than you think
                  </Text>
                </GridItem>
              </Grid>
            </GridItem>
            <GridItem xs={4}>
              <Grid spacing={2}>
                <GridItem xs={3}>
                  <Icon style={style.ICON}>more</Icon>
                </GridItem>
                <GridItem xs={9}>
                  <Text
                    style={{
                      ...style.TEXT,
                      textAlign: "left",
                      fontWeight: "bold" as "bold",
                      padding: 0,
                      paddingBottom: 10,
                    }}
                  >
                    Feature
                  </Text>
                  <Text
                    style={{ ...style.TEXT, textAlign: "left", padding: 0 }}
                  >
                    It's true. Getting results is much easier than you think
                  </Text>
                </GridItem>
              </Grid>
            </GridItem>
          </Grid>
        </Container>
      </Section>
    </Block>
  );
};

export default Layout;
