mirror of
https://github.com/LemmyNet/joinlemmy-site.git
synced 2024-11-22 04:11:15 +00:00
* Dont render detailsmodal until clicked. Fixes #261 * Make true.
This commit is contained in:
parent
bd97a9337f
commit
e5c3f406ae
1 changed files with 84 additions and 61 deletions
|
@ -93,20 +93,36 @@ const InstanceCardGrid = ({ instances }: InstanceCardGridProps) => (
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
interface InstanceCardProps {
|
|
||||||
instance: any;
|
|
||||||
}
|
|
||||||
|
|
||||||
function buildUrl(domain: string): string {
|
function buildUrl(domain: string): string {
|
||||||
return `https://${domain}`;
|
return `https://${domain}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const InstanceCard = ({ instance }: InstanceCardProps) => {
|
interface InstanceCardProps {
|
||||||
|
instance: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface InstanceCardState {
|
||||||
|
showModal: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
class InstanceCard extends Component<InstanceCardProps, InstanceCardState> {
|
||||||
|
state: InstanceCardState = {
|
||||||
|
showModal: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
constructor(props: any, context: any) {
|
||||||
|
super(props, context);
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const instance = this.props.instance;
|
||||||
|
|
||||||
const domain = instance.domain;
|
const domain = instance.domain;
|
||||||
const description = instance.site_info.site_view.site.description;
|
const description = instance.site_info.site_view.site.description;
|
||||||
const sidebar = instance.site_info.site_view.site.sidebar || description;
|
const sidebar = instance.site_info.site_view.site.sidebar || description;
|
||||||
const icon =
|
const icon =
|
||||||
instance.site_info.site_view.site.icon || "/static/assets/images/lemmy.svg";
|
instance.site_info.site_view.site.icon ||
|
||||||
|
"/static/assets/images/lemmy.svg";
|
||||||
const banner = instance.site_info.site_view.site.banner;
|
const banner = instance.site_info.site_view.site.banner;
|
||||||
const users = instance.site_info.site_view.counts.users;
|
const users = instance.site_info.site_view.counts.users;
|
||||||
const comments = instance.site_info.site_view.counts.comments;
|
const comments = instance.site_info.site_view.counts.comments;
|
||||||
|
@ -120,6 +136,7 @@ const InstanceCard = ({ instance }: InstanceCardProps) => {
|
||||||
<div className="card card-bordered bg-neutral-900 shadow-xl">
|
<div className="card card-bordered bg-neutral-900 shadow-xl">
|
||||||
<div className="card-body p-4">
|
<div className="card-body p-4">
|
||||||
<div className="flex flex-row flex-wrap gap-4">
|
<div className="flex flex-row flex-wrap gap-4">
|
||||||
|
{this.state.showModal && (
|
||||||
<DetailsModal
|
<DetailsModal
|
||||||
id={modalId}
|
id={modalId}
|
||||||
domain={domain}
|
domain={domain}
|
||||||
|
@ -131,6 +148,7 @@ const InstanceCard = ({ instance }: InstanceCardProps) => {
|
||||||
sidebar={sidebar}
|
sidebar={sidebar}
|
||||||
registrationMode={registrationMode}
|
registrationMode={registrationMode}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
<InstanceIcon domain={domain} icon={icon} />
|
<InstanceIcon domain={domain} icon={icon} />
|
||||||
<InstanceStats
|
<InstanceStats
|
||||||
users={users}
|
users={users}
|
||||||
|
@ -154,9 +172,7 @@ const InstanceCard = ({ instance }: InstanceCardProps) => {
|
||||||
</a>
|
</a>
|
||||||
<button
|
<button
|
||||||
className="btn btn-secondary btn-outline text-white max-md:btn-block normal-case"
|
className="btn btn-secondary btn-outline text-white max-md:btn-block normal-case"
|
||||||
onClick={() =>
|
onClick={linkEvent(this, handleModalClick)}
|
||||||
(document.getElementById(modalId) as any).showModal()
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
{i18n.t("more_information")}
|
{i18n.t("more_information")}
|
||||||
</button>
|
</button>
|
||||||
|
@ -164,7 +180,14 @@ const InstanceCard = ({ instance }: InstanceCardProps) => {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleModalClick(i: InstanceCard) {
|
||||||
|
const modalId = `modal_${i.props.instance.domain}`;
|
||||||
|
i.setState({ showModal: true });
|
||||||
|
(document.getElementById(modalId) as any).showModal();
|
||||||
|
}
|
||||||
|
|
||||||
const imgError =
|
const imgError =
|
||||||
"this.onError=null;this.src='/static/assets/images/lemmy.svg';" as unknown as InfernoEventHandler<HTMLImageElement>;
|
"this.onError=null;this.src='/static/assets/images/lemmy.svg';" as unknown as InfernoEventHandler<HTMLImageElement>;
|
||||||
|
|
Loading…
Reference in a new issue