Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/preprod #30

Merged
merged 6 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/assets/walletCoinbase.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions src/assets/walletConnect.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 42 additions & 3 deletions src/components/dapp/WalletConnectors.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import { useMemo } from "react";
import type { Connector } from "wagmi";
import walletCoinbaseIcon from "../../assets/walletCoinbase.svg";
import walletConnectIcon from "../../assets/walletConnect.svg";
import { useWalletContext } from "../../context/Wallet.context";
import Group from "../extenders/Group";
import Button from "../primitives/Button";
Expand All @@ -10,20 +14,44 @@ import Text from "../primitives/Text";
export default function WalletConnectors() {
const { config, connect, connector: _connected } = useWalletContext();

const sortedConnectors = useMemo(
() =>
[...config.connectors].sort((a, b) => {
const priority = (connector: Connector) => {
switch (connector.name.toLowerCase()) {
case "metamask":
return 0;
case "rabby wallet":
return 1;
case "walletconnect":
return 2;
default:
return 3;
}
};
return priority(a) - priority(b);
}),
[config.connectors],
);

return (
<Group className="flex-col w-full">
<div className="grid grid-flow-row gap-lg">
{config.connectors.map(connector => {
{sortedConnectors.map(connector => {
return (
<Button
look="base"
// look={connected?.id === connector.id ? "hype" : "bold"}
onClick={() => connect(connector.id)}
size="xl"
bold
className="gap-sm*2"
key={connector.id}>
<Image className="h-lg*2 w-lg*2 rounded-md" alt={connector.name} src={connector.icon} fallback="" />
<Image
className="h-lg*2 w-lg*2 rounded-full overflow-hidden"
alt={connector.name}
src={overrideIcons(connector)}
fallback=""
/>
{connector.name}
<Icon remix="RiArrowRightUpLine" />
</Button>
Expand All @@ -38,3 +66,14 @@ export default function WalletConnectors() {
</Group>
);
}

const overrideIcons = (connector: Connector) => {
switch (connector.name.toLowerCase()) {
case "coinbase wallet":
return walletCoinbaseIcon;
case "walletconnect":
return walletConnectIcon;
default:
return connector.icon;
}
};
6 changes: 3 additions & 3 deletions src/components/primitives/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ export default function Tooltip({ helper, children, icon = true }: TooltipProps)
<RadixTooltip.Provider delayDuration={0}>
<RadixTooltip.Root>
<RadixTooltip.Trigger asChild>
<span className="inline-flex items-center">
<span className="flex items-center gap-sm">
<div>{children}</div>
{!!icon && <Icon remix="RiQuestionLine" alt="Tooltip" />}
</span>
</RadixTooltip.Trigger>
<RadixTooltip.Portal>
<RadixTooltip.Content
style={vars}
className="select-none rounded bg-main-1 rounded-full px-lg py-md z-30 leading-none shadow-[hsl(206_22%_7%_/_35%)_0px_10px_38px_-10px,_hsl(206_22%_7%_/_20%)_0px_10px_20px_-15px] will-change-[transform,opacity] data-[state=delayed-open]:data-[side=bottom]:animate-slideUpAndFade data-[state=delayed-open]:data-[side=left]:animate-slideRightAndFade data-[state=delayed-open]:data-[side=right]:animate-slideLeftAndFade data-[state=delayed-open]:data-[side=top]:animate-slideDownAndFade"
className="select-none rounded-md bg-main-1 rounded-full px-lg py-md z-30 leading-none shadow-[hsl(206_22%_7%_/_35%)_0px_10px_38px_-10px,_hsl(206_22%_7%_/_20%)_0px_10px_20px_-15px] will-change-[transform,opacity] data-[state=delayed-open]:data-[side=bottom]:animate-slideUpAndFade data-[state=delayed-open]:data-[side=left]:animate-slideRightAndFade data-[state=delayed-open]:data-[side=right]:animate-slideLeftAndFade data-[state=delayed-open]:data-[side=top]:animate-slideDownAndFade max-w-[90vw] md:max-w-[70vw] lg:max-w-[40vw] xl:max-w-[30vw]"
sideOffset={5}>
<Text size="sm" className="text-main-12">
<Text size="sm" className="text-main-12 ">
{helper}
</Text>
<RadixTooltip.Arrow />
Expand Down
Loading