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

smol nits on DaoList and AccountSelector components #50

Merged
merged 1 commit into from
Jan 22, 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: 2 additions & 2 deletions src/components/DaoList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -493,8 +493,8 @@ const DaoList = (props: DaoListProps) => {
<div>
<div className='flex flex-col md:flex-row gap-2 md:gap-10 items-stretch md:items-center justify-between mb-4 mt-14 md:mt-0'>
<h4 className="text-white text-md">{isOverview ? 'My Staked DAOs' : 'All Registered DAOs'} ({stakedCoresCount || '0'})</h4>
<div className="bg-neutral-950 bg-opacity-50 rounded-lg flex flex-row items-stretch gap-2 p-4">
<div className='relative'>
<div className="bg-neutral-950 bg-opacity-50 rounded-lg flex flex-row gap-2 p-4">
<div className='relative w-full'>
<Input type="text" id="filterDaos" placeholder='Search' onChange={handleSearch} value={searchTerm} className='pr-12' />
{searchTerm && <button type='button' className='absolute -translate-x-10 pt-[4px] translate-y-1/2 hover:underline-offset-2 hover:underline text-tinkerYellow text-xxs' onClick={() => setSearchTerm('')}>clear</button>}
</div>
Expand Down
20 changes: 15 additions & 5 deletions src/modals/AccountSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { capitalizeFirst } from "../utils/capitalizeFirst";
import { WalletNameEnum, getWalletIcon } from "../utils/getWalletIcon";
import Button from "../components/Button";
import { BG_GRADIENT } from "../utils/consts";
import toast from "react-hot-toast";

const AccountSelector = (props: { isOpen: boolean; }) => {
const { isOpen } = props;
Expand Down Expand Up @@ -66,6 +67,15 @@ const AccountSelector = (props: { isOpen: boolean; }) => {
}
};

const handleCopy = (e: React.MouseEvent<HTMLElement>, value: string | undefined) => {
e.stopPropagation();

if (!value) return;

navigator.clipboard.writeText(value);
toast.success("Copied to clipboard");
};

return isOpen ? (
<Dialog open={true} onClose={closeModal}>
<Dialog.Title className="sr-only">Select your Wallet</Dialog.Title>
Expand Down Expand Up @@ -115,16 +125,16 @@ const AccountSelector = (props: { isOpen: boolean; }) => {
<div className={`rounded-full p-1 flex items-center ${ account.address !== selectedAccount?.address ? 'bg-tinkerLightGrey' : 'bg-tinkerGrey' }`}>
<Identicon value={account.address} size={47} theme="substrate" />
</div>
<div className="flex flex-col gap-0">
<div className="flex flex-col gap-0 truncate">
<div className="flex flex-row gap-1 items-center">
{typeof getWalletIcon(account.meta?.source) === 'undefined' ?
<span className="text-xxs text-ellipsis">{account.meta?.source}</span> :
<div className="text-xxs text-ellipsis truncate">{account.meta?.source}</div> :
<img src={getWalletIcon(account.meta?.source)} alt={account.meta?.source} className="w-4 h-4 mr-1" />
}
<span className="text-md font-normal text-ellipsis">{capitalizeFirst(account.meta?.name)}</span>
<span className="text-md leading-[20px] font-normal text-ellipsis truncate">{capitalizeFirst(account.meta?.name)}</span>
</div>
<span className="block overflow-hidden text-ellipsis text-xs md:text-sm text-gray-500 hover:underline hover:underline-offset-4">
{stringShorten(account.address, 17)}
<span onClick={(e) => handleCopy(e, account.address)} className="block overflow-hidden text-ellipsis text-xs text-gray-500 hover:underline hover:underline-offset-2 truncate mt-[2px]">
{stringShorten(account.address, 20)}
</span>
</div>
</li>
Expand Down