Skip to content

Commit

Permalink
[EuiDraggable] Convert child __item styles to Emotion
Browse files Browse the repository at this point in the history
- no theme tokens, so can be a static obj

+ remove 4 year old TODO that has never been added and probably isn't needed at this point
  • Loading branch information
cee-chen committed Sep 14, 2023
1 parent 47f5b09 commit 03341cc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ exports[`[React 18] EuiDraggable renders 1`] = `
tabindex="0"
>
<div
class="euiDraggable__item"
class="euiDraggable__item emotion-euiDraggable__item"
>
Hello
</div>
Expand Down
14 changes: 0 additions & 14 deletions src/components/drag_and_drop/_draggable.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,4 @@
&.euiDraggable--hasCustomDragHandle > .euiDraggable__item [data-react-beautiful-dnd-drag-handle]:focus {
@include euiFocusRing;
}

.euiDraggable__item {
&.euiDraggable__item--isDisabled {
cursor: not-allowed;
}

&.euiDraggable__item--isDragging {
// TODO: Resolve below
// Commenting this out for now,
// I'm thinking about adding an optional prop to auto-add these styles versus always having them
// @include euiBottomShadow;
// @include euiFocusRing;
}
}
}
7 changes: 7 additions & 0 deletions src/components/drag_and_drop/draggable.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,10 @@ export const euiDraggableStyles = (euiThemeContext: UseEuiTheme) => {
},
};
};

export const euiDraggableItemStyles = {
euiDraggable__item: css``,
disabled: css`
cursor: not-allowed;
`,
};
11 changes: 7 additions & 4 deletions src/components/drag_and_drop/draggable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,16 @@ import React, {
CSSProperties,
FunctionComponent,
ReactElement,
cloneElement,
useContext,
} from 'react';
import { Draggable, DraggableProps } from '@hello-pangea/dnd';
import classNames from 'classnames';

import { useEuiTheme } from '../../services';
import { useEuiTheme, cloneElementWithCss } from '../../services';
import { CommonProps } from '../common';

import { EuiDroppableContext } from './droppable';
import { euiDraggableStyles } from './draggable.styles';
import { euiDraggableStyles, euiDraggableItemStyles } from './draggable.styles';

const SPACINGS = ['none', 's', 'm', 'l'] as const;
export type EuiDraggableSpacing = (typeof SPACINGS)[number];
Expand Down Expand Up @@ -133,11 +132,15 @@ export const EuiDraggable: FunctionComponent<EuiDraggableProps> = ({
: provided.dragHandleProps?.tabIndex
}
>
{cloneElement(DraggableElement, {
{cloneElementWithCss(DraggableElement, {
className: classNames(
DraggableElement.props.className,
childClasses
),
css: [
euiDraggableItemStyles.euiDraggable__item,
isDragDisabled && euiDraggableItemStyles.disabled,
],
})}
</div>
{cloneItems && isDragging && (
Expand Down

0 comments on commit 03341cc

Please sign in to comment.