index.tsx 646 B

1234567891011121314151617181920212223242526
  1. import React, { forwardRef } from 'react';
  2. import { OuterWrapper, Wrapper } from './styled';
  3. type Props = {
  4. children: React.ReactNode;
  5. viewport: ViewportType;
  6. rotation: number;
  7. displayMode: string;
  8. };
  9. type Ref = HTMLDivElement;
  10. const Viewer = forwardRef<Ref, Props>(
  11. ({ children, viewport, rotation, displayMode }: Props, ref) => {
  12. const width =
  13. (Math.abs(rotation) / 90) % 2 === 1 ? viewport.height : viewport.width;
  14. return (
  15. <OuterWrapper id="pdf_viewer" ref={ref} isFull={displayMode === 'full'}>
  16. <Wrapper width={width}>{children}</Wrapper>
  17. </OuterWrapper>
  18. );
  19. }
  20. );
  21. export default Viewer;