DescriptionList.js 826 Bytes
Newer Older
1 2 3 4 5
import React from 'react';
import classNames from 'classnames';
import { Row } from 'antd';
import styles from './index.less';

ZHAO Jinxiang's avatar
ZHAO Jinxiang committed
6
const DescriptionList = ({
jim's avatar
jim committed
7 8 9 10 11 12 13 14 15
  className,
  title,
  col = 3,
  layout = 'horizontal',
  gutter = 32,
  children,
  size,
  ...restProps
}) => {
16
  const clsString = classNames(styles.descriptionList, styles[layout], className, {
17 18
    [styles.small]: size === 'small',
    [styles.large]: size === 'large',
19
  });
20 21 22 23 24
  const column = col > 4 ? 4 : col;
  return (
    <div className={clsString} {...restProps}>
      {title ? <div className={styles.title}>{title}</div> : null}
      <Row gutter={gutter}>
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
25 26 27 28
        {React.Children.map(
          children,
          child => (child ? React.cloneElement(child, { column }) : child)
        )}
29 30 31 32
      </Row>
    </div>
  );
};
ZHAO Jinxiang's avatar
ZHAO Jinxiang committed
33 34

export default DescriptionList;