2022-12-12 13:45:24 +00:00
|
|
|
import { ChainItemType } from "../../types";
|
|
|
|
import { ChangeEvent, FunctionComponent, useState } from "react";
|
2022-12-09 11:59:52 +00:00
|
|
|
import {
|
|
|
|
ChainImageContainer,
|
|
|
|
ChainInfoContainer,
|
|
|
|
ChainItemContainer,
|
|
|
|
} from "./chain-list";
|
|
|
|
|
|
|
|
import color from "../../styles/color";
|
2022-12-12 06:51:25 +00:00
|
|
|
import { Flex1 } from "../../styles/flex-1";
|
2022-12-09 11:59:52 +00:00
|
|
|
import styled from "styled-components";
|
2022-12-12 13:45:24 +00:00
|
|
|
import { ChainImage } from "./chain-image";
|
2022-12-09 11:59:52 +00:00
|
|
|
|
|
|
|
interface Props {
|
2022-12-12 13:45:24 +00:00
|
|
|
chainItem: ChainItemType;
|
|
|
|
checkedItemHandler: (chainItem: ChainItemType, isChecked: boolean) => void;
|
2022-12-09 11:59:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export const ChainItem: FunctionComponent<Props> = (props) => {
|
2022-12-12 13:45:24 +00:00
|
|
|
const { chainItem, checkedItemHandler } = props;
|
|
|
|
const [checked, setChecked] = useState(false);
|
|
|
|
|
|
|
|
const checkHandler = (event: ChangeEvent<HTMLInputElement>) => {
|
|
|
|
setChecked(!checked);
|
|
|
|
checkedItemHandler(chainItem, event.target.checked);
|
|
|
|
};
|
2022-12-09 11:59:52 +00:00
|
|
|
return (
|
2022-12-12 13:45:24 +00:00
|
|
|
<ChainItemContainer key={chainItem.prefix} isLoading={false}>
|
2022-12-09 11:59:52 +00:00
|
|
|
<ChainImageContainer width="3rem" height="3rem">
|
2022-12-12 13:45:24 +00:00
|
|
|
<ChainImage
|
|
|
|
src={chainItem.chainImageUrl}
|
2022-12-09 11:59:52 +00:00
|
|
|
fill={true}
|
2022-12-12 13:45:24 +00:00
|
|
|
alt={`${chainItem.prefix} chain image`}
|
2022-12-09 11:59:52 +00:00
|
|
|
/>
|
|
|
|
</ChainImageContainer>
|
|
|
|
<ChainInfoContainer>
|
2022-12-12 13:45:24 +00:00
|
|
|
<ChainName>{`.${chainItem.prefix}`}</ChainName>
|
|
|
|
<WalletAddress>{chainItem.address}</WalletAddress>
|
2022-12-09 11:59:52 +00:00
|
|
|
</ChainInfoContainer>
|
|
|
|
|
|
|
|
<Flex1 />
|
|
|
|
|
2022-12-12 13:45:24 +00:00
|
|
|
<ChainCheckBox
|
|
|
|
checked={checked}
|
|
|
|
onChange={(event) => checkHandler(event)}
|
|
|
|
/>
|
2022-12-09 11:59:52 +00:00
|
|
|
</ChainItemContainer>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
const ChainName = styled.div`
|
|
|
|
font-weight: 600;
|
|
|
|
font-size: 0.8rem;
|
|
|
|
line-height: 1rem;
|
|
|
|
|
|
|
|
color: ${color.grey["100"]};
|
|
|
|
`;
|
|
|
|
|
|
|
|
const WalletAddress = styled.div`
|
|
|
|
font-weight: 500;
|
|
|
|
font-size: 0.8rem;
|
|
|
|
line-height: 1rem;
|
|
|
|
|
|
|
|
color: ${color.grey["400"]};
|
|
|
|
`;
|
|
|
|
|
|
|
|
const ChainCheckBox = styled.input.attrs({ type: "checkbox" })`
|
|
|
|
width: 1.5rem;
|
|
|
|
height: 1.5rem;
|
|
|
|
`;
|