• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

react-ui-org / react-ui / 14831340595

05 May 2025 07:31AM UTC coverage: 77.116% (-13.2%) from 90.283%
14831340595

Pull #636

github

web-flow
Merge c233dddc7 into b73b8ec0f
Pull Request #636: Refactoring/miscellaneous jest to playwright

626 of 897 branches covered (69.79%)

Branch coverage included in aggregate %.

695 of 816 relevant lines covered (85.17%)

43.59 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.71
/src/components/Text/Text.jsx
1
import PropTypes from 'prop-types';
2
import React from 'react';
3
import { withGlobalProps } from '../../providers/globalProps';
4
import { classNames } from '../../helpers/classNames/classNames';
5
import { transferProps } from '../../helpers/transferProps';
6
import { isChildrenEmpty } from '../_helpers/isChildrenEmpty';
7
import { getRootClampClassName } from './_helpers/getRootClampClassName';
8
import { getRootHyphensClassName } from './_helpers/getRootHyphensClassName';
9
import { getRootWordWrappingClassName } from './_helpers/getRootWordWrappingClassName';
10
import styles from './Text.module.scss';
11

12
export const Text = ({
8✔
13
  blockLevel,
14
  children,
15
  hyphens,
16
  lines,
17
  wordWrapping,
18
  ...restProps
19
}) => {
20
  if (isChildrenEmpty(children)) {
56!
21
    return null;
×
22
  }
23

24
  const HtmlElement = blockLevel ? 'div' : 'span';
56✔
25

26
  return (
56✔
27
    <HtmlElement
28
      {...transferProps(restProps)}
29
      className={(hyphens !== 'none' || lines > 0 || wordWrapping !== 'normal')
86✔
30
        ? classNames(
31
          getRootClampClassName(lines, styles),
32
          getRootHyphensClassName(hyphens, styles),
33
          getRootWordWrappingClassName(wordWrapping, styles),
34
        )
35
        : undefined}
36
      style={(lines > 1) ? { '--rui-custom-lines': lines } : undefined}
28!
37
    >
38
      {children}
39
    </HtmlElement>
40
  );
41
};
42

43
Text.defaultProps = {
8✔
44
  blockLevel: false,
45
  children: null,
46
  hyphens: 'none',
47
  lines: undefined,
48
  wordWrapping: 'normal',
49
};
50

51
Text.propTypes = {
8✔
52
  /**
53
   * If true, the root HTML element renders as `<div>` instead of `<span>`.
54
   */
55
  blockLevel: PropTypes.bool,
56
  /**
57
   * Text content to be sanitized. Can contain HTML.
58
   */
59
  children: PropTypes.node,
60
  /**
61
   * Turn on hyphenation. Head to [Hyphens](#hyphens) to learn more.
62
   */
63
  hyphens: PropTypes.oneOf(['none', 'auto', 'manual']),
64
  /**
65
   * Optional number of lines. If exceeded, the content is truncated and appended by an ellipsis (`…`).
66
   */
67
  lines: PropTypes.number,
68
  /**
69
   * How to deal with long words. Head to [Word Wrapping](#word-wrapping) for detailed explanation.
70
   */
71
  wordWrapping: PropTypes.oneOf(['normal', 'long-words', 'anywhere']),
72
};
73

74
export const TextWithGlobalProps = withGlobalProps(Text, 'Text');
8✔
75

76
export default TextWithGlobalProps;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc