diff --git a/package.json b/package.json index 63c365a..3561537 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "chartjs-plugin-datalabels": "^2.2.0", "class-variance-authority": "^0.7.0", "clsx": "^2.0.0", + "cmdk": "^1.0.0", "color-diff": "^1.3.0", "crypto-js": "^4.2.0", "date-fns": "^3.3.1", diff --git a/src/components/coin-analytics.tsx b/src/components/coin-analytics.tsx index 9112251..45c657a 100644 --- a/src/components/coin-analytics.tsx +++ b/src/components/coin-analytics.tsx @@ -35,6 +35,8 @@ import { getImageApiPath } from "@/utils/app"; import { WalletAnalyzer } from "@/middlelayers/wallet"; import { timeToDateStr } from "@/utils/date"; import { + CaretSortIcon, + CheckIcon, ChevronLeftIcon, ChevronRightIcon, Pencil2Icon, @@ -49,19 +51,21 @@ import { } from "@/components/ui/dialog"; import { Button } from "./ui/button"; import { toast } from "./ui/use-toast"; -import { - Select, - SelectContent, - SelectGroup, - SelectItem, - SelectLabel, - SelectTrigger, - SelectValue, -} from "./ui/select"; import CoinsAmountAndValueChange from "./coins-amount-and-value-change"; import { Skeleton } from "./ui/skeleton"; import { loadingWrapper } from "@/lib/loading"; import WalletAssetsPercentage from "./wallet-assets-percentage"; +import { Popover, PopoverContent, PopoverTrigger } from "./ui/popover"; +import { + Command, + CommandEmpty, + CommandGroup, + CommandInput, + CommandItem, + CommandList, +} from "./ui/command"; +import { cn } from "@/lib/utils"; +import bluebird from 'bluebird' const App = ({ currency, @@ -88,6 +92,7 @@ const App = ({ const [maxPosition, setMaxPosition] = useState(0); + const [coinSelectOpen, setCoinSelectOpen] = useState(false); const [walletAliasMap, setWalletAliasMap] = useState<{ [k: string]: string | undefined; }>({}); @@ -532,28 +537,53 @@ const App = ({ alt={symbol} />
- + + + + + + + + No coin found. + + {allowSymbols.map((s) => ( + { + setCoinSelectOpen(false); + navigate(`/coins/${v}`); + }} + > +
{s}
+ +
+ ))} +
+
+
+
+
diff --git a/src/components/ui/command.tsx b/src/components/ui/command.tsx new file mode 100644 index 0000000..09a5896 --- /dev/null +++ b/src/components/ui/command.tsx @@ -0,0 +1,153 @@ +import * as React from "react" +import { type DialogProps } from "@radix-ui/react-dialog" +import { MagnifyingGlassIcon } from "@radix-ui/react-icons" +import { Command as CommandPrimitive } from "cmdk" + +import { cn } from "@/lib/utils" +import { Dialog, DialogContent } from "@/components/ui/dialog" + +const Command = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +Command.displayName = CommandPrimitive.displayName + +interface CommandDialogProps extends DialogProps {} + +const CommandDialog = ({ children, ...props }: CommandDialogProps) => { + return ( + + + + {children} + + + + ) +} + +const CommandInput = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( +
+ + +
+)) + +CommandInput.displayName = CommandPrimitive.Input.displayName + +const CommandList = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) + +CommandList.displayName = CommandPrimitive.List.displayName + +const CommandEmpty = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>((props, ref) => ( + +)) + +CommandEmpty.displayName = CommandPrimitive.Empty.displayName + +const CommandGroup = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) + +CommandGroup.displayName = CommandPrimitive.Group.displayName + +const CommandSeparator = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +CommandSeparator.displayName = CommandPrimitive.Separator.displayName + +const CommandItem = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) + +CommandItem.displayName = CommandPrimitive.Item.displayName + +const CommandShortcut = ({ + className, + ...props +}: React.HTMLAttributes) => { + return ( + + ) +} +CommandShortcut.displayName = "CommandShortcut" + +export { + Command, + CommandDialog, + CommandInput, + CommandList, + CommandEmpty, + CommandGroup, + CommandItem, + CommandShortcut, + CommandSeparator, +} diff --git a/yarn.lock b/yarn.lock index 1cf95e0..246be18 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1291,6 +1291,14 @@ clsx@^2.0.0: resolved "https://registry.yarnpkg.com/clsx/-/clsx-2.1.0.tgz#e851283bcb5c80ee7608db18487433f7b23f77cb" integrity sha512-m3iNNWpd9rl3jvvcBnu70ylMdrXt8Vlq4HYadnU5fwcOtvkSQWPmj7amUcDT2qYI7risszBjI5AUIUox9D16pg== +cmdk@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/cmdk/-/cmdk-1.0.0.tgz#0a095fdafca3dfabed82d1db78a6262fb163ded9" + integrity sha512-gDzVf0a09TvoJ5jnuPvygTB77+XdOSwEmJ88L6XPFPlv7T3RxbP9jgenfylrAMD0+Le1aO0nVjQUzl2g+vjz5Q== + dependencies: + "@radix-ui/react-dialog" "1.0.5" + "@radix-ui/react-primitive" "1.0.3" + color-convert@^1.9.0: version "1.9.3" resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8"