-
Notifications
You must be signed in to change notification settings - Fork 834
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added spotlight * fixed soptlight
- Loading branch information
Showing
19 changed files
with
1,082 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { PushDetail } from "@coral-xyz/react-common"; | ||
import { useCustomTheme } from "@coral-xyz/themes"; | ||
|
||
import { SELECTED_BLUE } from "./colors"; | ||
import { Line } from "./Line"; | ||
|
||
export const ActionRow = ({ | ||
title, | ||
onClick, | ||
selected = false, | ||
}: { | ||
title: string; | ||
onClick: any; | ||
selected?: boolean; | ||
}) => { | ||
const theme = useCustomTheme(); | ||
|
||
return ( | ||
<div> | ||
<div | ||
style={{ | ||
display: "flex", | ||
justifyContent: "space-between", | ||
padding: "20px 10px", | ||
background: selected ? SELECTED_BLUE : "", | ||
cursor: "pointer", | ||
}} | ||
onClick={onClick} | ||
> | ||
<div style={{ color: theme.custom.colors.fontColor }}>{title}</div> | ||
<div> | ||
<PushDetail /> | ||
</div> | ||
</div> | ||
<Line /> | ||
</div> | ||
); | ||
}; |
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,120 @@ | ||
import { useEffect,useState } from "react"; | ||
import { | ||
NAV_COMPONENT_MESSAGE_CHAT, | ||
NAV_COMPONENT_MESSAGE_PROFILE, | ||
TAB_MESSAGES, | ||
UI_RPC_METHOD_NAVIGATION_ACTIVE_TAB_UPDATE, | ||
} from "@coral-xyz/common"; | ||
import { useBackgroundClient, useNavigation } from "@coral-xyz/recoil"; | ||
|
||
import { ActionRow } from "./ActionRow"; | ||
import { GroupIdentifier } from "./GroupIdentifier"; | ||
import { SpotlightContact } from "./SpotlightContacts"; | ||
|
||
export const FriendCard = ({ | ||
friend, | ||
setOpen, | ||
}: { | ||
friend: { username: string; image: string; uuid: string }; | ||
setOpen: any; | ||
}) => { | ||
const [arrowIndex, setArrowIndex] = useState<number | null>(null); | ||
const background = useBackgroundClient(); | ||
const { push, toRoot } = useNavigation(); | ||
|
||
useEffect(() => { | ||
async function keyDownTextField(e: any) { | ||
if (e.which === 38) { | ||
setArrowIndex((x) => (x === null ? 0 : x - 1)); | ||
} else if (e.which === 40) { | ||
setArrowIndex((x) => (x === null ? 0 : x + 1)); | ||
} | ||
if ((e.key === "Enter" || e.key === "Return") && arrowIndex !== null) { | ||
await toRoot(); | ||
await background.request({ | ||
method: UI_RPC_METHOD_NAVIGATION_ACTIVE_TAB_UPDATE, | ||
params: [TAB_MESSAGES], | ||
}); | ||
if (arrowIndex !== null && arrowIndex !== -1 && arrowIndex % 2 === 0) { | ||
push({ | ||
title: `@${friend.username}`, | ||
componentId: NAV_COMPONENT_MESSAGE_CHAT, | ||
componentProps: { | ||
userId: friend?.uuid, | ||
id: friend?.uuid, | ||
username: friend?.username, | ||
}, | ||
}); | ||
} else { | ||
push({ | ||
title: `@${friend?.username}`, | ||
componentId: NAV_COMPONENT_MESSAGE_PROFILE, | ||
componentProps: { | ||
userId: friend?.uuid, | ||
}, | ||
}); | ||
} | ||
setOpen(false); | ||
} | ||
} | ||
document.addEventListener("keydown", keyDownTextField); | ||
|
||
return () => { | ||
document.removeEventListener("keydown", keyDownTextField); | ||
}; | ||
}, [arrowIndex, friend]); | ||
|
||
return ( | ||
<div> | ||
<GroupIdentifier name="Friends" /> | ||
<SpotlightContact | ||
setSelectedContact={() => {}} | ||
contact={friend} | ||
selected={false} | ||
/> | ||
|
||
<ActionRow | ||
selected={(arrowIndex !== null && arrowIndex % 2) === 0} | ||
title="Send a message" | ||
onClick={async () => { | ||
await toRoot(); | ||
await background.request({ | ||
method: UI_RPC_METHOD_NAVIGATION_ACTIVE_TAB_UPDATE, | ||
params: [TAB_MESSAGES], | ||
}); | ||
|
||
push({ | ||
title: `@${friend.username}`, | ||
componentId: NAV_COMPONENT_MESSAGE_CHAT, | ||
componentProps: { | ||
userId: friend?.uuid, | ||
id: friend?.uuid, | ||
username: friend?.username, | ||
}, | ||
}); | ||
setOpen(false); | ||
}} | ||
/> | ||
<ActionRow | ||
selected={(arrowIndex !== null && arrowIndex % 2) === 1} | ||
title="Go to profile" | ||
onClick={async () => { | ||
await toRoot(); | ||
await background.request({ | ||
method: UI_RPC_METHOD_NAVIGATION_ACTIVE_TAB_UPDATE, | ||
params: [TAB_MESSAGES], | ||
}); | ||
|
||
push({ | ||
title: `@${friend?.username}`, | ||
componentId: NAV_COMPONENT_MESSAGE_PROFILE, | ||
componentProps: { | ||
userId: friend?.uuid, | ||
}, | ||
}); | ||
setOpen(false); | ||
}} | ||
/> | ||
</div> | ||
); | ||
}; |
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,23 @@ | ||
import { PushDetail } from "@coral-xyz/react-common"; | ||
import { useCustomTheme } from "@coral-xyz/themes"; | ||
|
||
import { ActionRow } from "./ActionRow"; | ||
|
||
export const GroupIdentifier = ({ name }: { name: string }) => { | ||
const theme = useCustomTheme(); | ||
|
||
return ( | ||
<div | ||
style={{ | ||
display: "flex", | ||
justifyContent: "space-between", | ||
marginBottom: 4, | ||
}} | ||
> | ||
<div style={{ color: theme.custom.colors.icon }}>{name}</div> | ||
<div> | ||
<PushDetail /> | ||
</div> | ||
</div> | ||
); | ||
}; |
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,9 @@ | ||
import { useCustomTheme } from "@coral-xyz/themes"; | ||
|
||
export const Line = () => { | ||
const theme = useCustomTheme(); | ||
|
||
return ( | ||
<div style={{ height: 1, background: theme.custom.colors.icon }} /> | ||
); | ||
}; |
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,38 @@ | ||
import * as React from "react"; | ||
import { TextInput } from "@coral-xyz/react-common"; | ||
import { useCustomTheme } from "@coral-xyz/themes"; | ||
import SearchIcon from "@mui/icons-material/Search"; | ||
|
||
import { useStyles } from "./styles"; | ||
|
||
export const SpotlightSearchBar = ({ | ||
searchFilter, | ||
setSearchFilter, | ||
}: { | ||
searchFilter: string; | ||
setSearchFilter: any; | ||
}) => { | ||
const classes = useStyles(); | ||
const theme = useCustomTheme(); | ||
|
||
return ( | ||
<TextInput | ||
autoFocus | ||
className={classes.searchField} | ||
placeholder="Search" | ||
startAdornment={ | ||
<SearchIcon sx={{ color: theme.custom.colors.icon, mr: "10px" }} /> | ||
} | ||
value={searchFilter} | ||
setValue={async (e) => { | ||
const prefix = e.target.value; | ||
setSearchFilter(prefix); | ||
}} | ||
inputProps={{ | ||
style: { | ||
height: "48px", | ||
}, | ||
}} | ||
/> | ||
); | ||
}; |
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,82 @@ | ||
import { SpotlightContacts } from "./SpotlightContacts"; | ||
import { SpotlightGroups } from "./SpotlightGroups"; | ||
import { SpotlightNfts } from "./SpotlightNfts"; | ||
import { SpotlightTokens } from "./SpotlightTokens"; | ||
import { useSearchedContacts } from "./useSearchedContacts"; | ||
import { useSearchedGroupsCollections } from "./useSearchedGroups"; | ||
import { useSearchedNfts } from "./useSearchedNfts"; | ||
import { useSearchedTokens } from "./useSearchedTokens"; | ||
import { getCurrentCounter } from "./utils"; | ||
|
||
export const SearchBody = ({ | ||
searchFilter, | ||
arrowIndex, | ||
setOpen, | ||
setSelectedContact, | ||
}: { | ||
searchFilter: string; | ||
arrowIndex: number; | ||
setOpen: any; | ||
setSelectedContact: any; | ||
}) => { | ||
const contacts = useSearchedContacts(searchFilter); | ||
const groups = useSearchedGroupsCollections(searchFilter); | ||
const nfts = useSearchedNfts(searchFilter); | ||
const tokens = useSearchedTokens(searchFilter); | ||
const allResultsLength = | ||
contacts.length + groups.length + nfts.length + tokens.length; | ||
const currentCounter = getCurrentCounter(arrowIndex, allResultsLength); | ||
|
||
if (!searchFilter) return <div />; | ||
|
||
return ( | ||
<div> | ||
<div> | ||
<SpotlightContacts | ||
selectedIndex={ | ||
currentCounter < contacts.length ? currentCounter : null | ||
} | ||
contacts={contacts} | ||
setSelectedContact={setSelectedContact} | ||
/> | ||
</div> | ||
<div style={{ marginTop: 10 }}> | ||
<SpotlightGroups | ||
selectedIndex={ | ||
currentCounter >= contacts.length && | ||
currentCounter < contacts.length + groups.length | ||
? currentCounter - contacts.length | ||
: null | ||
} | ||
groups={groups} | ||
setOpen={setOpen} | ||
/> | ||
</div> | ||
<div style={{ marginTop: 10 }}> | ||
<SpotlightNfts | ||
selectedIndex={ | ||
currentCounter >= contacts.length + groups.length && | ||
currentCounter < contacts.length + groups.length + nfts.length | ||
? currentCounter - contacts.length - groups.length | ||
: null | ||
} | ||
nfts={nfts} | ||
setOpen={setOpen} | ||
/> | ||
</div> | ||
<div style={{ marginTop: 10 }}> | ||
<SpotlightTokens | ||
selectedIndex={ | ||
currentCounter >= contacts.length + groups.length + nfts.length && | ||
currentCounter < | ||
contacts.length + groups.length + nfts.length + tokens.length | ||
? currentCounter - contacts.length - groups.length - nfts.length | ||
: null | ||
} | ||
tokens={tokens} | ||
setOpen={setOpen} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.
66574c2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
backpack – ./
devnet.backpack.app
backpack.app
backpack-git-master-200ms.vercel.app
www.backpack.app
backpack-200ms.vercel.app