Skip to content

Commit

Permalink
feat: control empty DropZone height with minEmptyHeight prop
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvxd committed Nov 20, 2024
1 parent 41294a5 commit 342105e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
11 changes: 9 additions & 2 deletions packages/core/components/DropZone/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
CSSProperties,
useCallback,
useContext,
useEffect,
Expand Down Expand Up @@ -39,6 +40,7 @@ function DropZoneEdit({
disallow,
style,
className,
minEmptyHeight = 128,
dragRef,
collisionAxis,
}: DropZoneProps) {
Expand Down Expand Up @@ -237,7 +239,7 @@ function DropZoneEdit({
hoveringOverArea,
isEnabled,
isAreaSelected,
hasChildren: contentWithPreview.length > 0,
hasChildren: content.length > 0,
})}${className ? ` ${className}` : ""}`}
ref={(node) => {
ref.current = node;
Expand All @@ -246,7 +248,12 @@ function DropZoneEdit({

if (dragRef) dragRef(node);
}}
style={style}
style={
{
...style,
"--min-empty-height": `${minEmptyHeight}px`,
} as CSSProperties
}
>
{isRootZone && DEBUG && (
<>
Expand Down
4 changes: 2 additions & 2 deletions packages/core/components/DropZone/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

position: relative;
height: 100%;
min-height: 128px;
min-height: var(--min-empty-height);
outline-offset: -2px;
width: 100%;
}
Expand All @@ -14,7 +14,7 @@
}

.DropZone:empty {
min-height: 128px;
min-height: var(--min-empty-height);
}

.DropZone--hasChildren:not(.DropZone--userIsDragging) {
Expand Down
1 change: 1 addition & 0 deletions packages/core/components/DropZone/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export type DropZoneProps = {
allow?: string[];
disallow?: string[];
style?: CSSProperties;
minEmptyHeight?: number;
className?: string;
dragRef?: ((element: Element | null) => void) | null;
collisionAxis?: DragAxis;
Expand Down

0 comments on commit 342105e

Please sign in to comment.