import React, { FC, useContext } from 'react'; import classNames from 'classnames'; import { ContentButtonProps, createButton } from '../button/button'; import Space from '../space'; import { ConfigContext } from '../config-provider'; export interface PageActionsProps { /** 页面的主要操作,支持所有 Button 属性 */ primaryAction?: ContentButtonProps; /** 页面的辅助操作数组,支持所有 Button 属性 */ secondaryActions?: ContentButtonProps[]; } const PageActions: FC = ({ primaryAction, secondaryActions = [] }) => { const { getPrefixCls } = useContext(ConfigContext); const prefixCls = getPrefixCls('page-actions'); const primaryActionMarkup = primaryAction ? createButton(primaryAction, { type: 'primary' }) : null; const secondaryActionsMarkup = secondaryActions.length > 0 ? ( {secondaryActions.map((item, index) => ( // eslint-disable-next-line react/no-array-index-key {createButton(item, { danger: true, type: 'primary' })} ))} ) : null; return (
{secondaryActionsMarkup} {primaryActionMarkup}
); }; export default PageActions;