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

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

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

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

import {
  Block,
  Section,
  Headline,
  Text,
  Container,
  Button,
  Grid,
  GridItem,
  ListItem,
  ShareButton,
} from "@sc/plugins/webcomponents/v2";
import { VideoPlaceholder } from "../../Placeholders";
import { IconTypes } from "@sc/plugins/webcomponents/v2/Icon";
import { IconSource } from "@sc/plugins/webcomponents/v2/Icon/types";
import { ShareButtonTypes } from "@sc/plugins/webcomponents/v2/ShareButton/types";
import {
  faFacebookF,
  faTwitter,
  faReddit,
} from "@fortawesome/free-brands-svg-icons";

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"),
          }}
        >
          <Headline style={style.HEADLINE}>Headline Goes Here</Headline>
          <Grid spacing={2} style={{ marginTop: 40 }}>
            <GridItem xs>
              <VideoPlaceholder
                style={{
                  backgroundColor: theme.foregroundColor,
                  color: theme.backgroundColor,
                }}
              />
              <Grid spacing={0} style={{ marginTop: 10, textAlign: "center" }}>
                <GridItem xs={4}>
                  <ShareButton
                    type={ShareButtonTypes.FACEBOOK}
                    url="http://google.com"
                  >
                    {() => (
                      <Button
                        style={style.BUTTON.style}
                        caption1="Share on Facebook"
                        caption1style={style.BUTTON.caption1}
                        icon={faFacebookF}
                        iconSource={IconSource.FONTAWESOME}
                        iconStyle={style.BUTTON.iconStyle}
                      />
                    )}
                  </ShareButton>
                </GridItem>
                <GridItem xs={4}>
                  <ShareButton
                    type={ShareButtonTypes.TWITTER}
                    url="http://google.com"
                  >
                    {() => (
                      <Button
                        style={style.BUTTON.style}
                        caption1="Share on Twitter"
                        caption1style={style.BUTTON.caption1}
                        icon={faTwitter}
                        iconSource={IconSource.FONTAWESOME}
                        iconStyle={style.BUTTON.iconStyle}
                      />
                    )}
                  </ShareButton>
                </GridItem>
                <GridItem xs={4}>
                  <ShareButton
                    type={ShareButtonTypes.REDDIT}
                    url="http://google.com"
                  >
                    {() => (
                      <Button
                        style={style.BUTTON.style}
                        caption1="Share on Reddit"
                        caption1style={style.BUTTON.caption1}
                        icon={faReddit}
                        iconSource={IconSource.FONTAWESOME}
                        iconStyle={style.BUTTON.iconStyle}
                      />
                    )}
                  </ShareButton>
                </GridItem>
              </Grid>
            </GridItem>
            <GridItem xs={4}>
              <Container
                style={{
                  border: `1px solid ${theme.foregroundColor}`,
                  borderRadius: 5,
                  padding: 5,
                }}
              >
                <Headline
                  style={{
                    ...style.HEADLINE,
                    marginTop: -20,
                    fontSize: "18pt",
                    color: theme.backgroundColor,
                  }}
                >
                  <span
                    style={{
                      backgroundColor: theme.foregroundColor,
                      padding: 10,
                    }}
                  >
                    Downloads
                  </span>
                </Headline>
                <ListItem
                  icon={IconTypes.PictureAsPdf}
                  iconSource={IconSource.MATERIAL}
                  iconStyle={{
                    fontSize: "28pt",
                    padding: 15,
                    color: theme.foregroundColor,
                  }}
                >
                  <Text
                    style={{
                      ...style.TEXT,
                      fontWeight: "bold" as "bold",
                      paddingTop: 20,
                    }}
                  >
                    Value creation worksheet
                  </Text>
                  <Text style={{ ...style.TEXT }}>
                    {lorem.generateParagraphs(1)}
                  </Text>
                </ListItem>
              </Container>
            </GridItem>
          </Grid>
        </Container>
      </Section>
    </Block>
  );
};

export default Layout;
