Skip to content

Commit

Permalink
🐛 fix: build (#12)
Browse files Browse the repository at this point in the history
Co-authored-by: jiangchu <jiangchu.wzy@antgroup.com>
  • Loading branch information
ModestFun and jiangchu authored Sep 18, 2023
1 parent 375e934 commit 8638e59
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 60 deletions.
2 changes: 1 addition & 1 deletion src/BloodNode/demos/DataViewList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const NodeList = memo(() => {
<div className={cx(styles.container)}>
{nodeList.map((item) => {
return (
<BloodNode.Preview
<BloodNode
key={item.title}
className={styles.node}
title={item.title}
Expand Down
82 changes: 23 additions & 59 deletions src/BloodNode/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { NODE_DANGER, NODE_SELECT, NODE_WARNING, NodeSelect } from '@/ProFlow/constants';
import { ConfigProvider } from 'antd';
import { CSSProperties, ReactNode, memo, useRef } from 'react';
import React from 'react';
import { useStyles } from './styles';

interface BloodNodeProps {
Expand All @@ -27,63 +26,28 @@ export function getClsFromSelectType(select: NodeSelect) {
}
}

export interface BloodNodePreviewProps extends BloodNodeProps {
/**
* 是否激活状态
*/
active?: boolean;
/**
* 自定义样式
*/
style?: CSSProperties;
/**
* 自定义样式
*/
onClick?: () => void;
}

const Preview = memo<Partial<BloodNodePreviewProps>>(
({ title, logo, description, className, selectType = NodeSelect.SELECT }) => {
const { styles, cx } = useStyles();
const cardRef = useRef<HTMLDivElement>(null);

return (
<ConfigProvider
// 不这样做会导致 select 的下拉菜单被遮挡,并且不会正常放大缩小
getPopupContainer={() => {
return cardRef.current || document.body;
}}
>
{/* <Card ref={cardRef} title={title} className={} style={style}>
{children}
</Card> */}
<div className={cx(styles.nodeWrap, styles[getClsFromSelectType(selectType)], className)}>
<img className={'img'} src={logo} alt="" />
<div className={'content'}>
<div className={'title'}>
<span>{title}</span>
{/* {mainDanger && <DangerLogo />}
{qualityScore && <ApiScore score={parseFloat(qualityScore)} />} */}
</div>
<div className={'des'}>{description}</div>
</div>
const BloodNode: React.FC<Partial<BloodNodeProps>> = ({
title,
logo,
description,
className,
selectType = NodeSelect.SELECT,
}) => {
const { styles, cx } = useStyles();

return (
<div className={cx(styles.nodeWrap, styles[getClsFromSelectType(selectType)], className)}>
<img className={'img'} src={logo} alt="" />
<div className={'content'}>
<div className={'title'}>
<span>{title}</span>
{/* {mainDanger && <DangerLogo />}
{qualityScore && <ApiScore score={parseFloat(qualityScore)} />} */}
</div>
</ConfigProvider>
);
},
);

const Default = memo<BloodNodeProps>(({ ...props }) => {
return <Preview {...props} />;
}) as (props: BloodNodePreviewProps) => JSX.Element;

interface IBloodNode {
(props: BloodNodeProps): ReactNode;
Preview: typeof Preview;
}

const BloodNode = Default as IBloodNode;

BloodNode.Preview = Preview;
<div className={'des'}>{description}</div>
</div>
</div>
);
};

export default BloodNode;

0 comments on commit 8638e59

Please sign in to comment.