import * as React from 'react'; import { className, LinkWrapper, Wrapper, Header, IconWrapper, TextWrapper, Content, } from './styled'; export interface ExpandedFrameProps { isPlaceholder?: boolean; href?: string; icon?: React.ReactElement; text?: React.ReactNode; minWidth?: number; maxWidth?: number; children?: React.ReactNode; /** A flag that determines whether the card is selected in edit mode. */ isSelected?: boolean; /** The optional click handler */ onClick?: () => void; } export class ExpandedFrame extends React.Component { get isInteractive() { const { isPlaceholder, href, onClick } = this.props; return !isPlaceholder && (Boolean(href) || Boolean(onClick)); } handleClick = (event: React.MouseEvent) => { const { onClick } = this.props; if (onClick) { event.preventDefault(); event.stopPropagation(); onClick(); } }; renderHeader() { const { isPlaceholder = false, icon, text } = this.props; return (
{!isPlaceholder && icon} {!isPlaceholder && text}
); } renderContent() { const { isInteractive } = this; const { children } = this.props; return {children}; } render() { const { isInteractive } = this; const { isPlaceholder, isSelected, href, minWidth, maxWidth } = this.props; if (!isPlaceholder && href) { return ( {this.renderHeader()} {this.renderContent()} ); } else { return ( {this.renderHeader()} {this.renderContent()} ); } } }