working on drag and drop using dndkit
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { useEffect, useMemo, useRef } from "react"
|
||||
import Draggable from "./utils/draggableDnd"
|
||||
import Draggable from "./draggable/dnd/draggableDnd"
|
||||
|
||||
import { GithubOutlined, GitlabOutlined, LinkOutlined,
|
||||
AudioOutlined, FileTextOutlined,
|
||||
@@ -29,11 +29,23 @@ export function SidebarWidgetCard({ name, img, url, license, widgetClass, innerR
|
||||
|
||||
|
||||
return (
|
||||
// <Draggable className="tw-cursor-pointer" id={name}>
|
||||
<DraggableWrapper data-container={"sidebar"}
|
||||
<Draggable id={name}
|
||||
className="tw-cursor-pointer tw-w-fit tw-bg-white tw-h-fit"
|
||||
data-container={"sidebar"}
|
||||
dragElementType={widgetClass.widgetType}
|
||||
dragWidgetClass={widgetClass}
|
||||
elementMetaData={{
|
||||
name,
|
||||
url,
|
||||
img,
|
||||
license,
|
||||
widgetClass,
|
||||
}}
|
||||
>
|
||||
{/* <DraggableWrapper data-container={"sidebar"}
|
||||
dragElementType={widgetClass.widgetType}
|
||||
dragWidgetClass={widgetClass}
|
||||
className="tw-cursor-pointer tw-w-fit tw-bg-white tw-h-fit">
|
||||
className="tw-cursor-pointer tw-w-fit tw-bg-white tw-h-fit"> */}
|
||||
|
||||
<div ref={innerRef} className="tw-select-none tw-h-[200px] tw-w-[230px] tw-flex tw-flex-col
|
||||
tw-rounded-md tw-overflow-hidden
|
||||
@@ -72,8 +84,76 @@ export function SidebarWidgetCard({ name, img, url, license, widgetClass, innerR
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</DraggableWrapper>
|
||||
// </Draggable>
|
||||
{/* </DraggableWrapper> */}
|
||||
</Draggable>
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
|
||||
export function SidebarOverlayWidgetCard({ name, img, url, license, widgetClass, innerRef}){
|
||||
|
||||
const urlIcon = useMemo(() => {
|
||||
if (url){
|
||||
const host = new URL(url).hostname.toLowerCase()
|
||||
|
||||
if (host === "github.com"){
|
||||
return <GithubOutlined />
|
||||
}else if(host === "gitlab.com"){
|
||||
return <GitlabOutlined />
|
||||
}else{
|
||||
return <GlobalOutlined />
|
||||
}
|
||||
}
|
||||
|
||||
}, [url])
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* <DraggableWrapper data-container={"sidebar"}
|
||||
dragElementType={widgetClass.widgetType}
|
||||
dragWidgetClass={widgetClass}
|
||||
className="tw-cursor-pointer tw-w-fit tw-bg-white tw-h-fit"> */}
|
||||
|
||||
<div ref={innerRef} className="tw-bg-white tw-select-none tw-h-[200px] tw-w-[230px] tw-flex tw-flex-col
|
||||
tw-rounded-md tw-overflow-hidden
|
||||
tw-gap-2 tw-text-gray-600 tw-bg-[#ffffff44] tw-border-solid tw-border-[1px]
|
||||
tw-border-blue-500 tw-shadow-md">
|
||||
<div className="tw-h-[200px] tw-pointer-events-none tw-w-full tw-overflow-hidden">
|
||||
<img src={img} alt={name} className="tw-object-contain tw-h-full tw-w-full tw-select-none" />
|
||||
</div>
|
||||
<span className="tw-text-center tw-text-black tw-text-lg">{name}</span>
|
||||
<div className="tw-flex tw-text-lg tw-place tw-px-4">
|
||||
|
||||
<a href={url} className="tw-text-gray-600" target="_blank" rel="noopener noreferrer">
|
||||
{urlIcon}
|
||||
</a>
|
||||
|
||||
{license?.name &&
|
||||
|
||||
<div className="tw-ml-auto tw-text-sm">
|
||||
{
|
||||
license.url ?
|
||||
<a href={license.url} target="_blank" rel="noreferrer noopener"
|
||||
className="tw-p-[1px] tw-px-2 tw-text-blue-500 tw-border-[1px]
|
||||
tw-border-solid tw-rounded-sm tw-border-blue-500
|
||||
tw-shadow-md tw-text-center tw-no-underline">
|
||||
{license.name}
|
||||
</a>
|
||||
:
|
||||
<div className="tw-p-[1px] tw-px-2 tw-text-blue-500 tw-border-[1px]
|
||||
tw-border-solid tw-rounded-sm tw-border-blue-500
|
||||
tw-shadow-md tw-text-center">
|
||||
{license.name}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{/* </DraggableWrapper> */}
|
||||
</>
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user