import React from "react"; import { Button, Heading, Image, Stack, useColorMode } from "@chakra-ui/core"; import { Textfit } from "react-textfit"; import { motion, AnimatePresence } from "framer-motion"; import useConfig from "~/components/HyperglassProvider"; import useMedia from "~/components/MediaProvider"; const subtitleAnimation = { transition: { duration: 0.2, type: "tween" }, initial: { opacity: 1, scale: 1 }, animate: { opacity: 1, scale: 1 }, exit: { opacity: 0, scale: 0.3 } }; const titleSize = { true: "2xl", false: "lg" }; const titleMargin = { true: 2, false: 0 }; const textAlignment = { false: ["right", "center"], true: ["left", "center"] }; const TitleOnly = ({ text, showSubtitle }) => ( {text} ); const SubtitleOnly = React.forwardRef( ({ text, mediaSize, size = "md", ...props }, ref) => ( {text} ) ); const AnimatedSubtitle = motion.custom(SubtitleOnly); const TextOnly = ({ text, mediaSize, showSubtitle, ...props }) => ( {showSubtitle && ( )} ); const Logo = ({ text, logo, showSubtitle }) => { const { colorMode } = useColorMode(); const logoColor = { light: logo.dark, dark: logo.light }; const logoPath = logoColor[colorMode]; return {text.title}; }; const LogoSubtitle = ({ text, logo, showSubtitle, mediaSize }) => ( <> {showSubtitle && ( )} ); const All = ({ text, logo, mediaSize, showSubtitle }) => ( <> ); const modeMap = { text_only: TextOnly, logo_only: Logo, logo_subtitle: LogoSubtitle, all: All }; const justifyMap = { true: ["flex-end", "center", "center", "center"], false: ["flex-start", "center", "center", "center"] }; const Title = React.forwardRef(({ onClick, isSubmitting, ...props }, ref) => { const { web } = useConfig(); const { mediaSize } = useMedia(); const titleMode = web.text.title_mode; const MatchedMode = modeMap[titleMode]; return ( ); }); Title.displayName = "Title"; export default Title;