Skip to content

Commit

Permalink
chore(react): improve theme styles
Browse files Browse the repository at this point in the history
  • Loading branch information
janryWang committed Oct 4, 2021
1 parent 10092b1 commit 51a0fde
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 34 deletions.
20 changes: 9 additions & 11 deletions formily/antd/src/components/FormGrid/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,15 @@ export const FormGrid: DnFC<React.ComponentProps<formilyGrid>> & {

FormGrid.GridColumn = observer((props) => {
return (
<DroppableWidget>
<div
{...props}
data-span={props.gridSpan}
style={{
...props['style'],
gridColumnStart: `span ${props.gridSpan || 1}`,
}}
>
{props.children}
</div>
<DroppableWidget
{...props}
data-span={props.gridSpan}
style={{
...props['style'],
gridColumnStart: `span ${props.gridSpan || 1}`,
}}
>
{props.children}
</DroppableWidget>
)
})
Expand Down
20 changes: 9 additions & 11 deletions formily/next/src/components/FormGrid/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,15 @@ export const FormGrid: DnFC<React.ComponentProps<formilyGrid>> & {

FormGrid.GridColumn = observer((props) => {
return (
<DroppableWidget>
<div
{...props}
data-span={props.gridSpan}
style={{
...props['style'],
gridColumnStart: `span ${props.gridSpan || 1}`,
}}
>
{props.children}
</div>
<DroppableWidget
{...props}
data-span={props.gridSpan}
style={{
...props['style'],
gridColumnStart: `span ${props.gridSpan || 1}`,
}}
>
{props.children}
</DroppableWidget>
)
})
Expand Down
33 changes: 23 additions & 10 deletions packages/react/src/widgets/DroppableWidget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,42 @@ import { TreeNode } from '@designable/core'
import { observer } from '@formily/reactive-react'
import { useTreeNode, useNodeIdProps } from '../../hooks'
import { NodeTitleWidget } from '../NodeTitleWidget'
import cls from 'classnames'
import {
NodeActionsWidget,
INodeActionsWidgetActionProps,
} from '../NodeActionsWidget'
import './styles.less'

export interface IDroppableWidgetProps {
node?: TreeNode
actions?: INodeActionsWidgetActionProps[]
height?: number
style?: React.CSSProperties
className?: string
}

export const DroppableWidget: React.FC<IDroppableWidgetProps> = observer(
(props) => {
({ node, actions, height, style, className, ...props }) => {
const currentNode = useTreeNode()
const nodeId = useNodeIdProps(props.node)
const target = props.node ?? currentNode
const nodeId = useNodeIdProps(node)
const target = node ?? currentNode
const hasChildren = target.children?.length > 0
return (
<div
{...nodeId}
style={{ ...props.style, minHeight: props.height }}
className={cls(hasChildren ? '' : 'dn-droppable', props.className)}
>
{hasChildren ? props.children : <NodeTitleWidget node={target} />}
<div {...nodeId} className={className} style={style}>
{hasChildren ? (
props.children
) : (
<div style={{ height }} className="dn-droppable-placeholder">
<NodeTitleWidget node={target} />
</div>
)}
{actions?.length ? (
<NodeActionsWidget>
{actions.map((action, key) => (
<NodeActionsWidget.Action {...action} key={key} />
))}
</NodeActionsWidget>
) : null}
</div>
)
}
Expand Down
3 changes: 1 addition & 2 deletions packages/react/src/widgets/DroppableWidget/styles.less
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
.dn-droppable {
.dn-droppable-placeholder {
min-height: 60px;
background-color: var(--dn-droppable-bg-color);
border: 1px dashed var(--dn-droppable-border-color);
margin: 2px 0;
display: flex;
align-items: center;
justify-content: center;
Expand Down

0 comments on commit 51a0fde

Please sign in to comment.