-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1e6e027
commit 4e79db1
Showing
7 changed files
with
59 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,11 @@ | ||
.pub-loading { | ||
position: fixed; | ||
$prefix-cls: 'pub-loading'; | ||
|
||
.#{$prefix-cls} { | ||
position: absolute; | ||
inset: 0; | ||
z-index: 9999999; | ||
z-index: 10000; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
width: 100%; | ||
height: 100%; | ||
background-color: rgba($color: #000, $alpha: 20%); | ||
|
||
svg { | ||
width: 100px; | ||
height: 100px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,39 @@ | ||
import { memo } from 'react'; | ||
import { Root, createRoot } from 'react-dom/client'; | ||
|
||
import { SpinLoading } from 'antd-mobile'; | ||
|
||
import { createDesign } from '@/hooks'; | ||
|
||
import './index.scss'; | ||
|
||
/** Loading组件示例,可替换为ui库的loading组件作二次封装 */ | ||
let container: HTMLDivElement | null = null; | ||
let root: Root | null = null; | ||
|
||
const { prefixCls } = createDesign('pub-loading'); | ||
|
||
function Loading() { | ||
return ( | ||
<div className="pub-loading"> | ||
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24"> | ||
<path | ||
fill="none" | ||
stroke="#4579FF" | ||
strokeDasharray="15" | ||
strokeDashoffset="15" | ||
strokeLinecap="round" | ||
strokeWidth="2" | ||
d="M12 3C16.9706 3 21 7.02944 21 12" | ||
> | ||
<animate fill="freeze" attributeName="stroke-dashoffset" dur="0.3s" values="15;0" /> | ||
<animateTransform | ||
attributeName="transform" | ||
dur="1.5s" | ||
repeatCount="indefinite" | ||
type="rotate" | ||
values="0 12 12;360 12 12" | ||
/> | ||
</path> | ||
</svg> | ||
<div className={prefixCls}> | ||
<SpinLoading style={{ '--size': '42px' }} /> | ||
</div> | ||
); | ||
} | ||
|
||
export default memo(Loading); | ||
Loading.show = () => { | ||
if (container || root) return; | ||
container = document.createElement('div'); | ||
container.setAttribute('id', 'pub-loading'); | ||
root = createRoot(container); | ||
root.render(<Loading />); | ||
document.body.appendChild(container); | ||
}; | ||
|
||
Loading.hide = () => { | ||
if (container && root) { | ||
root.unmount(); | ||
document.body.removeChild(container); | ||
container = root = null; | ||
} | ||
}; | ||
|
||
export default Loading; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -179,3 +179,9 @@ pre { | |
::-webkit-scrollbar { | ||
display: none; | ||
} | ||
|
||
/* p, | ||
span, | ||
div { | ||
word-break: break-word; | ||
} */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters