-
Notifications
You must be signed in to change notification settings - Fork 294
/
Placeholder.jsx
51 lines (47 loc) · 1.45 KB
/
Placeholder.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// @flow
import React from "react";
import styled from "styled-components";
import type { NFTMetadata } from "@ledgerhq/types-live";
import type { ThemedComponent } from "~/renderer/styles/StyleProvider";
import { centerEllipsis } from "~/renderer/styles/helpers";
import Fallback from "~/renderer/images/nftFallback.jpg";
type Props = {
metadata: NFTMetadata,
tokenId: string,
full?: boolean,
};
// TODO Figure out if we really need this once we know who creates/processes the media.
const StyledPlaceholder: ThemedComponent<Props> = styled.div`
--hue: ${p => (p?.tokenId || "abcdefg").substr(-8) % 360};
background-image: url('${Fallback}');
background-size: contain;
border-radius: 4px;
width: 100%;
height: 100%;
position: relative;
background-color: hsla(var(--hue), 55%, 66%, 1);
background-blend-mode: hard-light;
aspect-ratio: 1;
&:after {
display: ${p => (p.full ? "flex" : "none")}
content: "${p => p?.metadata?.nftName || centerEllipsis(p?.tokenId || "-")}";
font-size: 16px;
font-size: 1vw;
color: #fff;
padding: 0.1vh;
align-items: center;
justify-content: center;
text-align: center;
font-family: "Inter", Arial;
font-weight: 600;
width: 100%;
height: 100%;
}
`;
class Placeholder extends React.PureComponent<Props> {
render() {
const { metadata, tokenId } = this.props;
return <StyledPlaceholder metadata={metadata} tokenId={tokenId} />;
}
}
export default Placeholder;