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

Switch react-dnd to pragmatic drag and drop #3043

Merged
merged 11 commits into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,7 @@ updates:
patterns:
- "stylelint"
- "stylelint-config-*"
pragmatic-dnd:
patterns:
- "@atlaskit/pragmatic-drag-and-drop"
- "@atlaskit/pragmatic-drag-and-drop-*"
118 changes: 37 additions & 81 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"author": "Renée Kooi <[email protected]>",
"type": "module",
"dependencies": {
"@atlaskit/pragmatic-drag-and-drop": "^1.3.1",
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.3",
"@emotion/cache": "^11.6.0",
"@emotion/core": "^11.0.0",
"@emotion/react": "^11.13.3",
Expand Down Expand Up @@ -61,8 +63,6 @@
"react-abstract-autocomplete": "^2.0.3",
"react-async-hook": "^4.0.0",
"react-bus": "^3.0.0",
"react-dnd": "^16.0.0",
"react-dnd-html5-backend": "^16.0.0",
"react-dom": "^18.0.0",
"react-google-button": "^0.8.0",
"react-markdown": "^9.0.1",
Expand Down
1 change: 0 additions & 1 deletion src/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
@import url("./vars.css");
@import url("./components/index.css");
@import url("./sources/index.css");
@import url("./containers/DragLayer.css");
@import url("./mobile") (max-width: 768px);

/* None of our buttons have a use for browser defaults! */
Expand Down
12 changes: 1 addition & 11 deletions src/components/App/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import PropTypes from 'prop-types';
import { DndProvider } from 'react-dnd';
import { HTML5Backend } from 'react-dnd-html5-backend';
import FooterBar from '../FooterBar';
import HeaderBar from '../../containers/HeaderBar';
import Video from '../../containers/Video';
Expand All @@ -15,14 +13,13 @@ import ConnectionIndicator from '../ConnectionIndicator';
import SidePanels from '../SidePanels';
import Dialogs from '../Dialogs';
import AddToPlaylistMenu from '../../containers/AddToPlaylistMenu';
import DragLayer from '../../containers/DragLayer';

function App({
activeOverlay,
isConnected,
onCloseOverlay,
}) {
const el = (
return (
<div className="App">
<div className="AppColumn AppColumn--left">
<div className="AppRow AppRow--top">
Expand Down Expand Up @@ -53,15 +50,8 @@ function App({
<Dialogs />

<AddToPlaylistMenu />
<DragLayer />
</div>
);

return (
<DndProvider backend={HTML5Backend}>
{el}
</DndProvider>
);
}

App.propTypes = {
Expand Down
29 changes: 4 additions & 25 deletions src/components/MediaList/MediaDragPreview.tsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,14 @@
import { mdiFormatListBulleted } from '@mdi/js';
import SvgIcon from '../SvgIcon';
import type { Media } from '../../reducers/booth';

function getItemStyles(offset: { x: number, y: number } | null) {
if (offset != null) {
return {
display: 'inline-block',
transform: `translate(${offset.x}px, ${offset.y}px)`,
};
}
return { display: 'none' };
}

type MediaDragPreviewProps = {
items?: { media?: Media[] | null } | null,
currentOffset: { x: number, y: number } | null,
count: number,
};
function MediaDragPreview({
items,
currentOffset,
}: MediaDragPreviewProps) {
if (!items || !items.media) {
return null;
}
function MediaDragPreview({ count }: MediaDragPreviewProps) {
return (
<div
className="MediaDragPreview"
style={getItemStyles(currentOffset)}
>
<div className="MediaDragPreview">
<SvgIcon path={mdiFormatListBulleted} className="MediaDragPreview-icon" />
{items.media.length}
{count}
</div>
);
}
Expand Down
Loading