-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3abd2a9
commit e874cd4
Showing
8 changed files
with
222 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React, { MouseEventHandler, ReactNode } from 'react'; | ||
import styled, { css } from 'styled-components'; | ||
import { Styles } from 'styled-components/dist/types'; | ||
|
||
const ButtonContainer = styled.button<{ styleOverride?: Styles<object> }>` | ||
text-decoration: none; | ||
color: black; | ||
background-color: transparent; | ||
border: unset; | ||
cursor: pointer; | ||
font-size: 1rem; | ||
${props => props.styleOverride && css(props.styleOverride)} | ||
`; | ||
|
||
interface ButtonProps { | ||
children: ReactNode; | ||
onClick?: MouseEventHandler<HTMLButtonElement> | undefined; | ||
styleOverride?: Styles<object>; | ||
} | ||
|
||
const Button = ({ children, onClick, styleOverride }: ButtonProps) => { | ||
return ( | ||
<ButtonContainer onClick={onClick} styleOverride={styleOverride}> | ||
{children} | ||
</ButtonContainer> | ||
); | ||
}; | ||
|
||
export default Button; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import React, { useEffect } from 'react'; | ||
import styled from 'styled-components'; | ||
import CloseIcon from '@mui/icons-material/Close'; | ||
import Button from '../components/common/Button'; | ||
import { createPortal } from 'react-dom'; | ||
import firebase from '../services/firebase'; | ||
import PDFViewerClient from '../services/PDFViewerClient'; | ||
|
||
const ResumeModalContainer = styled.div` | ||
background-color: #fbfcf8; | ||
width: 100vw; | ||
height: 100vh; | ||
position: fixed; | ||
top: 150%; | ||
visibility: hidden; | ||
transition: top 0.7s ease-in-out, visibility 0.7s ease-in-out; | ||
will-change: top, visibility; | ||
z-index: 1; | ||
&.is-visible { | ||
visibility: visible; | ||
top: 0; | ||
} | ||
`; | ||
|
||
const ResumeTopBarContainer = styled.div` | ||
display: flex; | ||
justify-content: end; | ||
`; | ||
|
||
const ResumeContentContainer = styled.div` | ||
height: 100%; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
`; | ||
|
||
interface ResumeModalProps { | ||
isVisible: boolean; | ||
onClose: () => void; | ||
} | ||
|
||
const ResumeModal = ({ isVisible, onClose }: ResumeModalProps) => { | ||
useEffect(() => { | ||
if (isVisible) { | ||
document.body.style.overflowY = 'hidden'; | ||
firebase.analytics.logEvent('resume_viewed'); | ||
} else { | ||
document.body.style.overflowY = 'scroll'; | ||
} | ||
}, [isVisible]); | ||
|
||
useEffect(() => { | ||
const pdfViewerClient = new PDFViewerClient('resume-content-container'); | ||
pdfViewerClient.previewFile('https://api.adrianleung.dev/resume', { | ||
embedMode: 'SIZED_CONTAINER', | ||
showAnnotationTools: false, | ||
enableFormFilling: false, | ||
showDownloadPDF: true, | ||
showPrintPDF: false, | ||
showZoomControl: true, | ||
showFullScreenViewButton: false, | ||
showFullScreen: false, | ||
defaultViewMode: 'FIT_PAGE', | ||
}); | ||
}, []); | ||
|
||
return createPortal( | ||
<ResumeModalContainer className={isVisible ? 'is-visible' : ''}> | ||
<ResumeTopBarContainer> | ||
<Button onClick={onClose}>{<CloseIcon />}</Button> | ||
</ResumeTopBarContainer> | ||
<ResumeContentContainer id='resume-content-container'></ResumeContentContainer> | ||
</ResumeModalContainer>, | ||
document.body | ||
); | ||
}; | ||
|
||
export default ResumeModal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
interface ViewConfig { | ||
embedMode?: 'FULL_WINDOW' | 'IN_LINE' | 'LIGHT_BOX' | 'SIZED_CONTAINER'; | ||
showAnnotationTools?: boolean; | ||
enableFormFilling?: boolean; | ||
showDownloadPDF?: boolean; | ||
showPrintPDF?: boolean; | ||
showZoomControl?: boolean; | ||
showFullScreenViewButton?: boolean; | ||
showFullScreen?: boolean; | ||
defaultViewMode?: | ||
| 'FIT_PAGE' | ||
| 'FIT_WIDTH' | ||
| 'TWO_COLUMN' | ||
| 'TWO_COLUMN_FIT_PAGE'; | ||
} | ||
|
||
interface FileContent { | ||
content: { | ||
location: { | ||
url: string; | ||
}; | ||
}; | ||
metaData: { | ||
fileName: string; | ||
}; | ||
} | ||
|
||
interface AdobeDCView { | ||
previewFile: (fileContent: FileContent, viewConfig: ViewConfig) => void; | ||
} | ||
|
||
class PDFViewerClient { | ||
config: object = { | ||
clientId: 'e4e1feeff1db47a1a9a218a37a77d502', | ||
}; | ||
|
||
adobeDCView: AdobeDCView | undefined = undefined; | ||
|
||
constructor(divId?: string) { | ||
this.config = { ...this.config, divId }; | ||
if ((window as any).AdobeDC) { | ||
this.adobeDCView = new (window as any).AdobeDC.View(this.config); | ||
} else { | ||
document.addEventListener('adobe_dc_view_sdk.ready', () => { | ||
this.adobeDCView = new (window as any).AdobeDC.View(this.config); | ||
}); | ||
} | ||
} | ||
|
||
previewFile(url: string, viewConfig: ViewConfig) { | ||
if (this.adobeDCView) { | ||
this.adobeDCView.previewFile( | ||
{ | ||
content: { | ||
location: { | ||
url, | ||
}, | ||
}, | ||
metaData: { | ||
fileName: 'Resume_AdrianLeung.pdf', | ||
}, | ||
}, | ||
viewConfig | ||
); | ||
} | ||
} | ||
} | ||
export default PDFViewerClient; |