UNPKG

@ovine/core

Version:

Build flexible admin system with json.

28 lines (27 loc) 1.19 kB
/** * App头部工具 ICON 按钮 */ import React, { cloneElement } from 'react'; import { withAppTheme } from "../../app/theme"; import { jumpTo, JumpToOption } from "../../routes/exports"; import { Amis } from "../amis/schema"; export default withAppTheme((props) => { const { itemProps, theme, classPrefix } = props; const ns = theme.ns || classPrefix; const { className = '', icon, faIcon, children, onClick, href, blank, origin, replace, tip, body, } = itemProps; const onItemClick = (e) => { if (href) { jumpTo(href, { blank, origin, replace }); } if (onClick) { onClick(e); } }; return (React.createElement("div", { className: `${ns}Button ${className} ${ns}Button--blank ${ns}Button--iconOnly`, onClick: onItemClick }, !icon && !faIcon ? null : (React.createElement("i", { className: `${icon || `fa fa-${faIcon}`}`, "data-position": "bottom", "data-tooltip": tip })), children && (!tip ? children : cloneElement(children, { 'data-tooltip': tip, 'data-position': 'bottom' })), body && React.createElement(Amis, { schema: body }))); });