section.tsx 1.0 KB

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