All files / src/layout MasterDetailLayout.tsx

100% Statements 3/3
100% Branches 6/6
100% Functions 1/1
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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                          66x       39x   36x                                                    
import { Row, Col } from 'antd';
import React, { ReactElement } from 'react';
 
export interface MasterDetailLayoutProps {
  flex: string;
  leftOnClick: () => void;
  leftContent: ReactElement;
  rightVisible: boolean;
  rightContent: ReactElement;
  leftClassName?: string;
  rightClassName?: string;
}
 
const MasterDetailLayout = (props: MasterDetailLayoutProps): ReactElement => {
  const {
    flex, leftContent, leftOnClick, rightContent, rightVisible,
    leftClassName, rightClassName,
  } = props;
 
  return (
    <Row
      justify="end"
    >
      <Col
        flex={flex}
        onClick={leftOnClick}
        className={`md-layout-left ${leftClassName ?? ""}`}
        span={24}
      >
        {leftContent}
      </Col>
      {rightVisible &&
        <Col
          flex="auto"
          style={{ width: "1px" }}
          className={`md-layout-right ${rightClassName ?? ""}`}
          span={24}
        >
          {rightContent}
        </Col>}
    </Row>
  );
};
 
export default MasterDetailLayout;