Skip to content

Commit

Permalink
feat: b3 loading component
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianJiang2021 committed Mar 20, 2023
1 parent 3cee88a commit e1f9cbc
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 84 deletions.
3 changes: 2 additions & 1 deletion apps/storefront/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,5 @@ export {
export {
B3PageMask,
showPageMask,
} from './pageMask/B3PageMask'
Loading,
} from './loadding'
19 changes: 4 additions & 15 deletions apps/storefront/src/components/layout/B3RenderRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ import {
useEffect,
} from 'react'

import {
Box,
} from '@mui/material'

import {
Route,
Routes,
Expand All @@ -24,6 +20,7 @@ import type {

import {
B3Layout,
Loading,
} from '@/components'
import {
RegisteredProvider,
Expand Down Expand Up @@ -86,17 +83,9 @@ export const B3RenderRouter = (props: B3RenderRouterProps) => {
}, [openUrl])

return (
<Suspense fallback={(
<Box sx={{
display: 'flex',
width: '100%',
height: '100vh',
justifyContent: 'center',
alignItems: 'center',
}}
>
Loading...
</Box>
<Suspense
fallback={(
<Loading />
)}
>
<B3LayoutTip />
Expand Down
40 changes: 40 additions & 0 deletions apps/storefront/src/components/loadding/B3PageMask.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import {
useContext,
} from 'react'

import {
GlobaledContext,
} from '@/shared/global'

import {
DispatchProps,
} from '@/shared/global/context/config'

import Loading from './Loading'

export const B3PageMask = () => {
const {
state: {
showPageMask,
},
} = useContext(GlobaledContext)

return (
<>
{
showPageMask && (
<Loading />
)
}
</>
)
}

export const showPageMask = (dispatch: DispatchProps, isShow: boolean) => {
dispatch({
type: 'common',
payload: {
showPageMask: isShow,
},
})
}
35 changes: 35 additions & 0 deletions apps/storefront/src/components/loadding/Loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import {
Box,
Typography,
} from '@mui/material'

const Loading = () => (
<Box
sx={{
width: '100%',
height: '100%',
position: 'fixed',
top: 0,
left: 0,
backgroundColor: '#fef9f5',
zIndex: 120000,
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
}}
>
<Typography
sx={{
position: 'absolute',
top: '50%',
left: '50%',
transform: 'translate(-50%, -50%)',
color: 'black',
}}
>
Loading...
</Typography>
</Box>
)

export default Loading
10 changes: 10 additions & 0 deletions apps/storefront/src/components/loadding/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Loading from './Loading'

export {
B3PageMask,
showPageMask,
} from './B3PageMask'

export {
Loading,
}
68 changes: 0 additions & 68 deletions apps/storefront/src/components/pageMask/B3PageMask.tsx

This file was deleted.

0 comments on commit e1f9cbc

Please sign in to comment.