dropdownTitle.tsx 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import React, { PureComponent } from 'react';
  2. import PropTypes from 'prop-types';
  3. import { cssClasses } from '@douyinfe/semi-foundation/dropdown/constants';
  4. import cls from 'classnames';
  5. import DropdownContext from './context';
  6. import { BaseProps } from '../_base/baseComponent';
  7. const prefixCls = cssClasses.PREFIX;
  8. export type DropdownTitleProps = BaseProps;
  9. class DropdownTitle extends PureComponent<DropdownTitleProps> {
  10. static propTypes = {
  11. children: PropTypes.node,
  12. className: PropTypes.string,
  13. style: PropTypes.object,
  14. };
  15. static contextType = DropdownContext;
  16. render() {
  17. const { className, style, children } = this.props;
  18. const { showTick } = this.context;
  19. const titleCls = cls({
  20. [`${prefixCls}-title`]: true,
  21. [`${prefixCls}-title-withTick`]: showTick,
  22. }, className);
  23. return (
  24. <div className={titleCls} style={style}>
  25. {children}
  26. </div>
  27. );
  28. }
  29. }
  30. export default DropdownTitle;