chore: file structure

This commit is contained in:
Ou 2024-10-01 13:12:06 +08:00
parent ab35e2383d
commit 5c94fa2a19
2 changed files with 7 additions and 8 deletions

View File

@ -17,7 +17,7 @@ export interface ItemsProps extends React.HTMLAttributes<HTMLDivElement> {
*/ */
isDragged?: boolean isDragged?: boolean
isOverlay?: boolean isOverlay?: boolean
listeners?: SyntheticListenerMap handleListeners?: SyntheticListenerMap
} }
interface NewsCardProps { interface NewsCardProps {
@ -31,7 +31,7 @@ interface Query {
query: UseQueryResult<SourceInfo, Error> query: UseQueryResult<SourceInfo, Error>
} }
export const CardWrapper = forwardRef<HTMLDivElement, ItemsProps>(({ id, isDragged, isOverlay, listeners, style, ...props }, dndRef) => { export const CardWrapper = forwardRef<HTMLDivElement, ItemsProps>(({ id, isDragged, isOverlay, handleListeners, style, ...props }, dndRef) => {
const ref = useRef<HTMLDivElement>(null) const ref = useRef<HTMLDivElement>(null)
const { ref: inViewRef, inView } = useInView({ const { ref: inViewRef, inView } = useInView({
threshold: 0, threshold: 0,
@ -48,14 +48,13 @@ export const CardWrapper = forwardRef<HTMLDivElement, ItemsProps>(({ id, isDragg
isDragged && "op-50", isDragged && "op-50",
isOverlay ? "bg-glass" : "", isOverlay ? "bg-glass" : "",
)} )}
key={id}
style={{ style={{
transformOrigin: "50% 50%", transformOrigin: "50% 50%",
...style, ...style,
}} }}
{...props} {...props}
> >
<NewsCard id={id} inView={inView} isOverlay={isOverlay} handleListeners={listeners} /> <NewsCard id={id} inView={inView} isOverlay={isOverlay} handleListeners={handleListeners} />
</div> </div>
) )
}) })

View File

@ -66,8 +66,7 @@ export function Dnd() {
) )
} }
function SortableCardWrapper(props: ItemsProps) { function SortableCardWrapper({ id, ...props }: ItemsProps) {
const { id } = props
const { const {
isDragging, isDragging,
attributes, attributes,
@ -79,15 +78,16 @@ function SortableCardWrapper(props: ItemsProps) {
const style = { const style = {
transform: CSS.Transform.toString(transform), transform: CSS.Transform.toString(transform),
transition: transition || undefined, transition,
} }
return ( return (
<CardWrapper <CardWrapper
ref={setNodeRef} ref={setNodeRef}
id={id}
style={style} style={style}
isDragged={isDragging} isDragged={isDragging}
listeners={listeners} handleListeners={listeners}
{...attributes} {...attributes}
{...props} {...props}
/> />