-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adjust autocomplete suggestions to design
- Loading branch information
1 parent
91a8fd4
commit 0c67a3d
Showing
7 changed files
with
89 additions
and
75 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,62 @@ | ||
import { Box, ListItem, UnorderedList } from "@chakra-ui/react"; | ||
import { Contact } from "../../types/Contact"; | ||
import colors from "../../style/colors"; | ||
import { parsePkh } from "../../types/Address"; | ||
import AddressTile from "../AddressTile/AddressTile"; | ||
|
||
export const Suggestions = ({ | ||
contacts, | ||
onChange, | ||
}: { | ||
contacts: Contact[]; | ||
onChange: (name: string) => void; | ||
}) => { | ||
if (contacts.length === 0) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<UnorderedList | ||
data-testid="suggestions-list" | ||
overflowY="auto" | ||
mt="8px" | ||
ml={0} | ||
width="100%" | ||
borderRadius="8px" | ||
listStyleType="none" | ||
position="absolute" | ||
border="1px solid" | ||
borderColor={colors.gray[500]} | ||
bg={colors.gray[700]} | ||
zIndex={2} | ||
maxHeight={300} | ||
> | ||
{contacts.map((contact, i) => ( | ||
<Box key={contact.pkh}> | ||
<ListItem | ||
onMouseDown={() => { | ||
// onMouseDown is the only way for this to fire before the onBlur callback of the Input | ||
// https://stackoverflow.com/a/28963938/6797267 | ||
onChange(contact.name); | ||
}} | ||
padding="5px 15px 0 5px" | ||
mb={i === contacts.length - 1 ? "5px" : 0} | ||
> | ||
<AddressTile | ||
cursor="pointer" | ||
address={parsePkh(contact.pkh)} | ||
_hover={{ | ||
background: colors.gray[500], | ||
}} | ||
background={colors.gray[700]} | ||
width="370px" | ||
borderRadius="4px" | ||
padding="5px" | ||
height="40px" | ||
/> | ||
</ListItem> | ||
</Box> | ||
))} | ||
</UnorderedList> | ||
); | ||
}; |
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 @@ | ||
export * from "./AddressAutocomplete"; |
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