mirror of
https://github.com/filecoin-project/slate.git
synced 2024-11-23 14:07:20 +03:00
feat(LinkIcon): get Link icon from an object
This commit is contained in:
parent
987d6d14e6
commit
0603222c50
19
components/core/LinkIcon.js
Normal file
19
components/core/LinkIcon.js
Normal file
@ -0,0 +1,19 @@
|
||||
import * as React from "react";
|
||||
import * as SVG from "~/common/svg";
|
||||
|
||||
import { useImage } from "~/common/hooks";
|
||||
|
||||
export default function LinkIcon({ file, width = 16, height = 16, style, ...props }) {
|
||||
const { linkFavicon } = file;
|
||||
const faviconImgState = useImage({ src: linkFavicon });
|
||||
return faviconImgState.error ? (
|
||||
<SVG.ExternalLink height={16} width={16} style={style} {...props} />
|
||||
) : (
|
||||
<img
|
||||
src={linkFavicon}
|
||||
alt="Link source logo"
|
||||
style={{ borderRadius: "4px", height, width, ...style }}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
Loading…
Reference in New Issue
Block a user