fluidPanel.tsx 711 B

123456789101112131415161718192021222324252627282930313233
  1. import {LegacyRef, ReactChild} from 'react';
  2. import styled from '@emotion/styled';
  3. type Props = {
  4. children: ReactChild;
  5. bodyRef?: LegacyRef<HTMLDivElement> | undefined;
  6. bottom?: ReactChild;
  7. className?: string;
  8. title?: ReactChild;
  9. };
  10. function FluidPanel({className, children, bottom, title, bodyRef}: Props) {
  11. return (
  12. <FluidContainer className={className}>
  13. {title}
  14. <OverflowBody ref={bodyRef}>{children}</OverflowBody>
  15. {bottom}
  16. </FluidContainer>
  17. );
  18. }
  19. const FluidContainer = styled('section')`
  20. display: grid;
  21. grid-template-rows: auto 1fr auto;
  22. height: 100%;
  23. `;
  24. const OverflowBody = styled('div')`
  25. height: 100%;
  26. overflow: auto;
  27. `;
  28. export default FluidPanel;