icns-frontend/components/chain-list/chain-image.tsx

28 lines
590 B
TypeScript
Raw Normal View History

import { useState } from "react";
import Image, { ImageProps } from "next/image";
import KeplrIcon from "../../public/images/svg/keplr-icon.svg";
2022-12-16 15:53:40 +00:00
import styled from "styled-components";
2022-12-16 15:53:40 +00:00
export const ChainImage = ({ src, ...props }: ImageProps) => {
const [srcState, setSrcState] = useState(src);
2022-12-15 04:25:07 +00:00
return (
2022-12-16 15:53:40 +00:00
<ImageWrapper>
<Image
{...props}
src={srcState}
alt="chain image"
sizes="3rem"
onError={() => setSrcState(KeplrIcon)}
/>
</ImageWrapper>
2022-12-15 04:25:07 +00:00
);
};
2022-12-16 15:53:40 +00:00
const ImageWrapper = styled.div`
img {
border-radius: 50%;
}
`;