mirror of
https://github.com/zhigang1992/react.git
synced 2026-03-26 06:55:07 +08:00
docs: support chinese
This commit is contained in:
@@ -1,15 +1,16 @@
|
||||
import React from 'react'
|
||||
import { Spacer, Code, useTheme } from 'components'
|
||||
import VirtualAnchor from 'lib/components/anchor'
|
||||
import { useConfigs } from 'lib/config-context'
|
||||
|
||||
export interface AttributesTitleProps {
|
||||
alias?: string
|
||||
}
|
||||
|
||||
const getAlias = (alias?: string) => {
|
||||
const getAlias = (isChinese: boolean, alias?: string, ) => {
|
||||
if (!alias) return null
|
||||
return (
|
||||
<small><span>[</span>alias: <Code>{alias}</Code><span>]</span></small>
|
||||
<small><span>[</span>{isChinese ? '别名' : 'alias'}: <Code>{alias}</Code><span>]</span></small>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -17,12 +18,13 @@ const AttributesTitle: React.FC<React.PropsWithChildren<AttributesTitleProps>> =
|
||||
children, alias,
|
||||
}) => {
|
||||
const theme = useTheme()
|
||||
const { isChinese } = useConfigs()
|
||||
|
||||
return (
|
||||
<>
|
||||
<h4 className="title">
|
||||
<Code><VirtualAnchor pure>{children}</VirtualAnchor></Code>
|
||||
{getAlias(alias)}
|
||||
{getAlias(!!isChinese, alias)}
|
||||
</h4>
|
||||
<Spacer y={.6} />
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import React, { useMemo } from 'react'
|
||||
import { Card, Link, Spacer, useTheme } from 'components'
|
||||
import AttributesTitle from './attributes-title'
|
||||
import VirtualAnchor from 'lib/components/anchor'
|
||||
import { useConfigs } from '../../config-context'
|
||||
|
||||
export interface AttributesProps {
|
||||
edit: string
|
||||
@@ -11,6 +12,7 @@ const Attributes: React.FC<React.PropsWithChildren<AttributesProps>> = React.mem
|
||||
edit, children,
|
||||
}) => {
|
||||
const theme = useTheme()
|
||||
const { isChinese } = useConfigs()
|
||||
const link = useMemo(() => {
|
||||
return `https://github.com/zeit-ui/react/blob/master${edit || '/pages'}`
|
||||
}, [])
|
||||
@@ -18,12 +20,14 @@ const Attributes: React.FC<React.PropsWithChildren<AttributesProps>> = React.mem
|
||||
return (
|
||||
<>
|
||||
<Spacer y={5} />
|
||||
<h3><VirtualAnchor>Attributes</VirtualAnchor></h3>
|
||||
<h3><VirtualAnchor>APIs</VirtualAnchor>{isChinese && ' / 接口文档'}</h3>
|
||||
<Card className="attr">
|
||||
{children}
|
||||
</Card>
|
||||
<Spacer y={1} />
|
||||
<Link color target="_blank" className="attributes-link" href={link} rel="nofollow">Edit this page on GitHub</Link>
|
||||
<Link color target="_blank" className="attributes-link" href={link} rel="nofollow">
|
||||
{isChinese ? '在 GitHub 上编辑此页面' : 'Edit this page on GitHub'}
|
||||
</Link>
|
||||
|
||||
<style global jsx>{`
|
||||
.attr table {
|
||||
|
||||
Reference in New Issue
Block a user