mirror of https://github.com/shuang854/Turtle
added basic online list
parent
1017155720
commit
e28f849632
@ -0,0 +1,32 @@
|
||||
.online-button {
|
||||
margin: 0 4px 0 0;
|
||||
align-self: center;
|
||||
}
|
||||
|
||||
.popover-list {
|
||||
padding-top: 2px;
|
||||
}
|
||||
|
||||
.online-popover .popover-content {
|
||||
font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
|
||||
}
|
||||
|
||||
.list-header {
|
||||
font-size: 24px;
|
||||
color: var(--ion-color-primary);
|
||||
border-bottom: 1px solid #999;
|
||||
}
|
||||
|
||||
.online-item {
|
||||
--padding-start: 12px;
|
||||
--min-height: 0;
|
||||
}
|
||||
|
||||
.online-label {
|
||||
margin-top: 8px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
ion-backdrop {
|
||||
cursor: default;
|
||||
}
|
||||
@ -0,0 +1,48 @@
|
||||
import React, { useState } from 'react';
|
||||
import { IonPopover, IonFabButton, IonIcon, IonList, IonListHeader, IonItem, IonLabel } from '@ionic/react';
|
||||
import { peopleOutline } from 'ionicons/icons';
|
||||
import './OnlineList.css';
|
||||
|
||||
type OnlineListProps = {
|
||||
userList: string[];
|
||||
};
|
||||
|
||||
const OnlineList: React.FC<OnlineListProps> = ({ userList }) => {
|
||||
const [showPopover, setShowPopover] = useState<{ open: boolean; event: Event | undefined }>({
|
||||
open: false,
|
||||
event: undefined,
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<IonPopover
|
||||
cssClass="online-popover"
|
||||
isOpen={showPopover.open}
|
||||
event={showPopover.event}
|
||||
showBackdrop={false}
|
||||
onDidDismiss={(e) => setShowPopover({ open: false, event: undefined })}
|
||||
>
|
||||
<IonList class="popover-list">
|
||||
<IonListHeader class="list-header">Online</IonListHeader>
|
||||
{userList.map((user) => {
|
||||
return (
|
||||
<IonItem key={user} class="online-item" lines="none">
|
||||
<IonLabel class="online-label">{user}</IonLabel>
|
||||
</IonItem>
|
||||
);
|
||||
})}
|
||||
</IonList>
|
||||
</IonPopover>
|
||||
<IonFabButton
|
||||
slot="end"
|
||||
size="small"
|
||||
class="online-button"
|
||||
onClick={(e) => setShowPopover({ open: true, event: e.nativeEvent })}
|
||||
>
|
||||
<IonIcon icon={peopleOutline}></IonIcon>
|
||||
</IonFabButton>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default OnlineList;
|
||||
Loading…
Reference in New Issue