forked from ReactTraining/hooks-workshop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTopBar.js
49 lines (45 loc) · 1.09 KB
/
TopBar.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import React from "react"
import { logout } from "app/utils"
import { useAppState } from "app/app-state"
import Avatar from "app/Avatar"
import { FaPowerOff } from "react-icons/fa"
import { FaSearch } from "react-icons/fa"
import GlobalNav from "app/GlobalNav"
export default function TopBar({ children }) {
return (
<div className="TopBar">
<div className="TopBar_inner">
<GlobalNav />
<Search />
<Account />
</div>
</div>
)
}
function Account() {
const [{ user }] = useAppState()
return user ? (
<div className="Account">
<Avatar uid={user.uid} />
<div className="Account_user_name">{user.displayName}</div>
<button
aria-label="Log out"
title="Log out"
className="Account_logout icon_button"
onClick={logout}
>
<FaPowerOff />
</button>
</div>
) : (
<div>Loading user</div>
)
}
function Search() {
return (
<div className="Search">
<FaSearch className="Search_icon" />
<input type="text" aria-label="Search" className="Search_input" />
</div>
)
}