-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
89b8767
commit 45a5c94
Showing
2 changed files
with
72 additions
and
10 deletions.
There are no files selected for viewing
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,66 @@ | ||
import { | ||
IonCard, | ||
IonCardHeader, | ||
IonCardTitle, | ||
IonCardSubtitle, | ||
IonCardContent, | ||
IonButton, | ||
} from "@ionic/react"; | ||
import React from "react"; | ||
import { ServerTypes } from "../../ServerTypes"; | ||
|
||
export type ClientsCardProps = { | ||
ownerId: string | undefined; | ||
clientMap: Record<string, ServerTypes.Client>; | ||
addClientClicked: () => void; | ||
}; | ||
|
||
export const ClientsCard: React.FC<ClientsCardProps> = ({ | ||
clientMap, | ||
ownerId, | ||
addClientClicked, | ||
}) => { | ||
const allClients = Object.values(clientMap); | ||
const onlyOwner = ownerId && clientMap[ownerId] && allClients.length <= 1; | ||
|
||
return ( | ||
<IonCard> | ||
<IonCardHeader> | ||
<IonCardTitle>Clients</IonCardTitle> | ||
<IonCardSubtitle>Devices connected to this session</IonCardSubtitle> | ||
</IonCardHeader> | ||
<IonCardContent> | ||
<div style={{ display: "flex", flexDirection: "row" }}> | ||
{onlyOwner ? ( | ||
<p>You are the only client connected to this session.</p> | ||
) : null} | ||
{allClients.map((client) => ( | ||
<ClientCircle client={client}></ClientCircle> | ||
))} | ||
<IonButton onClick={addClientClicked}>Add Client</IonButton> | ||
</div> | ||
</IonCardContent> | ||
</IonCard> | ||
); | ||
}; | ||
|
||
type ClientCircleProps = { | ||
client: ServerTypes.Client; | ||
}; | ||
|
||
const ClientCircle: React.FC<ClientCircleProps> = ({ client }) => { | ||
return ( | ||
<div | ||
style={{ | ||
minWidth: 32, | ||
height: 32, | ||
backgroundColor: "skyblue", | ||
borderRadius: 32, | ||
color: "white", | ||
fontSize: 16, | ||
}} | ||
> | ||
{client.id} : {client.name} | ||
</div> | ||
); | ||
}; |
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