Skip to content

Commit

Permalink
Fix/preprod (#30)
Browse files Browse the repository at this point in the history
* fix: update fallback prop for Image component in WalletConnectors

* fix: update Tooltip component styles for improved layout and responsiveness

* Sort wallets and add icons for walletconnect and coinbase

* lint

---------

Signed-off-by: hugolxt <[email protected]>
  • Loading branch information
hugolxt authored Dec 16, 2024
1 parent cfe2001 commit 821ccfe
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 6 deletions.
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

0 comments on commit 821ccfe

Please sign in to comment.