diff --git a/src/components/UserList.scss b/src/components/UserList.scss index e7469d707..f2720c397 100644 --- a/src/components/UserList.scss +++ b/src/components/UserList.scss @@ -37,6 +37,8 @@ padding: 0; justify-content: normal; margin: 0.5rem 0; + max-width: none; + max-height: none; } .UserList__more { @@ -49,6 +51,18 @@ color: var(--color-gray-70); } + --userlist-hint-bg-color: var(--color-gray-10); + --userlist-hint-heading-color: var(--color-gray-80); + --userlist-hint-text-color: var(--color-gray-60); + --userlist-collaborators-border-color: var(--color-gray-20); + + &.theme--dark { + --userlist-hint-bg-color: var(--color-gray-90); + --userlist-hint-heading-color: var(--color-gray-30); + --userlist-hint-text-color: var(--color-gray-40); + --userlist-collaborators-border-color: var(--color-gray-80); + } + .UserList__collaborators { position: static; top: auto; @@ -56,16 +70,8 @@ max-height: 12rem; overflow-y: auto; padding: 0.25rem 0.5rem; - } - - --userlist-hint-bg-color: var(--color-gray-10); - --userlist-hint-heading-color: var(--color-gray-80); - --userlist-hint-text-color: var(--color-gray-60); - - &.theme--dark { - --userlist-hint-bg-color: var(--color-gray-90); - --userlist-hint-heading-color: var(--color-gray-30); - --userlist-hint-text-color: var(--color-gray-40); + border-top: 1px solid var(--userlist-collaborators-border-color); + border-bottom: 1px solid var(--userlist-collaborators-border-color); } .UserList__hint { @@ -87,4 +93,20 @@ line-height: 150%; } } + + .UserList__search { + width: 100%; + box-sizing: border-box; + border: 0 !important; + border-radius: 0 !important; + font-size: 0.875rem; + + &::placeholder { + color: var(--color-gray-40); + } + + &:focus { + box-shadow: none !important; + } + } } diff --git a/src/components/UserList.tsx b/src/components/UserList.tsx index a44427cc6..a4461d7b1 100644 --- a/src/components/UserList.tsx +++ b/src/components/UserList.tsx @@ -142,27 +142,40 @@ export const UserList = ({ // }); const uniqueCollaboratorsMap = sampleCollaborators; - const uniqueCollaboratorsArray = Array.from(uniqueCollaboratorsMap).filter( - ([_, collaborator]) => Object.keys(collaborator).length !== 0, + const uniqueCollaboratorsArray = React.useMemo( + () => + Array.from(uniqueCollaboratorsMap).filter( + ([_, collaborator]) => Object.keys(collaborator).length !== 0, + ), + [uniqueCollaboratorsMap], + ); + + const [searchTerm, setSearchTerm] = React.useState(""); + + const filteredCollaborators = React.useMemo( + () => + uniqueCollaboratorsArray.filter(([, collaborator]) => + collaborator.username?.toLowerCase().includes(searchTerm.toLowerCase()), + ), + [uniqueCollaboratorsArray, searchTerm], ); if (uniqueCollaboratorsArray.length === 0) { return null; } - const firstThreeCollaborators = uniqueCollaboratorsArray.slice( + const firstNCollaborators = uniqueCollaboratorsArray.slice( 0, FIRST_N_AVATARS, ); - const first3avatarsJSX = firstThreeCollaborators.map( - ([clientId, collaborator]) => - renderCollaborator({ - actionManager, - collaborator, - clientId, - shouldWrapWithTooltip: true, - }), + const firstNAvatarsJSX = firstNCollaborators.map(([clientId, collaborator]) => + renderCollaborator({ + actionManager, + collaborator, + clientId, + shouldWrapWithTooltip: true, + }), ); return mobile ? ( @@ -178,10 +191,16 @@ export const UserList = ({ ) : (