index.tsx 579 B

12345678910111213141516171819202122232425
  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. };
  8. type Ref = HTMLDivElement;
  9. const Viewer = forwardRef<Ref, Props>(
  10. ({ children, viewport, rotation }: Props, ref) => {
  11. const width =
  12. (Math.abs(rotation) / 90) % 2 === 1 ? viewport.height : viewport.width;
  13. return (
  14. <OuterWrapper id="pdf_viewer" ref={ref}>
  15. <Wrapper width={width}>{children}</Wrapper>
  16. </OuterWrapper>
  17. );
  18. },
  19. );
  20. export default Viewer;