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
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
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
baichixing
Neos
Commits
7573e743
Commit
7573e743
authored
May 05, 2023
by
chechunchi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimize CardModal.tsx
parent
a9f70fff
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
107 additions
and
90 deletions
+107
-90
src/styles/card-modal.scss
src/styles/card-modal.scss
+52
-0
src/ui/Duel/Message/CardModal.tsx
src/ui/Duel/Message/CardModal.tsx
+55
-90
No files found.
src/styles/card-modal.scss
0 → 100644
View file @
7573e743
.card-modal
{
position
:
fixed
;
display
:
flex
;
left
:
5%
;
top
:
20%
;
border-style
:
groove
;
border-radius
:
8px
;
width
:
200px
;
flex-wrap
:
wrap
;
background-color
:
#303030
;
padding
:
1%
;
--visibility
:
hidden
;
visibility
:
var
(
--
visibility
);
--opacity
:
0
;
opacity
:
var
(
--
opacity
);
transition
:visibility
0
.3s
linear
,
opacity
0
.3s
linear
;
}
.card-modal-container
{
display
:
flex
;
flex-direction
:
column
;
gap
:
5px
;
}
.card-modal-name
{
font-weight
:
bold
;
}
.card-modal-attribute
{
font-weight
:
bold
;
}
.card-modal-atk
{
font-weight
:
bold
;
}
.card-modal-counter
{
font-weight
:
bold
;
}
.card-modal-effect
{
font-weight
:
lighter
;
text-align
:
left
;
max-height
:
200px
;
overflow
:
auto
;
}
.card-modal-btn
{
margin
:
1px
5px
;
font-size
:
80%
;
border-color
:
yellow
;
}
src/ui/Duel/Message/CardModal.tsx
View file @
7573e743
import
Icon
,
{
StarOutlined
}
from
"
@ant-design/icons
"
;
import
"
@/styles/card-modal.scss
"
;
import
{
Button
,
Card
,
Col
,
Modal
,
Row
}
from
"
antd
"
;
import
{
ReactComponent
as
BattleSvg
}
from
"
neos-assets/battle-axe.svg
"
;
import
classnames
from
"
classnames
"
;
import
{
ReactComponent
as
DefenceSvg
}
from
"
neos-assets/checked-shield.svg
"
;
import
React
from
"
react
"
;
import
React
from
"
react
"
;
import
{
useSnapshot
}
from
"
valtio
"
;
import
{
useSnapshot
}
from
"
valtio
"
;
...
@@ -19,105 +18,72 @@ import {
...
@@ -19,105 +18,72 @@ import {
Type2StringCodeMap
,
Type2StringCodeMap
,
}
from
"
../../../common
"
;
}
from
"
../../../common
"
;
const
NeosConfig
=
useConfig
();
const
{
Meta
}
=
Card
;
const
CARD_WIDTH
=
240
;
const
{
cardModal
}
=
messageStore
;
const
{
cardModal
}
=
messageStore
;
const
NeosConfig
=
useConfig
();
const
CARD_WIDTH
=
200
;
export
const
CardModal
=
()
=>
{
export
const
CardModal
=
()
=>
{
const
snap
CardModal
=
useSnapshot
(
cardModal
);
const
snap
=
useSnapshot
(
cardModal
);
const
isOpen
=
snap
CardModal
.
isOpen
;
const
isOpen
=
snap
.
isOpen
;
const
meta
=
snap
CardModal
.
meta
;
const
meta
=
snap
.
meta
;
const
name
=
meta
?.
text
.
name
;
const
name
=
meta
?.
text
.
name
;
const
types
=
meta
?.
data
.
type
;
const
types
=
meta
?.
data
.
type
;
const
race
=
meta
?.
data
.
race
;
const
race
=
meta
?.
data
.
race
;
const
attribute
=
meta
?.
data
.
attribute
;
const
attribute
=
meta
?.
data
.
attribute
;
const
level
=
meta
?.
data
.
level
;
const
desc
=
meta
?.
text
.
desc
;
const
desc
=
meta
?.
text
.
desc
;
const
atk
=
meta
?.
data
.
atk
;
const
atk
=
meta
?.
data
.
atk
;
const
def
=
meta
?.
data
.
def
;
const
def
=
meta
?.
data
.
def
;
const
counters
=
snap
.
counters
;
// const counters = useAppSelector(selectCardModalCounters);
const
counters
=
snapCardModal
.
counters
;
const
imgUrl
=
meta
?.
id
const
imgUrl
=
meta
?.
id
?
`
${
NeosConfig
.
cardImgUrl
}
/
${
meta
.
id
}
.jpg`
?
`
${
NeosConfig
.
cardImgUrl
}
/
${
meta
.
id
}
.jpg`
:
undefined
;
:
undefined
;
const
interactivies
=
snapCardModal
.
interactivies
;
const
interactivies
=
snap
.
interactivies
;
const
handleOkOrCancel
=
()
=>
{
cardModal
.
isOpen
=
false
;
};
return
(
return
(
<
Modal
open=
{
isOpen
}
onOk=
{
handleOkOrCancel
}
onCancel=
{
handleOkOrCancel
}
>
<
div
<
Card
className=
{
classnames
(
"
card-modal
"
)
}
hoverable
style=
{
style=
{
{
width
:
CARD_WIDTH
}
}
{
cover=
{
<
img
alt=
{
name
}
src=
{
imgUrl
}
/>
}
"
--visibility
"
:
isOpen
?
"
visible
"
:
"
hidden
"
,
>
"
--opacity
"
:
isOpen
?
1
:
0
,
<
Meta
title=
{
name
}
/>
}
as
any
}
>
<
div
className=
"card-modal-container"
>
<
img
src=
{
imgUrl
}
width=
{
CARD_WIDTH
}
/>
<
div
className=
"card-modal-name"
>
{
name
}
</
div
>
<
AttLine
<
AttLine
types=
{
extraCardTypes
(
types
||
0
)
}
types=
{
extraCardTypes
(
types
||
0
)
}
race=
{
race
}
race=
{
race
}
attribute=
{
attribute
}
attribute=
{
attribute
}
/>
/>
<
AtkLine
level=
{
level
}
atk=
{
atk
}
def=
{
def
}
/>
<
AtkLine
atk=
{
atk
}
def=
{
def
}
/>
<
CounterLine
counters=
{
counters
}
/>
<
CounterLine
counters=
{
counters
}
/>
<
p
>
{
desc
}
</
p
>
<
div
className=
"card-modal-effect"
>
{
desc
}
</
div
>
</
Card
>
{
interactivies
.
map
((
interactive
,
idx
)
=>
{
{
interactivies
.
map
((
interactive
,
idx
)
=>
{
return
(
return
(
<
button
<
Button
key=
{
idx
}
key=
{
idx
}
className=
"card-modal-btn"
onClick=
{
()
=>
{
onClick=
{
()
=>
{
sendSelectIdleCmdResponse
(
interactive
.
response
);
sendSelectIdleCmdResponse
(
interactive
.
response
);
cardModal
.
isOpen
=
false
;
cardModal
.
isOpen
=
false
;
clearAllIdleInteractivities
(
0
);
clearAllIdleInteractivities
(
0
);
clearAllIdleInteractivities
(
1
);
clearAllIdleInteractivities
(
1
);
}
}
}
}
>
>
{
interactive
.
desc
}
{
interactive
.
desc
}
</
Button
>
</
button
>
);
);
})
}
})
}
</
Modal
>
</
div
>
</
div
>
);
);
};
};
const
AtkLine
=
(
props
:
{
level
?:
number
;
atk
?:
number
;
def
?:
number
})
=>
(
<
Row
gutter=
{
8
}
>
{
props
.
level
?
(
<
Col
>
<
StarOutlined
/>
{
props
.
level
}
</
Col
>
)
:
(
<></>
)
}
{
props
.
atk
?
(
<
Col
>
<
Icon
component=
{
BattleSvg
}
/>
<
a
>
{
props
.
atk
}
</
a
>
</
Col
>
)
:
(
<></>
)
}
<
Col
>
/
</
Col
>
{
props
.
def
?
(
<
Col
>
<
Icon
component=
{
DefenceSvg
}
/>
<
a
>
{
props
.
def
}
</
a
>
</
Col
>
)
:
(
<></>
)
}
</
Row
>
);
const
AttLine
=
(
props
:
{
const
AttLine
=
(
props
:
{
types
:
number
[];
types
:
number
[];
race
?:
number
;
race
?:
number
;
...
@@ -125,23 +91,24 @@ const AttLine = (props: {
...
@@ -125,23 +91,24 @@ const AttLine = (props: {
})
=>
{
})
=>
{
const
race
=
props
.
race
const
race
=
props
.
race
?
fetchStrings
(
"
!system
"
,
Race2StringCodeMap
.
get
(
props
.
race
)
||
0
)
?
fetchStrings
(
"
!system
"
,
Race2StringCodeMap
.
get
(
props
.
race
)
||
0
)
:
undefined
;
:
"
?
"
;
const
attribute
=
props
.
attribute
const
attribute
=
props
.
attribute
?
fetchStrings
(
"
!system
"
,
Attribute2StringCodeMap
.
get
(
props
.
attribute
)
||
0
)
?
fetchStrings
(
"
!system
"
,
Attribute2StringCodeMap
.
get
(
props
.
attribute
)
||
0
)
:
undefined
;
:
"
?
"
;
const
types
=
props
.
types
const
types
=
props
.
types
.
map
((
t
)
=>
fetchStrings
(
"
!system
"
,
Type2StringCodeMap
.
get
(
t
)
||
0
))
.
map
((
t
)
=>
fetchStrings
(
"
!system
"
,
Type2StringCodeMap
.
get
(
t
)
||
0
))
.
join
(
"
|
"
);
.
join
(
"
|
"
);
return
(
return
(
<
Row
gutter=
{
8
}
>
<
div
className=
"card-modal-attribute"
>
{
`【 ${race} / ${types} 】【 ${attribute} 】`
}
</
div
>
<
Col
>
{
`[${types}]`
}
</
Col
>
{
race
?
<
Col
>
{
race
}
</
Col
>
:
<></>
}
<
Col
>
/
</
Col
>
{
attribute
?
<
Col
>
{
attribute
}
</
Col
>
:
<></>
}
</
Row
>
);
);
};
};
const
AtkLine
=
(
props
:
{
atk
?:
number
;
def
?:
number
})
=>
(
<
div
className=
"card-modal-atk"
>
{
`ATK/${
props.atk !== undefined ? props.atk : "?"
} DEF/${props.def !== undefined ? props.def : "?"}`
}
</
div
>
);
const
CounterLine
=
(
props
:
{
counters
:
{
[
type
:
number
]:
number
}
})
=>
{
const
CounterLine
=
(
props
:
{
counters
:
{
[
type
:
number
]:
number
}
})
=>
{
const
counters
=
[];
const
counters
=
[];
for
(
const
counterType
in
props
.
counters
)
{
for
(
const
counterType
in
props
.
counters
)
{
...
@@ -152,13 +119,11 @@ const CounterLine = (props: { counters: { [type: number]: number } }) => {
...
@@ -152,13 +119,11 @@ const CounterLine = (props: { counters: { [type: number]: number } }) => {
}
}
}
}
return
counters
.
length
>
0
?
(
return
(
<
Row
gutter=
{
8
}
>
<>
{
counters
.
map
((
counter
)
=>
(
{
counters
.
map
((
counter
)
=>
(
<
Col
>
{
counter
}
</
Col
>
<
div
className=
"card-modal-counter"
>
{
counter
}
</
div
>
))
}
))
}
</
Row
>
</>
)
:
(
<></>
);
);
};
};
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