mirror of https://github.com/shuang854/Turtle
Merge branch 'master' into database-restructuring
commit
fb90ca1c77
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,29 @@
|
||||
.online-button {
|
||||
margin: 0 4px 0 0;
|
||||
align-self: center;
|
||||
--box-shadow: 0 3px 2px -1px rgba(0, 0, 0, 0.2), 0 2px 5px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12);
|
||||
}
|
||||
|
||||
.popover-list {
|
||||
padding-top: 2px;
|
||||
}
|
||||
|
||||
.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