import * as React from "react"; import { useState } from "react"; import { Flex, useColorMode } from "@chakra-ui/core"; import { FiCode } from "react-icons/fi"; import { GoLinkExternal } from "react-icons/go"; import format from "string-format"; import useConfig from "~/components/HyperglassProvider"; import FooterButton from "./FooterButton"; import FooterContent from "./FooterContent"; format.extend(String.prototype, {}); const footerBg = { light: "blackAlpha.50", dark: "whiteAlpha.100" }; const footerColor = { light: "black", dark: "white" }; const contentBorder = { light: "blackAlpha.100", dark: "whiteAlpha.200" }; const Footer = () => { const config = useConfig(); const { colorMode } = useColorMode(); const [helpVisible, showHelp] = useState(false); const [termsVisible, showTerms] = useState(false); const [creditVisible, showCredit] = useState(false); const handleCollapse = i => { if (i === "help") { showTerms(false); showCredit(false); showHelp(!helpVisible); } else if (i === "credit") { showTerms(false); showHelp(false); showCredit(!creditVisible); } else if (i === "terms") { showHelp(false); showCredit(false); showTerms(!termsVisible); } }; const extUrl = config.web.external_link.url.includes("{primary_asn}") ? config.web.external_link.url.format({ primary_asn: config.primary_asn }) : config.web.external_link.url || "/"; return ( <> {config.web.help_menu.enable && ( )} {config.web.terms.enable && ( )} {config.web.credit.enable && ( )} {config.web.terms.enable && ( handleCollapse("terms")} aria-label={config.web.terms.title} > {config.web.terms.title} )} {config.web.help_menu.enable && ( handleCollapse("help")} aria-label={config.web.help_menu.title} > {config.web.help_menu.title} )} {config.web.credit.enable && ( handleCollapse("credit")} aria-label="Powered by hyperglass" > )} {config.web.external_link.enable && ( {config.web.external_link.title} )} ); }; export default Footer;