forked from M-Labs/web2019
Try make wrappers
Signed-off-by: Egor Savkin <es@m-labs.hk>
This commit is contained in:
parent
5c65815f76
commit
448cf9c29a
|
@ -1,6 +1,5 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
//import {Droppable} from "@hello-pangea/dnd";
|
import {Droppable} from './dnd/Droppable';
|
||||||
import {useDroppable} from '@dnd-kit/core';
|
|
||||||
import {ProductItem} from "./ProductItem";
|
import {ProductItem} from "./ProductItem";
|
||||||
import {useShopStore} from "./shop_store";
|
import {useShopStore} from "./shop_store";
|
||||||
// #!render_count
|
// #!render_count
|
||||||
|
@ -18,10 +17,6 @@ export function Backlog() {
|
||||||
const onClickToggleMobileSideMenu = useShopStore((state) => state.switchSideMenu);
|
const onClickToggleMobileSideMenu = useShopStore((state) => state.switchSideMenu);
|
||||||
const isMobile = useShopStore((state) => state.isMobile);
|
const isMobile = useShopStore((state) => state.isMobile);
|
||||||
|
|
||||||
const {setNodeRef} = useDroppable({
|
|
||||||
id: data.id,
|
|
||||||
});
|
|
||||||
|
|
||||||
// #!render_count
|
// #!render_count
|
||||||
console.log("Backlog renders: ", renderCount)
|
console.log("Backlog renders: ", renderCount)
|
||||||
|
|
||||||
|
@ -57,7 +52,9 @@ export function Backlog() {
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div ref={setNodeRef}>
|
<Droppable
|
||||||
|
droppableId={data.id}
|
||||||
|
isDropDisabled={false}>
|
||||||
|
|
||||||
{(provided) => (
|
{(provided) => (
|
||||||
<div
|
<div
|
||||||
|
@ -85,7 +82,7 @@ export function Backlog() {
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
</div>
|
</Droppable>
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
//import {Droppable} from "@hello-pangea/dnd";
|
import {Droppable} from './dnd/Droppable';
|
||||||
import {useDroppable} from '@dnd-kit/core';
|
|
||||||
import {cartStyle, compareArraysWithIds} from "./utils";
|
import {cartStyle, compareArraysWithIds} from "./utils";
|
||||||
import {ProductCartItem} from "./ProductCartItem";
|
import {ProductCartItem} from "./ProductCartItem";
|
||||||
import {FakePlaceholder} from "./FakePlaceholder";
|
import {FakePlaceholder} from "./FakePlaceholder";
|
||||||
|
@ -23,10 +22,6 @@ export function Cart({crate_index}) {
|
||||||
});
|
});
|
||||||
const crateParams = useShopStore((state) => state.crateParams);
|
const crateParams = useShopStore((state) => state.crateParams);
|
||||||
|
|
||||||
const {setNodeRef} = useDroppable({
|
|
||||||
id: crate.id,
|
|
||||||
});
|
|
||||||
|
|
||||||
// #!render_count
|
// #!render_count
|
||||||
console.log("Cart renders: ", renderCount)
|
console.log("Cart renders: ", renderCount)
|
||||||
|
|
||||||
|
@ -47,7 +42,7 @@ export function Cart({crate_index}) {
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div ref={setNodeRef}>
|
<Droppable droppableId={crate.id} direction="horizontal">
|
||||||
|
|
||||||
{(provided, snapshot) => (
|
{(provided, snapshot) => (
|
||||||
<div
|
<div
|
||||||
|
@ -73,6 +68,6 @@ export function Cart({crate_index}) {
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
</div>
|
</Droppable>
|
||||||
);
|
);
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
//import {Draggable} from "@hello-pangea/dnd";
|
//import {Draggable} from "@hello-pangea/dnd";
|
||||||
import {useDraggable} from '@dnd-kit/core';
|
import {Draggable} from './dnd/Draggable';
|
||||||
import {compareObjectsEmptiness, productStyle} from "./utils";
|
import {compareObjectsEmptiness, productStyle} from "./utils";
|
||||||
import {Resources} from "./Resources";
|
import {Resources} from "./Resources";
|
||||||
import {CardWarnings} from "./CardWarnings";
|
import {CardWarnings} from "./CardWarnings";
|
||||||
|
@ -32,10 +32,6 @@ export function ProductCartItem({card_index, crate_index, first, last}) {
|
||||||
const removeHighlight = useShopStore((state) => state.highlightReset);
|
const removeHighlight = useShopStore((state) => state.highlightReset);
|
||||||
const onCardRemove = useShopStore((state) => state.deleteCard);
|
const onCardRemove = useShopStore((state) => state.deleteCard);
|
||||||
|
|
||||||
const {attributes, listeners, setNodeRef, transform} = useDraggable({
|
|
||||||
id: card.id,
|
|
||||||
});
|
|
||||||
|
|
||||||
// #!render_count
|
// #!render_count
|
||||||
console.log("ProductCartItem renders: ", renderCount)
|
console.log("ProductCartItem renders: ", renderCount)
|
||||||
|
|
||||||
|
@ -45,7 +41,7 @@ export function ProductCartItem({card_index, crate_index, first, last}) {
|
||||||
const resources = !options_disabled && card_counted_resources && card_counted_resources.length > 0;
|
const resources = !options_disabled && card_counted_resources && card_counted_resources.length > 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div ref={setNodeRef} {...listeners} {...attributes}>
|
<Draggable draggableId={card.id} index={card_index}>
|
||||||
|
|
||||||
{(provided, snapshot) => (
|
{(provided, snapshot) => (
|
||||||
<div
|
<div
|
||||||
|
@ -115,6 +111,6 @@ export function ProductCartItem({card_index, crate_index, first, last}) {
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
</div>
|
</Draggable>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
//import {Draggable} from "@hello-pangea/dnd";
|
import {Draggable} from './dnd/Draggable';
|
||||||
import {useDraggable} from '@dnd-kit/core';
|
|
||||||
import {formatMoney, productStyle} from "./utils";
|
import {formatMoney, productStyle} from "./utils";
|
||||||
import {useShopStore} from "./shop_store";
|
import {useShopStore} from "./shop_store";
|
||||||
|
|
||||||
|
@ -20,10 +19,6 @@ export function ProductItem({card_index}) {
|
||||||
const onAddCard = useShopStore((state) => state.addCardFromBacklog);
|
const onAddCard = useShopStore((state) => state.addCardFromBacklog);
|
||||||
const card = getCardDescription(card_index);
|
const card = getCardDescription(card_index);
|
||||||
|
|
||||||
const {attributes, listeners, setNodeRef, transform} = useDraggable({
|
|
||||||
id: card.id,
|
|
||||||
});
|
|
||||||
|
|
||||||
// #!render_count
|
// #!render_count
|
||||||
console.log("ProductItem renders: ", renderCount)
|
console.log("ProductItem renders: ", renderCount)
|
||||||
|
|
||||||
|
@ -67,7 +62,7 @@ export function ProductItem({card_index}) {
|
||||||
<img src="/images/shop/icon-add.svg" alt="add"/>
|
<img src="/images/shop/icon-add.svg" alt="add"/>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<div ref={setNodeRef} {...listeners} {...attributes}>
|
<Draggable draggableId={card.id} index={card_index}>
|
||||||
{(provided, snapshot) => (
|
{(provided, snapshot) => (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<img
|
<img
|
||||||
|
@ -87,7 +82,7 @@ export function ProductItem({card_index}) {
|
||||||
)}
|
)}
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
)}
|
)}
|
||||||
</div>
|
</Draggable>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
import React from 'react';
|
||||||
|
import {useDraggable} from '@dnd-kit/core';
|
||||||
|
|
||||||
|
export function Draggable(props) {
|
||||||
|
const Element = props.element || 'div';
|
||||||
|
const {attributes, listeners, setNodeRef} = useDraggable({
|
||||||
|
id: props.id,
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Element ref={setNodeRef} {...listeners} {...attributes}>
|
||||||
|
{props.children}
|
||||||
|
</Element>
|
||||||
|
);
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
import {useDroppable} from '@dnd-kit/core';
|
||||||
|
import React from 'react'
|
||||||
|
|
||||||
|
export function Droppable(props) {
|
||||||
|
const {setNodeRef} = useDroppable({
|
||||||
|
id: props.id,
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div ref={setNodeRef}>
|
||||||
|
{props.children}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
Loading…
Reference in New Issue