1 import { Component, linkEvent } from "inferno";
2 import { PersonView, Site, SiteAggregates } from "lemmy-js-client";
3 import { i18n } from "../../i18next";
4 import { mdToHtml } from "../../utils";
5 import { Badges } from "../common/badges";
6 import { BannerIconHeader } from "../common/banner-icon-header";
7 import { Icon } from "../common/icon";
8 import { PersonListing } from "../person/person-listing";
10 interface SiteSidebarProps {
13 counts?: SiteAggregates;
14 admins?: PersonView[];
18 interface SiteSidebarState {
22 export class SiteSidebar extends Component<SiteSidebarProps, SiteSidebarState> {
23 state: SiteSidebarState = {
27 constructor(props: any, context: any) {
28 super(props, context);
33 <div className="accordion">
34 <section id="sidebarInfo" className="card border-secondary mb-3">
36 className="card-header d-flex align-items-center"
37 id="sidebarInfoHeader"
40 {!this.state.collapsed && (
41 <BannerIconHeader banner={this.props.site.banner} />
47 className="collapse show"
48 aria-labelledby="sidebarInfoHeader"
50 <div className="card-body">{this.siteInfo()}</div>
60 <h5 className="mb-0 d-inline">{this.props.site.name}</h5>
61 {!this.props.isMobile && (
64 className="btn btn-sm"
65 onClick={linkEvent(this, this.handleCollapseSidebar)}
67 this.state.collapsed ? i18n.t("expand") : i18n.t("collapse")
70 this.state.collapsed ? i18n.t("expand") : i18n.t("collapse")
72 data-bs-toggle="collapse"
73 data-bs-target="#sidebarInfoBody"
75 aria-controls="sidebarInfoBody"
77 {this.state.collapsed ? (
78 <Icon icon="plus-square" classes="icon-inline" />
80 <Icon icon="minus-square" classes="icon-inline" />
89 const site = this.props.site;
92 {site.description && <h6>{site.description}</h6>}
93 {site.sidebar && this.siteSidebar(site.sidebar)}
94 {this.props.counts && <Badges counts={this.props.counts} />}
95 {this.props.admins && this.admins(this.props.admins)}
100 siteSidebar(sidebar: string) {
102 <div className="md-div" dangerouslySetInnerHTML={mdToHtml(sidebar)} />
106 admins(admins: PersonView[]) {
108 <ul className="mt-1 list-inline small mb-0">
109 <li className="list-inline-item">{i18n.t("admins")}:</li>
111 <li key={av.person.id} className="list-inline-item">
112 <PersonListing person={av.person} />
119 handleCollapseSidebar(i: SiteSidebar) {
120 i.setState({ collapsed: !i.state.collapsed });