import clsx from 'clsx'; import { localize } from 'i18n-calypso'; import PropTypes from 'prop-types'; import { Component } from 'react'; import FormTextInput from 'calypso/components/forms/form-text-input'; import { decodeEntities } from 'calypso/lib/formatting'; const closeKeyCodes = [ 13, // Return 27, // Escape ]; class SharingButtonsLabelEditor extends Component { static displayName = 'SharingButtonsLabelEditor'; static propTypes = { active: PropTypes.bool, value: PropTypes.string, onChange: PropTypes.func, onClose: PropTypes.func, hasEnabledButtons: PropTypes.bool, }; static defaultProps = { active: false, value: '', onChange: function () {}, onClose: function () {}, hasEnabledButtons: true, }; onKeyDown = ( event ) => { if ( -1 !== closeKeyCodes.indexOf( event.keyCode ) ) { event.target.blur(); event.preventDefault(); this.props.onClose(); } }; onInputChange = ( event ) => { this.props.onChange( event.target.value ); }; getNoButtonsNoticeElement = () => { if ( ! this.props.hasEnabledButtons ) { return ( { this.props.translate( "This text won't appear until you add at least one sharing button.", { context: 'Sharing: Buttons', } ) } ); } }; render() { const classes = clsx( 'sharing-buttons-preview__panel', 'is-top', 'sharing-buttons-label-editor', { 'is-active': this.props.active, } ); return (
{ this.props.translate( 'Change the text of the sharing buttons label' ) }