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

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

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

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

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>
            <GridItem xs={7}>
              <ImagePlaceholder
                type={ImagePlaceholderTypes.NONE}
                style={{
                  height: "100%",
                  backgroundColor: theme.foregroundColor,
                }}
              />
            </GridItem>
            <GridItem xs={5}>
              <Container style={{ padding: 100 }}>
                {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>
                )}
                <Text
                  name="Pre Headline"
                  id="pre_headline"
                  style={{
                    ...style.TEXT,
                    ...get(content, "pre_headline.style", {}),
                  }}
                >
                  To avoid conflicts it is recommended that business analysts
                  who understand the user requirements, create a basic wireframe
                  and then work with designers to further improve the
                  wireframes.
                  <br />
                  <br />
                  Modern UI design incorporates various devices such as
                  expanding panels, hover
                </Text>
              </Container>
            </GridItem>
          </Grid>
        </Container>
      </Section>
    </Block>
  );
};

export default Layout;
