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
f87c4755
Commit
f87c4755
authored
Aug 19, 2023
by
timel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: small
parent
99930ac5
Pipeline
#23259
failed with stages
in 9 minutes
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
93 additions
and
12 deletions
+93
-12
src/ui/Duel/Message/NewYesNoModal/index.tsx
src/ui/Duel/Message/NewYesNoModal/index.tsx
+1
-0
src/ui/Shared/Modal/index.module.scss
src/ui/Shared/Modal/index.module.scss
+24
-0
src/ui/Shared/Modal/index.tsx
src/ui/Shared/Modal/index.tsx
+68
-12
No files found.
src/ui/Duel/Message/NewYesNoModal/index.tsx
View file @
f87c4755
...
@@ -17,6 +17,7 @@ const Content: ReactFcWithOnResult<Props, Result> = ({ msg, onResult }) => {
...
@@ -17,6 +17,7 @@ const Content: ReactFcWithOnResult<Props, Result> = ({ msg, onResult }) => {
return
(
return
(
<>
<>
<
Title
>
{
`${preHintMsg} ${msg}`
}
</
Title
>
<
Title
>
{
`${preHintMsg} ${msg}`
}
</
Title
>
<
div
style=
{
{
height
:
40
}
}
></
div
>
<
Footer
>
<
Footer
>
<
Button
onClick=
{
()
=>
onResult
({
isOk
:
false
})
}
>
取消
</
Button
>
<
Button
onClick=
{
()
=>
onResult
({
isOk
:
false
})
}
>
取消
</
Button
>
<
Button
type=
"primary"
onClick=
{
()
=>
onResult
({
isOk
:
true
})
}
>
<
Button
type=
"primary"
onClick=
{
()
=>
onResult
({
isOk
:
true
})
}
>
...
...
src/ui/Shared/Modal/index.module.scss
View file @
f87c4755
...
@@ -7,3 +7,27 @@
...
@@ -7,3 +7,27 @@
justify-content
:
flex-end
;
justify-content
:
flex-end
;
gap
:
12px
;
gap
:
12px
;
}
}
.modal
{
position
:
fixed
;
left
:
0
;
right
:
0
;
top
:
0
!
important
;
bottom
:
0
!
important
;
top
:
-
webkit-fill-available
;
margin
:
auto
;
height
:
fit-content
;
transition
:
top
0
.3s
;
}
.mini
{
top
:
100%
!
important
;
bottom
:
0
!
important
;
transform
:
translateY
(
calc
(
50%
-
66px
));
}
.btn-minimize
{
position
:
absolute
;
right
:
16px
;
top
:
16px
;
}
src/ui/Shared/Modal/index.tsx
View file @
f87c4755
import
{
App
}
from
"
antd
"
;
import
{
App
,
Button
}
from
"
antd
"
;
import
type
{
ModalFunc
}
from
"
antd/es/modal/confirm
"
;
import
type
{
ModalFunc
}
from
"
antd/es/modal/confirm
"
;
import
{
MinusOutlined
,
UpOutlined
}
from
"
@ant-design/icons
"
;
import
styles
from
"
./index.module.scss
"
;
import
styles
from
"
./index.module.scss
"
;
import
classNames
from
"
classnames
"
;
import
{
proxy
}
from
"
valtio
"
;
import
{
cloneElement
,
createElement
,
useState
}
from
"
react
"
;
/** 挂到某个节点去,在全局添加这几个静态方法 */
export
const
ModalContext
:
React
.
FC
=
()
=>
{
export
const
ModalContext
:
React
.
FC
=
()
=>
{
const
{
message
,
notification
,
modal
}
=
App
.
useApp
();
const
{
message
,
notification
,
modal
}
=
App
.
useApp
();
window
.
message
=
message
;
window
.
message
=
message
;
...
@@ -31,7 +34,7 @@ export const Footer: React.FC<React.PropsWithChildren> = ({ children }) => (
...
@@ -31,7 +34,7 @@ export const Footer: React.FC<React.PropsWithChildren> = ({ children }) => (
* 目的是通过传入不同的 Content 组件和配置选项,生成不同类型的弹窗,并在弹窗的 Content 中处理回调,最终返回一个 Promise 来处理弹窗的结果。
* 目的是通过传入不同的 Content 组件和配置选项,生成不同类型的弹窗,并在弹窗的 Content 中处理回调,最终返回一个 Promise 来处理弹窗的结果。
*/
*/
export
const
genModal
=
<
Props
extends
{},
Result
extends
{}
>
(
{
export
const
genModal
=
<
Props
extends
{},
Result
extends
{}
>
(
{
Content
,
Content
:
_Content
,
type
=
"
confirm
"
,
type
=
"
confirm
"
,
...
rest
...
rest
}
:
{
}
:
{
...
@@ -43,19 +46,72 @@ export const genModal = <Props extends {}, Result extends {}>({
...
@@ -43,19 +46,72 @@ export const genModal = <Props extends {}, Result extends {}>({
>
) =
>
{
>
) =
>
{
return
(
props
:
Props
)
=>
return
(
props
:
Props
)
=>
new
Promise
<
Result
>
((
rs
)
=>
{
new
Promise
<
Result
>
((
rs
)
=>
{
const
{
destroy
}
=
modal
[
type
]({
let
isMini
=
proxy
({
value
:
false
});
const
getClassNames
=
()
=>
classNames
(
styles
.
modal
,
{
[
styles
.
mini
]:
isMini
.
value
,
});
// const Content = ContentWrap(_Content);
const
BtnMini
=
()
=>
(
<
Button
icon=
{
<
MinusOutlined
/>
}
onClick=
{
function
()
{
isMini
.
value
=
!
isMini
.
value
;
update
({
className
:
getClassNames
(),
title
:
BtnMax
()
});
}
}
/>
);
const
BtnMax
=
()
=>
(
<
Button
icon=
{
<
UpOutlined
/>
}
onClick=
{
function
()
{
isMini
.
value
=
!
isMini
.
value
;
update
({
className
:
getClassNames
(),
title
:
BtnMini
()
});
}
}
/>
);
const
genMinimizeBtn
=
()
=>
(
<
Button
className=
{
styles
[
"
btn-minimize
"
]
}
type=
"text"
// size=
{16}
icon=
{
isMini
.
value
?
<
UpOutlined
/>
:
<
MinusOutlined
/>
}
onClick=
{
()
=>
{
isMini
.
value
=
!
isMini
.
value
;
update
({
className
:
getClassNames
(),
title
:
genMinimizeBtn
()
});
}
}
/>
);
const
{
destroy
,
update
}
=
modal
[
type
]({
content
:
(
content
:
(
<
Content
<
div
>
<
_Content
onResult=
{
(
result
)
=>
{
onResult=
{
(
result
)
=>
{
rs
(
result
);
rs
(
result
);
destroy
();
destroy
();
}
}
}
}
{
...
props
}
{
...
props
}
/>
/>
</
div
>
),
),
icon
:
null
,
title
:
genMinimizeBtn
(),
footer
:
null
,
footer
:
null
,
centered
:
true
,
centered
:
true
,
className
:
getClassNames
(),
onCancel
:
()
=>
false
,
...
rest
,
...
rest
,
});
});
});
});
}
;
}
;
function ContentWrap
<
P
extends
{}
>
(ChildrenComponent: React.ComponentType
<
P
>
)
{
return
(
props
:
P
&
{
toggleMini
:
()
=>
void
;
isMini
:
boolean
})
=>
{
return
(
<>
<
Button
onClick=
{
props
.
toggleMini
}
icon=
{
props
.
isMini
?
"
a
"
:
"
b
"
}
/>
<
ChildrenComponent
{
...
props
}
/>
</>
);
};
}
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