section.tsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /* eslint-disable prefer-template */
  2. import React, { PureComponent } from 'react';
  3. import classNames from 'classnames';
  4. import PropTypes from 'prop-types';
  5. import { cssClasses } from '@douyinfe/semi-foundation/form/constants';
  6. const prefix = cssClasses.PREFIX;
  7. export interface SectionProps {
  8. className?: string;
  9. style?: React.CSSProperties;
  10. text?: React.ReactNode | string;
  11. children?: React.ReactNode;
  12. }
  13. export default class Section extends PureComponent<SectionProps> {
  14. static propTypes = {
  15. text: PropTypes.node,
  16. className: PropTypes.string,
  17. style: PropTypes.object,
  18. children: PropTypes.node,
  19. };
  20. render() {
  21. const { text, className, style, children } = this.props;
  22. const cls = classNames({
  23. [prefix + '-section']: true,
  24. }, className);
  25. const textCls = prefix + '-section-text';
  26. return (
  27. <section className={cls} style={style}>
  28. <h5 className={textCls}>{text}</h5>
  29. {children}
  30. </section>
  31. );
  32. }
  33. }