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

mac-s-g / react-json-view / #2219

23 Dec 2025 09:56PM UTC coverage: 80.962%. First build
#2219

push

kenneth-matroid
working custom button icon

286 of 360 branches covered (79.44%)

Branch coverage included in aggregate %.

1 of 6 new or added lines in 2 files covered. (16.67%)

505 of 617 relevant lines covered (81.85%)

43.7 hits per line

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

0.0
/src/js/components/CustomButton.js
1
import React from 'react';
2

3
import { toType } from './../helpers/util';
4

5
//theme
6
import Theme from './../themes/getStyle';
7

8
export default class extends React.PureComponent {
9
    handleClick = () => {
×
NEW
10
        const { customButtonProps, src } = this.props;
×
NEW
11
        const { onClick } = customButtonProps;
×
12
        const valueFromSrc = this.clipboardValue(src);
×
13

14
        onClick(valueFromSrc);
×
15
    };
16

17
    clipboardValue = value => {
×
18
        const type = toType(value);
×
19
        switch (type) {
×
20
            case 'function':
21
            case 'regexp':
22
                return value.toString();
×
23
            default:
24
                return value;
×
25
        }
26
    };
27

28
    render() {
29
        const { theme, hidden, rowHovered, customButtonProps } = this.props;
×
30
        let style = Theme(theme, 'copy-to-clipboard').style;
×
31
        let display = 'inline';
×
32

NEW
33
        const { icon } = customButtonProps;
×
34

35
        if (hidden) {
×
36
            display = 'none';
×
37
        }
38

39
        return (
×
40
            <span
41
                className="copy-to-clipboard-container"
42
                title="Copy to clipboard"
43
                style={{
44
                    verticalAlign: 'top',
45
                    display: rowHovered ? 'inline-block' : 'none'
×
46
                }}
47
            >
48
                <span
49
                    style={{
50
                        ...style,
51
                        display: display
52
                    }}
53
                    onClick={e => {
NEW
54
                        e.stopPropagation();
×
NEW
55
                        this.handleClick();
×
56
                    }}
57
                >
58
                    {icon}
59
                </span>
60
            </span>
61
        );
62
    }
63
}
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