1 import { Component, linkEvent } from "inferno";
2 import { Post } from "lemmy-js-client";
3 import { mdToHtml } from "../utils";
4 import { i18n } from "../i18next";
5 import { Icon } from "./icon";
7 interface FramelyCardProps {
11 interface FramelyCardState {
15 export class IFramelyCard extends Component<
19 private emptyState: FramelyCardState = {
23 constructor(props: any, context: any) {
24 super(props, context);
25 this.state = this.emptyState;
29 let post = this.props.post;
32 {post.embed_title && !this.state.expanded && (
33 <div class="card border-secondary mt-3 mb-2">
36 <div class="card-body">
37 {post.name !== post.embed_title && [
38 <h5 class="card-title d-inline">
39 <a class="text-body" href={post.url} rel="noopener">
43 <span class="d-inline-block ml-2 mb-2 small text-muted">
45 class="text-muted font-italic"
49 {new URL(post.url).hostname}
50 <Icon icon="external-link" classes="ml-1" />
54 {post.embed_description && (
56 className="card-text small text-muted md-div"
57 dangerouslySetInnerHTML={mdToHtml(post.embed_description)}
62 class="mt-2 btn btn-secondary text-monospace"
63 onClick={linkEvent(this, this.handleIframeExpand)}
64 data-tippy-content={i18n.t("expand_here")}
66 {this.state.expanded ? "-" : "+"}
74 {this.state.expanded && (
77 dangerouslySetInnerHTML={{ __html: post.embed_html }}
84 handleIframeExpand(i: IFramelyCard) {
85 i.state.expanded = !i.state.expanded;