Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Emotion] Convert EuiDroppable & EuiDraggable #7187

Merged
merged 17 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions src/components/drag_and_drop/_droppable.scss
Original file line number Diff line number Diff line change
@@ -1,7 +0,0 @@

@include euiPanel($selector: '.euiDroppable--withPanel');

.euiDroppable--withPanel {
@include euiBottomShadowMedium;
border-radius: $euiBorderRadius;
}
23 changes: 16 additions & 7 deletions src/components/drag_and_drop/droppable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import classNames from 'classnames';

import { useEuiTheme } from '../../services';
import { CommonProps } from '../common';
import { EuiPanel } from '../panel';

import { EuiDragDropContextContext } from './drag_drop_context';
import { euiDroppableStyles } from './droppable.styles';
Expand Down Expand Up @@ -86,6 +87,15 @@ export const EuiDroppable: FunctionComponent<EuiDroppableProps> = ({
{(provided, snapshot) => {
const { isDraggingOver } = snapshot;

const PanelOrDiv = withPanel ? EuiPanel : 'div';
const panelOrDivProps = withPanel
? {
panelRef: provided.innerRef,
hasShadow: true,
paddingSize: 'none' as const,
}
: { ref: provided.innerRef };

Comment on lines +90 to +98
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Elegant refactor and use down on line 119!

const cssStyles = [
styles.euiDroppable,
isDraggingType === type && !dropIsDisabled && styles.isDragging,
Expand All @@ -96,20 +106,19 @@ export const EuiDroppable: FunctionComponent<EuiDroppableProps> = ({

const classes = classNames(
'euiDroppable',
{
'euiDroppable--isDisabled': dropIsDisabled,
'euiDroppable--withPanel': withPanel,
},
{ 'euiDroppable--isDisabled': dropIsDisabled },
className
);

const DroppableElement =
typeof children === 'function'
? children(provided, snapshot)
: children;

return (
<div
<PanelOrDiv
{...provided.droppableProps}
ref={provided.innerRef}
{...panelOrDivProps}
style={style}
data-test-subj={dataTestSubj}
className={classes}
Expand All @@ -125,7 +134,7 @@ export const EuiDroppable: FunctionComponent<EuiDroppableProps> = ({
<div className="euiDroppable__placeholder" hidden={cloneDraggables}>
{provided.placeholder}
</div>
</div>
</PanelOrDiv>
);
}}
</Droppable>
Expand Down