-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a ThemeContext to provide theme related components/assets
- Loading branch information
1 parent
6f6d97f
commit b21a250
Showing
4 changed files
with
46 additions
and
3 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
ui/packages/shared/components/src/ParcaThemeContext/index.tsx
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,36 @@ | ||
import {createContext, ReactNode, useContext} from 'react'; | ||
import Spinner from '../Spinner'; | ||
|
||
interface ParcaThemeContextProps { | ||
loader: ReactNode; | ||
} | ||
|
||
const defaultValue: ParcaThemeContextProps = { | ||
loader: <Spinner />, | ||
}; | ||
|
||
const ParcaThemeContext = createContext<ParcaThemeContextProps>(defaultValue); | ||
|
||
export const ParcaThemeProvider = ({ | ||
children, | ||
value, | ||
}: { | ||
children: ReactNode; | ||
value?: ParcaThemeContextProps; | ||
}) => { | ||
return ( | ||
<ParcaThemeContext.Provider value={value ?? defaultValue}> | ||
{children} | ||
</ParcaThemeContext.Provider> | ||
); | ||
}; | ||
|
||
export const useParcaTheme = () => { | ||
const context = useContext(ParcaThemeContext); | ||
if (context == null) { | ||
return defaultValue; | ||
} | ||
return context; | ||
}; | ||
|
||
export default ParcaThemeContext; |
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