-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathindex.tsx
67 lines (55 loc) · 1.39 KB
/
index.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
59
60
61
62
63
64
65
66
67
import React, { lazy, Suspense } from "react";
import styled from "styled-components";
import { useSearchParams } from "react-router-dom";
import NewTabIcon from "svgs/icons/new-tab.svg";
import Loader from "components/Loader";
import Header from "./Header";
const FileViewer = lazy(() => import("components/FileViewer"));
const Container = styled.div`
width: 100%;
display: flex;
flex-direction: column;
gap: 8px;
`;
const LoaderContainer = styled.div`
width: 100%;
display: flex;
justify-content: center;
`;
const NewTabInfo = styled.a`
align-self: flex-end;
display: flex;
gap: 8px;
align-items: center;
`;
const StyledNewTabIcon = styled(NewTabIcon)`
path {
fill: ${({ theme }) => theme.primaryBlue};
}
`;
const AttachmentDisplay: React.FC = () => {
const [searchParams] = useSearchParams();
const url = searchParams.get("url");
return (
<Container>
<Header />
{url ? (
<>
<NewTabInfo href={url} rel="noreferrer" target="_blank">
Open in new tab <StyledNewTabIcon />
</NewTabInfo>
<Suspense
fallback={
<LoaderContainer>
<Loader width={"48px"} height={"48px"} />
</LoaderContainer>
}
>
<FileViewer url={url} />
</Suspense>
</>
) : null}
</Container>
);
};
export default AttachmentDisplay;