This commit is contained in:
2020-08-19 22:55:44 +02:00
parent 312c8754bc
commit b84aa3db45
18 changed files with 1184 additions and 146 deletions

View File

@@ -1,4 +1,5 @@
import React, { useState, useEffect, createContext } from 'react';
import { Layout, Spin } from 'antd';
interface GithubContextType {
username: string;
@@ -13,6 +14,20 @@ interface Props {
children: React.ReactNode;
}
const Loader = () => (
<Layout
style={{
position: 'fixed',
alignItems: 'center',
justifyContent: 'center',
height: '100%',
width: '100%',
}}
>
<Spin size="large" />
</Layout>
);
const GithubContext = createContext<GithubContextType>({
username: 'unknown',
state: 'failed',
@@ -46,6 +61,10 @@ const GithubProvider: React.FC<Props> = ({
run();
}, [username]);
if (state === 'loading') {
return <Loader />;
}
return (
<GithubContext.Provider
value={{