Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
N
Neos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Neos
Commits
c7c55b09
Commit
c7c55b09
authored
Apr 01, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add SortCardModal.tsx
parent
4f467af2
Pipeline
#21051
passed with stages
in 23 minutes and 24 seconds
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
116 additions
and
2 deletions
+116
-2
src/ui/Duel/main.tsx
src/ui/Duel/main.tsx
+2
-0
src/ui/Duel/sortCardModal.tsx
src/ui/Duel/sortCardModal.tsx
+114
-2
No files found.
src/ui/Duel/main.tsx
View file @
c7c55b09
...
@@ -28,6 +28,7 @@ import PlayerStatus from "./status";
...
@@ -28,6 +28,7 @@ import PlayerStatus from "./status";
import
Alert
from
"
./alert
"
;
import
Alert
from
"
./alert
"
;
import
CheckCardModalV3
from
"
./checkCardModalV3
"
;
import
CheckCardModalV3
from
"
./checkCardModalV3
"
;
import
CheckCounterModal
from
"
./checkCounterModal
"
;
import
CheckCounterModal
from
"
./checkCounterModal
"
;
import
SortCardModal
from
"
./sortCardModal
"
;
// Ref: https://github.com/brianzinn/react-babylonjs/issues/126
// Ref: https://github.com/brianzinn/react-babylonjs/issues/126
const
NeosDuel
=
()
=>
{
const
NeosDuel
=
()
=>
{
...
@@ -50,6 +51,7 @@ const NeosDuel = () => {
...
@@ -50,6 +51,7 @@ const NeosDuel = () => {
<
CheckCardModalV2
/>
<
CheckCardModalV2
/>
<
CheckCardModalV3
/>
<
CheckCardModalV3
/>
<
CheckCounterModal
/>
<
CheckCounterModal
/>
<
SortCardModal
/>
</>
</>
);
);
};
};
...
...
src/ui/Duel/sortCardModal.tsx
View file @
c7c55b09
import
React
from
"
react
"
;
import
React
,
{
useRef
,
useState
}
from
"
react
"
;
import
{
DndContext
,
closestCenter
,
KeyboardSensor
,
PointerSensor
,
useSensor
,
useSensors
,
DragEndEvent
,
}
from
"
@dnd-kit/core
"
;
import
{
arrayMove
,
SortableContext
,
sortableKeyboardCoordinates
,
verticalListSortingStrategy
,
useSortable
,
}
from
"
@dnd-kit/sortable
"
;
import
{
CSS
}
from
"
@dnd-kit/utilities
"
;
import
{
useAppSelector
}
from
"
../../hook
"
;
import
{
selectSortCardModal
}
from
"
../../reducers/duel/modal/sortCardModalSlice
"
;
import
{
sendSelectCardResponse
}
from
"
../../api/ocgcore/ocgHelper
"
;
import
{
store
}
from
"
../../store
"
;
import
{
resetSortCardModal
}
from
"
../../reducers/duel/mod
"
;
import
DragModal
from
"
./dragModal
"
;
import
{
Button
,
Card
}
from
"
antd
"
;
import
{
CardMeta
}
from
"
../../api/cards
"
;
import
NeosConfig
from
"
../../../neos.config.json
"
;
const
SortCardModal
=
()
=>
<></>;
const
SortCardModal
=
()
=>
{
const
dispatch
=
store
.
dispatch
;
const
state
=
useAppSelector
(
selectSortCardModal
);
const
isOpen
=
state
.
isOpen
;
const
options
=
state
.
options
;
const
[
items
,
setItems
]
=
useState
(
options
);
const
sensors
=
useSensors
(
useSensor
(
PointerSensor
),
useSensor
(
KeyboardSensor
,
{
coordinateGetter
:
sortableKeyboardCoordinates
,
})
);
const
draggleRef
=
useRef
<
HTMLDivElement
>
(
null
);
const
onFinish
=
()
=>
{
sendSelectCardResponse
(
items
.
map
((
item
)
=>
item
.
response
));
dispatch
(
resetSortCardModal
());
};
const
onDragEnd
=
(
event
:
DragEndEvent
)
=>
{
const
{
active
,
over
}
=
event
;
if
(
active
.
id
!==
over
?.
id
)
{
setItems
((
items
)
=>
{
const
oldIndex
=
items
.
findIndex
((
item
)
=>
item
.
response
==
active
.
id
);
const
newIndex
=
items
.
findIndex
((
item
)
=>
item
.
response
===
over
?.
id
);
return
arrayMove
(
items
,
oldIndex
,
newIndex
);
});
}
};
return
(
<
DragModal
modalProps=
{
{
title
:
"
请为下列卡牌排序
"
,
open
:
isOpen
,
closable
:
false
,
footer
:
<
Button
onClick=
{
onFinish
}
>
finish
</
Button
>,
}
}
dragRef=
{
draggleRef
}
draggable=
{
true
}
>
<
DndContext
sensors=
{
sensors
}
collisionDetection=
{
closestCenter
}
onDragEnd=
{
onDragEnd
}
>
<
SortableContext
items=
{
items
.
map
((
item
)
=>
item
.
response
)
}
strategy=
{
verticalListSortingStrategy
}
>
{
items
.
map
((
item
)
=>
(
<
SortableItem
key=
{
item
.
response
}
id=
{
item
.
response
}
meta=
{
item
.
meta
}
/>
))
}
</
SortableContext
>
</
DndContext
>
</
DragModal
>
);
};
const
SortableItem
=
(
props
:
{
id
:
number
;
meta
:
CardMeta
})
=>
{
const
{
attributes
,
listeners
,
setNodeRef
,
transform
,
transition
}
=
useSortable
({
id
:
props
.
id
});
const
style
=
{
transform
:
CSS
.
Transform
.
toString
(
transform
),
transition
,
};
return
(
<
div
ref=
{
setNodeRef
}
style=
{
style
}
{
...
attributes
}
{
...
listeners
}
>
<
Card
style=
{
{
width
:
100
}
}
cover=
{
<
img
alt=
{
props
.
meta
.
id
.
toString
()
}
src=
{
`${NeosConfig.cardImgUrl}/${props.meta.id}.jpg`
}
/>
}
/>
</
div
>
);
};
export
default
SortCardModal
;
export
default
SortCardModal
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment