2021-05-14 18:02:50 +10:00
|
|
|
import React from "react";
|
|
|
|
|
import { Image } from "theme-ui";
|
|
|
|
|
|
|
|
|
|
import { useDataURL } from "../../contexts/AssetsContext";
|
|
|
|
|
|
|
|
|
|
import { tokenSources as defaultTokenSources } from "../../tokens";
|
|
|
|
|
|
2021-05-25 18:06:26 +10:00
|
|
|
const TokenImage = React.forwardRef(({ token, ...props }, ref) => {
|
2021-05-14 18:02:50 +10:00
|
|
|
const tokenURL = useDataURL(
|
|
|
|
|
token,
|
|
|
|
|
defaultTokenSources,
|
|
|
|
|
undefined,
|
|
|
|
|
token.type === "file"
|
|
|
|
|
);
|
|
|
|
|
|
2021-05-25 18:06:26 +10:00
|
|
|
return <Image src={tokenURL} ref={ref} {...props} />;
|
2021-05-25 16:56:37 +10:00
|
|
|
});
|
2021-05-14 18:02:50 +10:00
|
|
|
|
2021-05-25 16:56:37 +10:00
|
|
|
export default TokenImage;
|