import {
Button,
ButtonProps,
Link,
useColorModeValue,
Wrap,
} from '@chakra-ui/react'
import React from 'react'
import { FaGithub, FaNpm, FaYoutube } from 'react-icons/fa'
import { t } from 'utils/i18n'
import StorybookIcon from '../storybook-icon'
type ComponentLinkProps = ButtonProps & {
icon: React.ElementType
url: string
iconSize?: string
iconColor?: string
}
function ComponentLink(props: ComponentLinkProps) {
const { icon: BtnIcon, url, children, iconSize, iconColor, ...rest } = props
return (
}
sx={{
'& span': {
width: iconSize,
},
'& svg': {
color: iconColor,
width: 'full',
height: 'auto',
},
}}
{...rest}
>
{children}
)
}
export type ComponentLinksProps = {
theme?: { componentName: string }
github?: { url?: string; package?: string }
npm?: { package: string }
storybook?: { url: string }
video?: { url: string }
}
function ComponentLinks(props: ComponentLinksProps) {
const { theme, github, npm, storybook, video, ...rest } = props
const iconColor = useColorModeValue('gray.600', 'inherit')
const githubRepoUrl = 'https://github.com/chakra-ui/chakra-ui'
const githubLink = (github?.url || github?.package) && (
{t('component.mdx-components.component-links.view-source')}
)
const npmLink = npm?.package && (
{npm.package}
)
// Note: Currently an unused component
const storybookLink = storybook?.url && (
{t('component.mdx-components.component-links.view-storybook')}
)
// Note: Currently an unused component
const videoLink = video?.url && (
{t('component.mdx-components.component-links.view-video')}
)
const themeComponentLink = theme && (
{t('component.mdx-components.component-links.view-theme-source')}
)
return (
{githubLink}
{themeComponentLink}
{npmLink}
{storybookLink}
{videoLink}
)
}
export default ComponentLinks