import React, { useState } from "react"; import { Flex, useColorMode, useTheme } 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 "~/components/FooterButton"; import FooterContent from "~/components/FooterContent"; format.extend(String.prototype, {}); const Footer = () => { const theme = useTheme(); const config = useConfig(); const { colorMode } = useColorMode(); const footerBg = { light: theme.colors.blackAlpha[50], dark: theme.colors.whiteAlpha[100] }; const footerColor = { light: theme.colors.black, dark: theme.colors.white }; const contentBorder = { light: theme.colors.blackAlpha[100], dark: theme.colors.whiteAlpha[200] }; const [helpVisible, showHelp] = useState(false); const [termsVisible, showTerms] = useState(false); const [creditVisible, showCredit] = useState(false); 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 || "/"; 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); } }; return ( <> {config.web.help_menu.enable && ( )} {config.web.terms.enable && ( )} {config.web.credit.enable && ( )} {config.web.terms.enable && ( handleCollapse("terms")}> {config.web.terms.title} )} {config.web.help_menu.enable && ( handleCollapse("help")}> {config.web.help_menu.title} )} {config.web.credit.enable && ( handleCollapse("credit")}> )} {config.web.external_link.enable && ( {config.web.external_link.title} )} ); }; Footer.displayName = "Footer"; export default Footer;