import React, { type FC, useMemo } from 'react';
import {
Container,
Text,
Center,
HStack,
Button,
Image,
Icon
} from '@chakra-ui/react';
import { VscGithub as Github } from 'react-icons/vsc';
import { SiDiscord as Discord } from 'react-icons/si';
import HeroTitle from '../HeroTitle';
import { Link } from 'dumi';
import useHero from '../../hooks/useHero';
import { isOutLink, isEmpty } from '../../factory/tools';
export type HeroConfig = {
/**
* @description whether show version badge
* @description.zh-CN 是否展示版本标签
*/
showVersionBadge?: boolean;
};
const icons = {
github: ,
discord:
};
const ActionLeftIcon: FC<{ icon: string }> = ({ icon }) =>
// @ts-ignore
icons[icon] ?? ;
const Hero: FC = () => {
const { config, ...hero } = useHero();
const { actions, description } = hero ?? {};
const showActionButtons = useMemo(() => {
return !!actions?.length;
}, [actions]);
if (isEmpty(hero)) return null;
return (
{description}
{showActionButtons && (
{actions!.map(({ icon, text, link }, index) => {
const ActionButton = (
: undefined}
mb="var(--chakra-space-2)!important"
>
{text}
);
if (link) {
return isOutLink(link) ? (
{ActionButton}
) : (
{ActionButton}
);
}
return ActionButton;
})}
)}
);
};
export default Hero;