Allow heading to close drawer
parent
3fdea4bc34
commit
8393454f8a
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "chat",
|
"name": "chat",
|
||||||
"version": "0.0.20",
|
"version": "0.0.21",
|
||||||
"main": "./src/index.tsx",
|
"main": "./src/index.tsx",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -4,27 +4,38 @@ import { UserList } from "./UserList";
|
||||||
import "./ChatHeading.css";
|
import "./ChatHeading.css";
|
||||||
|
|
||||||
export function ChatHeading() {
|
export function ChatHeading() {
|
||||||
const { reveal } = useDrawer();
|
const { open, hide, reveal } = useDrawer();
|
||||||
const { online } = useChat();
|
const { online } = useChat();
|
||||||
const handleOpenUserListDrawer = useCallback(
|
const handleToggleUserListDrawer = useCallback(() => {
|
||||||
() =>
|
if (open) {
|
||||||
|
hide();
|
||||||
|
} else {
|
||||||
reveal({
|
reveal({
|
||||||
title: "Users in chat",
|
title: "Users in chat",
|
||||||
content: <UserList fluid={true} />,
|
content: <UserList fluid={true} />,
|
||||||
}),
|
});
|
||||||
[]
|
}
|
||||||
);
|
}, [open]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="ChatHeading">
|
<div className="ChatHeading">
|
||||||
<div />
|
<div />
|
||||||
<div>
|
<div>
|
||||||
<i
|
{open ? (
|
||||||
role="button"
|
<button
|
||||||
className="far fa-user"
|
className="btn btn-secondary"
|
||||||
onClick={handleOpenUserListDrawer}
|
onClick={handleToggleUserListDrawer}
|
||||||
/>
|
>Close</button>
|
||||||
<em>{online.length} users online</em>
|
) : (
|
||||||
|
<>
|
||||||
|
<i
|
||||||
|
role="button"
|
||||||
|
className="far fa-user"
|
||||||
|
onClick={handleToggleUserListDrawer}
|
||||||
|
/>
|
||||||
|
<em>{online.length} users online</em>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue