All files / ExampleComponent ExampleComponent.tsx

83.33% Statements 5/6
100% Branches 0/0
50% Functions 1/2
83.33% Lines 5/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83            1x 1x                     1x                                                                                               6x   6x                            
// Required for all new components
import React from 'react';
import PropTypes from 'prop-types';
import { lucidClassNames } from '../../util/style-helpers';
import { createClass } from '../../util/component-types';
 
const cx = lucidClassNames.bind('&-ExampleComponent');
const { bool, func, node, string, object } = PropTypes;
 
/**
 * {"categories": ["mycategory"]}
 *
 * Update "mycategory" to set the category your component falls under. You can see available categories
 * in the left hand column.
 *
 * Describe your component here. How it should be used, use cases and more.
 * Please see examples for more information.
 */
const ExampleComponent = createClass({
	displayName: 'ExampleComponent',
 
	// reducers,
	// selectors,
 
	// Each prop in propTypes should include a description using /* */ of what
	// the prop is and how it should be used by other developers who consume your
	// component.
	propTypes: {
		/**
		 * Appended to the component-specific class names set on the root
		 * element.
		 */
		className: string,
 
		/**
		 * Any valid React children. This wraps your new component around whatever other React children consumers
		 * of your component may choose to use. If consumers can not use any/all React children. Be sure to call
		 * that out here.
		 */
		children: node,
 
		/**
		 * Example of a boolean prop.
		 * Used in this example to control an additional classname
		 * `lucid-ExampleComponent-isX' on the root element.
		 */
		isX: bool,
 
		/**
		 * Example of a customizable component function. Always show the signature.
		 *
		 * Signature: `(item, { event, props }) => {}`
		 */
		onX: func,
 
		/**
		 * Passed through to the root element.
		 */
		style: object,
	},
 
	handleX() {
		alert('This is an example of a handler function');
	},
 
	render() {
		const { className, children, isX, style } = this.props as any;
 
		return (
			<div
				className={cx('&', className, {
					'&-isX': isX,
				})}
				style={style}
			>
				{children}
			</div>
		);
	},
});
 
export default ExampleComponent;