1 import { Component, linkEvent } from "inferno";
2 import { Post } from "lemmy-js-client";
3 import { i18n } from "../../i18next";
4 import { relTags } from "../../utils";
5 import { Icon } from "../common/icon";
7 interface MetadataCardProps {
11 interface MetadataCardState {
15 export class MetadataCard extends Component<
19 private emptyState: MetadataCardState = {
23 constructor(props: any, context: any) {
24 super(props, context);
25 this.state = this.emptyState;
29 let post = this.props.post;
32 {!this.state.expanded &&
33 post.embed_title.match({
37 <div className="card border-secondary mt-3 mb-2">
39 <div className="col-12">
40 <div className="card-body">
41 {post.name !== embedTitle && (
43 <h5 className="card-title d-inline">
52 <span className="d-inline-block ml-2 mb-2 small text-muted">
54 className="text-muted font-italic"
58 {new URL(url).hostname}
59 <Icon icon="external-link" classes="ml-1" />
64 {post.embed_description.match({
67 className="card-text small text-muted md-div"
68 dangerouslySetInnerHTML={{
75 {post.embed_video_url.isSome() && (
77 className="mt-2 btn btn-secondary text-monospace"
78 onClick={linkEvent(this, this.handleIframeExpand)}
79 data-tippy-content={i18n.t("expand_here")}
81 {this.state.expanded ? "-" : "+"}
93 {this.state.expanded &&
94 post.embed_video_url.match({
98 dangerouslySetInnerHTML={{ __html: html }}
107 handleIframeExpand(i: MetadataCard) {
108 i.setState({ expanded: !i.state.expanded });