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
fed1294e
Commit
fed1294e
authored
Aug 30, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decouple DeckZone
parent
11d7bb1b
Pipeline
#23295
passed with stages
in 11 minutes and 7 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
14 deletions
+45
-14
src/ui/BuildDeck/index.tsx
src/ui/BuildDeck/index.tsx
+45
-14
No files found.
src/ui/BuildDeck/index.tsx
View file @
fed1294e
...
@@ -207,7 +207,23 @@ export const DeckEditor: React.FC<{
...
@@ -207,7 +207,23 @@ export const DeckEditor: React.FC<{
</
Space
>
</
Space
>
<
ScrollableArea
className=
{
styles
[
"
deck-zone
"
]
}
>
<
ScrollableArea
className=
{
styles
[
"
deck-zone
"
]
}
>
{
([
"
main
"
,
"
extra
"
,
"
side
"
]
as
const
).
map
((
type
)
=>
(
{
([
"
main
"
,
"
extra
"
,
"
side
"
]
as
const
).
map
((
type
)
=>
(
<
DeckZone
key=
{
type
}
type=
{
type
}
/>
<
DeckZone
key=
{
type
}
type=
{
type
}
cards=
{
[...
snapEditDeck
[
type
]]
}
canAdd=
{
editDeckStore
.
canAdd
}
onChange=
{
(
card
,
source
,
destination
)
=>
{
editDeckStore
.
add
(
destination
,
card
);
if
(
source
!==
"
search
"
)
{
editDeckStore
.
remove
(
source
,
card
);
}
}
}
onElementClick=
{
(
card
)
=>
{
selectedCard
.
id
=
card
.
id
;
selectedCard
.
open
=
true
;
}
}
onElementRightClick=
{
(
card
)
=>
editDeckStore
.
remove
(
type
,
card
)
}
/>
))
}
))
}
</
ScrollableArea
>
</
ScrollableArea
>
</
div
>
</
div
>
...
@@ -397,9 +413,28 @@ const Search: React.FC = () => {
...
@@ -397,9 +413,28 @@ const Search: React.FC = () => {
/** 正在组卡的zone,包括main/extra/side */
/** 正在组卡的zone,包括main/extra/side */
const
DeckZone
:
React
.
FC
<
{
const
DeckZone
:
React
.
FC
<
{
type
:
Type
;
type
:
Type
;
}
>
=
({
type
})
=>
{
cards
:
CardMeta
[];
canAdd
:
(
card
:
CardMeta
,
type
:
Type
,
source
:
Type
|
"
search
"
,
)
=>
{
result
:
boolean
;
reason
:
string
};
onChange
:
(
card
:
CardMeta
,
source
:
Type
|
"
search
"
,
destination
:
Type
,
)
=>
void
;
onElementClick
:
(
card
:
CardMeta
)
=>
void
;
onElementRightClick
:
(
card
:
CardMeta
)
=>
void
;
}
>
=
({
type
,
cards
,
canAdd
,
onChange
,
onElementClick
,
onElementRightClick
,
})
=>
{
const
{
message
}
=
App
.
useApp
();
const
{
message
}
=
App
.
useApp
();
const
cards
=
useSnapshot
(
editDeckStore
)[
type
];
const
[
allowToDrop
,
setAllowToDrop
]
=
useState
(
false
);
const
[
allowToDrop
,
setAllowToDrop
]
=
useState
(
false
);
const
[{
isOver
},
dropRef
]
=
useDrop
({
const
[{
isOver
},
dropRef
]
=
useDrop
({
accept
:
[
"
Card
"
],
// 指明该区域允许接收的拖放物。可以是单个,也可以是数组
accept
:
[
"
Card
"
],
// 指明该区域允许接收的拖放物。可以是单个,也可以是数组
...
@@ -407,21 +442,16 @@ const DeckZone: React.FC<{
...
@@ -407,21 +442,16 @@ const DeckZone: React.FC<{
// 当拖拽物在这个拖放区域放下时触发,这个item就是拖拽物的item(拖拽物携带的数据)
// 当拖拽物在这个拖放区域放下时触发,这个item就是拖拽物的item(拖拽物携带的数据)
drop
:
({
value
,
source
}:
{
value
:
CardMeta
;
source
:
Type
|
"
search
"
})
=>
{
drop
:
({
value
,
source
}:
{
value
:
CardMeta
;
source
:
Type
|
"
search
"
})
=>
{
if
(
type
===
source
)
return
;
if
(
type
===
source
)
return
;
const
{
result
,
reason
}
=
editDeckStore
.
canAdd
(
value
,
type
,
source
);
const
{
result
,
reason
}
=
canAdd
(
value
,
type
,
source
);
if
(
result
)
{
if
(
result
)
{
editDeckStore
.
add
(
type
,
value
);
onChange
(
value
,
source
,
type
);
if
(
source
!==
"
search
"
)
{
editDeckStore
.
remove
(
source
,
value
);
}
}
else
{
}
else
{
message
.
error
(
reason
);
message
.
error
(
reason
);
}
}
},
},
hover
:
({
value
,
source
})
=>
{
hover
:
({
value
,
source
})
=>
{
setAllowToDrop
(
setAllowToDrop
(
type
!==
source
type
!==
source
?
canAdd
(
value
,
type
,
source
).
result
:
true
,
?
editDeckStore
.
canAdd
(
value
,
type
,
source
).
result
:
true
,
);
);
},
},
collect
:
(
monitor
)
=>
({
collect
:
(
monitor
)
=>
({
...
@@ -443,10 +473,11 @@ const DeckZone: React.FC<{
...
@@ -443,10 +473,11 @@ const DeckZone: React.FC<{
key=
{
card
.
id
+
i
+
type
}
key=
{
card
.
id
+
i
+
type
}
source=
{
type
}
source=
{
type
}
onClick=
{
()
=>
{
onClick=
{
()
=>
{
selectedCard
.
id
=
card
.
id
;
onElementClick
(
card
);
selectedCard
.
open
=
true
;
}
}
onRightClick=
{
()
=>
{
onElementRightClick
(
card
);
}
}
}
}
onRightClick=
{
()
=>
editDeckStore
.
remove
(
type
,
card
)
}
/>
/>
))
}
))
}
<
div
className=
{
styles
[
"
editing-zone-name
"
]
}
>
<
div
className=
{
styles
[
"
editing-zone-name
"
]
}
>
...
...
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