Skip to content

Commit 7185c4b

Browse files
committed
Profile UI created with ChakraUI framework :D
1 parent a9e5d56 commit 7185c4b

File tree

5 files changed

+1170
-14
lines changed

5 files changed

+1170
-14
lines changed

package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,14 @@
88
"preview": "vite preview"
99
},
1010
"dependencies": {
11+
"@chakra-ui/react": "^1.8.6",
12+
"@emotion/react": "11",
13+
"@emotion/styled": "11",
14+
"axios": "^0.26.1",
15+
"framer-motion": "6",
1116
"react": "^17.0.2",
12-
"react-dom": "^17.0.2"
17+
"react-dom": "^17.0.2",
18+
"react-icons": "^4.3.1"
1319
},
1420
"devDependencies": {
1521
"@types/react": "^17.0.33",
@@ -18,4 +24,4 @@
1824
"typescript": "^4.5.4",
1925
"vite": "^2.8.0"
2026
}
21-
}
27+
}

src/App.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
import React from "react";
2-
import HelloWorld from "./components/HelloWorld";
2+
import { ChakraProvider, extendTheme } from "@chakra-ui/react";
3+
4+
import Home from "./pages/Home";
35

46
const App = () => {
7+
const config = {
8+
initialColorMode: "dark",
9+
useSystemColorMode: false
10+
};
11+
12+
const theme = extendTheme({ config });
13+
514
return (
6-
<>
7-
<HelloWorld />
8-
</>
15+
<ChakraProvider theme={theme}>
16+
<Home />
17+
</ChakraProvider>
918
);
1019
};
1120

src/pages/Home.tsx

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import React from "react";
2+
3+
import api from "../services/api";
4+
import { Flex, Input, Grid, Image, Text, Button } from "@chakra-ui/react";
5+
import { FaGithub } from "react-icons/fa";
6+
7+
export default function Home() {
8+
const [user, setUser] = React.useState({});
9+
10+
React.useEffect(() => {
11+
async function getUser() {
12+
try {
13+
const response = await api.get("/users/thiagoow");
14+
setUser(response.data);
15+
} catch (error) {
16+
console.log(error);
17+
}
18+
}
19+
20+
//Executa a função acima:
21+
getUser();
22+
}, []);
23+
24+
return (
25+
<Flex direction="column" alignItems="center" paddingTop="2rem">
26+
<Input width="14rem" size="sm" placeholder="Digite seu nome de usuário" />
27+
28+
<Flex direction="row" alignItems="center">
29+
<Image
30+
src={(user as any)?.avatar_url}
31+
alt="avatar"
32+
width="6rem"
33+
height="6rem"
34+
marginTop="2rem"
35+
borderRadius="full"
36+
/>
37+
38+
<Flex direction="column" marginLeft="1rem" alignItems="center">
39+
<Text fontWeight="bold" fontSize="1.5rem" marginTop="0.8rem">
40+
<a href={(user as any).url} target="_blank">
41+
{(user as any)?.name}
42+
</a>
43+
</Text>
44+
45+
<Button
46+
variant="link"
47+
_focus={{ boxShadow: "none" }}
48+
leftIcon={<FaGithub />}
49+
fontSize="0.8rem"
50+
alignSelf="start"
51+
marginTop="0.6rem"
52+
marginLeft="0.2rem"
53+
color="#ccc"
54+
>
55+
<a href={(user as any).html_url} target="_blank">
56+
{(user as any)?.login}
57+
</a>
58+
</Button>
59+
</Flex>
60+
</Flex>
61+
</Flex>
62+
);
63+
}

src/services/api.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import axios from "axios";
2+
3+
const api = axios.create({
4+
baseURL: "https://api.github.com"
5+
});
6+
7+
export default api;

0 commit comments

Comments
 (0)