page-lead.js 665 B

1234567891011121314151617181920212223242526
  1. import React from 'react';
  2. import stringCount from 'misago/utils/string-count';
  3. export default class extends React.Component {
  4. getClassName() {
  5. if (this.props.copy && this.props.copy.length) {
  6. if (stringCount(this.props.copy, '<p') === 1 && this.props.copy.indexOf('<br') === -1) {
  7. return 'page-lead lead';
  8. }
  9. }
  10. return 'page-lead';
  11. }
  12. render() {
  13. if (this.props.copy && this.props.copy.length) {
  14. /* jshint ignore:start */
  15. return <div className={this.getClassName()} dangerouslySetInnerHTML={{
  16. __html: this.props.copy
  17. }} />;
  18. /* jshint ignore:end */
  19. } else {
  20. return null;
  21. }
  22. }
  23. }