-
Notifications
You must be signed in to change notification settings - Fork 77
/
Copy pathCardBody.tsx
58 lines (50 loc) · 1.18 KB
/
CardBody.tsx
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
52
53
54
55
56
57
58
import { EmailPCD, getEmailAddress } from "@pcd/email-pcd";
import { styled } from "@pcd/passport-ui";
import { PCDUI } from "@pcd/pcd-types";
export const EmailPCDUI: PCDUI<EmailPCD> = {
renderCardBody: EmailCardBody
};
function EmailCardBody({ pcd }: { pcd: EmailPCD }): JSX.Element {
const emailAddress = getEmailAddress(pcd);
if (!emailAddress) return <></>;
const [username, domain] = emailAddress.split("@");
return (
<Container>
<EmailInfo>
<EmailWrapper>
<Username>{username}</Username>
<Domain>@{domain}</Domain>
<div style={{ clear: "both" }} />
</EmailWrapper>
</EmailInfo>
</Container>
);
}
const Container = styled.span`
padding: 16px;
overflow: hidden;
width: 100%;
`;
const EmailInfo = styled.div`
margin-top: 8px;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
`;
const EmailWrapper = styled.div`
display: flex;
max-width: 80%;
overflow: hidden;
`;
const Username = styled.span`
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
flex: 1;
min-width: 0;
`;
const Domain = styled.span`
flex-shrink: 0;
margin-left: -1px;
`;