From 55f91ac5dc1816463fb99d6974f89acd46de3444 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Mon, 17 Feb 2020 11:18:01 -0500 Subject: First pass at adding oembeds / iframely. --- ui/src/components/iframely-card.tsx | 100 ++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 ui/src/components/iframely-card.tsx (limited to 'ui/src/components/iframely-card.tsx') diff --git a/ui/src/components/iframely-card.tsx b/ui/src/components/iframely-card.tsx new file mode 100644 index 00000000..73f3cef7 --- /dev/null +++ b/ui/src/components/iframely-card.tsx @@ -0,0 +1,100 @@ +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.thumbnail_url && ( +
+ {iframely.html ? ( + + + + ) : ( + + )} +
+ )} +
+
+
+ + + {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); + } +} -- cgit v1.2.3