import { Component, linkEvent } from 'inferno'; import { FramelyData } from '../interfaces'; import { mdToHtml } from '../utils'; interface FramelyCardProps { iframely: FramelyData; } interface FramelyCardState { expanded: boolean; } export class IFramelyCard extends Component< FramelyCardProps, FramelyCardState > { private emptyState: FramelyCardState = { expanded: false, }; constructor(props: any, context: any) { super(props, context); this.state = this.emptyState; } render() { let iframely = this.props.iframely; return ( <> {iframely.title && !this.state.expanded && (
{iframely.title}
{new URL(iframely.url).hostname} {iframely.html && ( {this.state.expanded ? '[-]' : '[+]'} )} {iframely.description && (
)}
)} {this.state.expanded && (
)} ); } handleIframeExpand(i: IFramelyCard) { i.state.expanded = !i.state.expanded; i.setState(i.state); } }