-
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.
Merge pull request #34 from michaelclapham/improve-session-page1
Refactor + Improve session page
- Loading branch information
Showing
14 changed files
with
285 additions
and
245 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { IonCard, IonCardHeader, IonCardTitle, IonCardContent, IonItem } from "@ionic/react"; | ||
import React from "react"; | ||
import { SessionMessage } from "../session/SessionMessage"; | ||
|
||
export type HistoryCardProps = { | ||
messages: SessionMessage[]; | ||
} | ||
|
||
export const HistoryCard: React.FC<HistoryCardProps> = ({messages}) => { | ||
return <IonCard> | ||
<IonCardHeader> | ||
<IonCardTitle>History</IonCardTitle> | ||
</IonCardHeader> | ||
<IonCardContent> | ||
{ messages.length === 0 ? <NoMessages/> : | ||
messages.map(msg => <Message key={msg.uuid ?? "" + Math.random()} msg={msg} />) } | ||
</IonCardContent> | ||
</IonCard>; | ||
}; | ||
|
||
type MessageProps = { | ||
msg: SessionMessage; | ||
} | ||
|
||
const Message: React.FC<MessageProps> = ({msg}) => { | ||
return <IonItem> | ||
<b>{msg.senderName}:</b> | ||
{msg.text} | ||
</IonItem> | ||
} | ||
|
||
const NoMessages: React.FC = () => { | ||
return <div>Shared content will show up here.</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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.