File size: 1,106 Bytes
1e92f2d |
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 |
import { Gridicon } from '@automattic/components';
import clsx from 'clsx';
import { omit, startsWith } from 'lodash';
import PropTypes from 'prop-types';
const SharingButtonsPreviewAction = ( props ) => {
const { active, position, icon, children } = props;
const classes = clsx( 'sharing-buttons-preview-action', {
'is-active': active,
'is-top': startsWith( position, 'top' ),
'is-right': position.endsWith( '-right' ),
'is-bottom': startsWith( position, 'bottom' ),
'is-left': position.endsWith( '-left' ),
} );
return (
<button
type="button"
className={ classes }
{ ...omit( props, [ 'active', 'position', 'icon' ] ) }
>
{ icon && <Gridicon icon={ icon } size={ 18 } /> }
{ children }
</button>
);
};
SharingButtonsPreviewAction.propTypes = {
active: PropTypes.bool,
position: PropTypes.oneOf( [ 'top-left', 'top-right', 'bottom-left', 'bottom-right' ] ),
icon: PropTypes.string,
onClick: PropTypes.func,
};
SharingButtonsPreviewAction.defaultProps = {
active: true,
position: 'top-left',
onClick: () => {},
};
export default SharingButtonsPreviewAction;
|