feat:Nav组件label支持render渲染 (#2583)

Co-authored-by: qinhaoyan <qinhaoyan@baidu.com>
This commit is contained in:
qinhaoyan 2021-09-18 16:21:10 +08:00 committed by GitHub
parent 32747910f8
commit 2c6eae17d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,7 +14,7 @@ import {
import {ScopedContext, IScopedContext} from '../Scoped';
import {themeable, ThemeProps} from '../theme';
import {Icon} from '../components/icons';
import {BaseSchema, SchemaApi, SchemaIcon, SchemaUrlPath} from '../Schema';
import {BaseSchema, SchemaApi, SchemaIcon, SchemaUrlPath, SchemaCollection} from '../Schema';
import {generateIcon} from '../utils/icon';
import {
RemoteOptionsProps,
@ -27,7 +27,7 @@ export type NavItemSchema = {
/**
*
*/
label?: string;
label?: string | SchemaCollection;
/**
* fontawesome 4
@ -85,7 +85,7 @@ export interface NavSchema extends BaseSchema {
export interface Link {
className?: string;
label?: string;
label?: string | SchemaCollection;
to?: string;
target?: string;
icon?: string;
@ -113,6 +113,7 @@ export interface NavigationProps
togglerClassName?: string;
links?: Array<Link>;
loading?: boolean;
render: RendererProps['render']
}
export class Navigation extends React.Component<
@ -157,7 +158,11 @@ export class Navigation extends React.Component<
style={{paddingLeft: depth * (parseInt(indentSize as any, 10) ?? 24)}}
>
{generateIcon(cx, link.icon, 'Nav-itemIcon')}
{link.label}
{
link.label && (typeof link.label === 'string'
? link.label
: this.props.render('inline', link.label as SchemaCollection))
}
</a>
{link.loading ? (