-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat(Data Mapper): Drag functions onto canvas (#5001)
* getting drop coordinates * creating new fn node * drag function works * styling * button styling * PR improvements * placing nodes works * node position improvements * fixed import * build passes * tests pass
- Loading branch information
1 parent
1f82ee6
commit ccf276f
Showing
20 changed files
with
758 additions
and
505 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
libs/data-mapper-v2/src/components/common/reactflow/FunctionNode.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { customTokens } from '../../../core'; | ||
import type { FunctionData } from '../../../models'; | ||
import { FunctionIcon } from '../../functionIcon/FunctionIcon'; | ||
import { Button, Caption1, tokens } from '@fluentui/react-components'; | ||
import { useCardContextMenu } from '@microsoft/designer-ui'; | ||
|
||
import type { NodeProps } from 'reactflow'; | ||
import { useStyles } from './styles'; | ||
import { getFunctionBrandingForCategory } from '../../../utils/Function.Utils'; | ||
|
||
export interface FunctionCardProps extends CardProps { | ||
functionData: FunctionData; | ||
dataTestId: string; | ||
} | ||
|
||
export interface CardProps { | ||
onClick?: () => void; | ||
displayHandle: boolean; | ||
disabled: boolean; | ||
} | ||
|
||
export const FunctionNode = (props: NodeProps<FunctionCardProps>) => { | ||
const { functionData, disabled, onClick, dataTestId } = props.data; | ||
const styles = useStyles(); | ||
const fnBranding = getFunctionBrandingForCategory(functionData.category); | ||
|
||
const contextMenu = useCardContextMenu(); | ||
|
||
return ( | ||
<div onContextMenu={contextMenu.handle} data-testid={dataTestId}> | ||
<Button onClick={onClick} disabled={!!disabled} className={styles.functionButton}> | ||
<div className={styles.iconContainer} style={{ backgroundColor: customTokens[fnBranding.colorTokenName] }}> | ||
<FunctionIcon | ||
iconSize={11} | ||
functionKey={functionData.key} | ||
functionName={functionData.functionName} | ||
categoryName={functionData.category} | ||
color={tokens.colorNeutralForegroundInverted} | ||
/> | ||
</div> | ||
<Caption1 className={styles.functionName} truncate block> | ||
{functionData.displayName} | ||
</Caption1> | ||
</Button> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.