import React from 'react'; import _DropdownMenu from '../toolbar/_dropdown-menu'; import { getStyleIcon } from '../util/icon-util'; export default class LinkButton extends _DropdownMenu { constructor(props) { super(props) } specificState() { return { textValue: '' }; } // HANDLERS ----- handleClickInside() { const { isApplied, removeEntity, applyPseudoSelection } = this.props; if (isApplied) { removeEntity(); } else { applyPseudoSelection(); } } handleTextChange(e) { e.preventDefault(); this.setState({ textValue: e.currentTarget.value }); } handleSubmit(e) { e.preventDefault(); this.props.applyEntity('LINK', 'MUTABLE', { url: this.state.textValue }); this.setState({ textValue: '' }); this.toggleExpansion(); } // RENDERING ----- render() { const { isExpanded } = this.state; const buttonProps = { ref: 'button', className: ( 'style-button menu-button image-icon ' + (this.props.isApplied || isExpanded ? ' pressed' : '') ), onMouseDown: this.handleMouseDown, }; return (
{ this.renderIcon() }
{ this.renderMenu() }
); } renderIcon() { const { isApplied } = this.props; const { isExpanded } = this.state; let styleCode = isApplied ? 'unlink' : 'link'; return getStyleIcon(styleCode, isApplied || isExpanded); } renderMenu() { const { isExpanded } = this.state; return (

URL:

); } }