-
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
9b3a6b3
commit c0998bb
Showing
13 changed files
with
158 additions
and
132 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
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// src/components/LoadingMask.tsx | ||
import React from 'react'; | ||
import { useLoading } from 'contexts/LoadingContext'; | ||
|
||
const LoadingMask: React.FC = () => { | ||
const { loading } = useLoading(); | ||
|
||
if (!loading) return null; | ||
|
||
return ( | ||
<div className="fixed inset-0 flex items-center justify-center bg-gray-800 bg-opacity-50 z-50"> | ||
<div className="spinner-border text-white" role="status"> | ||
<span className="visually-hidden">Loading...</span> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default LoadingMask; |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// src/context/LoadingContext.tsx | ||
import React, { createContext, useState, useContext, ReactNode } from 'react'; | ||
|
||
interface LoadingContextType { | ||
loading: boolean; | ||
startLoading: () => void; | ||
stopLoading: () => void; | ||
} | ||
|
||
const LoadingContext = createContext<LoadingContextType | undefined>(undefined); | ||
|
||
export const useLoading = (): LoadingContextType => { | ||
const context = useContext(LoadingContext); | ||
if (!context) { | ||
throw new Error('useLoading must be used within a LoadingProvider'); | ||
} | ||
return context; | ||
}; | ||
|
||
interface LoadingProviderProps { | ||
children: ReactNode; | ||
} | ||
|
||
export const LoadingProvider: React.FC<LoadingProviderProps> = ({ children }) => { | ||
const [loading, setLoading] = useState<boolean>(false); | ||
|
||
const startLoading = () => setLoading(true); | ||
const stopLoading = () => setLoading(false); | ||
|
||
return ( | ||
<LoadingContext.Provider value={{ loading, startLoading, stopLoading }}> | ||
{children} | ||
</LoadingContext.Provider> | ||
); | ||
}; |
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
Oops, something went wrong.