-
-
Notifications
You must be signed in to change notification settings - Fork 633
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(settings): move NodePath to NodePathWidget
- Loading branch information
Showing
6 changed files
with
61 additions
and
53 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: 0 additions & 47 deletions
47
packages/react-settings-form/src/components/NodePath/index.tsx
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import React from 'react' | ||
import { Breadcrumb } from 'antd' | ||
import { useCurrentNode, useSelection, usePrefix, useHover } from '../../hooks' | ||
import { IconWidget } from '../IconWidget' | ||
import { TextWidget } from '../TextWidget' | ||
import { observer } from '@formily/react' | ||
import './styles.less' | ||
|
||
export interface INodePathWidgetProps { | ||
workspaceId?: string | ||
maxItems?: number | ||
} | ||
|
||
export const NodePathWidget: React.FC<INodePathWidgetProps> = observer( | ||
(props) => { | ||
const selected = useCurrentNode(props.workspaceId) | ||
const selection = useSelection(props.workspaceId) | ||
const hover = useHover(props.workspaceId) | ||
const prefix = usePrefix('node-path') | ||
if (!selected) return <React.Fragment /> | ||
const maxItems = props.maxItems ?? 3 | ||
const nodes = selected | ||
.getParents() | ||
.slice(0, maxItems - 1) | ||
.reverse() | ||
.concat(selected) | ||
return ( | ||
<Breadcrumb className={prefix}> | ||
{nodes.map((node, key) => { | ||
return ( | ||
<Breadcrumb.Item key={key}> | ||
{key === 0 && ( | ||
<IconWidget infer="Position" style={{ marginRight: 3 }} /> | ||
)} | ||
<a | ||
href="" | ||
onMouseEnter={() => { | ||
hover.setHover(node) | ||
}} | ||
onClick={(e) => { | ||
e.stopPropagation() | ||
e.preventDefault() | ||
selection.select(node) | ||
}} | ||
> | ||
<TextWidget>{node.designerProps.title}</TextWidget> | ||
</a> | ||
</Breadcrumb.Item> | ||
) | ||
})} | ||
</Breadcrumb> | ||
) | ||
} | ||
) |
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