Add user avatars to select dropdown

This commit is contained in:
Tom Moor committed 2023-12-29 18:59:39 -05:00
1 parent 2e9ada5a87
commit 044eb758e9
3 files changed
+16 -6

No files matched your search

+6 -3
View File
@@ -20,6 +20,8 @@ import { undraggableOnDesktop } from "~/styles";
type Suggestion = {
id: string;
value: string;
/** A label to show instead of the value if a more rich component is needed */
label?: React.ReactNode;
[key: string]: any;
};
@@ -31,7 +33,7 @@ type Props = Omit<React.InputHTMLAttributes<HTMLInputElement>, "list"> & {
/** Value held by the search input bar */
value: string;
/** Label for search input */
label: string;
label?: string;
/** Label for the search results list */
listLabel: string;
/** Handler which triggers upon search input change */
@@ -66,7 +68,7 @@ function Combobox({
};
const state = useComboboxState({
gutter: 8,
gutter: 2,
values: suggestions.map((s) => s.value),
});
@@ -148,7 +150,7 @@ function Combobox({
state.hide();
}}
>
{item.value}
{item.label ?? item.value}
</StyledComboboxOption>
))
: null}
@@ -198,6 +200,7 @@ const StyledComboboxInput = styled(ComboboxInput)`
const StyledComboboxOption = styled(ComboboxOption)`
${MenuAnchorCSS}
/* overriding the styles from MenuAnchorCSS because we use &nbsp; here */
svg:not(:last-child) {
margin-right: 0px;
@@ -10,6 +10,8 @@ import Document from "~/models/Document";
import User from "~/models/User";
import UserMembership from "~/models/UserMembership";
import MemberListItem from "~/scenes/CollectionPermissions/components/MemberListItem";
import Avatar from "~/components/Avatar";
import { AvatarSize } from "~/components/Avatar/Avatar";
import Flex from "~/components/Flex";
import LoadingIndicator from "~/components/LoadingIndicator";
import PaginatedList from "~/components/PaginatedList";
@@ -169,13 +171,18 @@ function InviteTeamMembers({ document }: Props) {
suggestions={nonMembers.map((user) => ({
id: user.id,
value: user.name,
label: (
<Flex align="center" gap={8}>
<Avatar model={user} size={AvatarSize.Small} showBorder={false} />
<span>{user.name}</span>
</Flex>
),
}))}
value={query}
onChangeInput={handleQuery}
onSelectOption={handleSelect}
label={t("Invite team members")}
listLabel={t("Team members")}
placeholder={`${t("Search by name")}…`}
placeholder={`${t("Add workspace members")}…`}
autoFocus
/>
<PaginatedList
+1 -1
View File
@@ -554,8 +554,8 @@
"Viewer insights": "Viewer insights",
"As an admin you can manage if team members can see who has viewed this document": "As an admin you can manage if team members can see who has viewed this document",
"{{ userName }} was removed from the document": "{{ userName }} was removed from the document",
"Invite team members": "Invite team members",
"Team members": "Team members",
"Add workspace members": "Add workspace members",
"Sorry, the last change could not be persisted – please reload the page": "Sorry, the last change could not be persisted – please reload the page",
"This template will be permanently deleted in <2></2> unless restored.": "This template will be permanently deleted in <2></2> unless restored.",
"This document will be permanently deleted in <2></2> unless restored.": "This document will be permanently deleted in <2></2> unless restored.",