mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 04:44:37 +03:00
114 lines
3.0 KiB
TypeScript
114 lines
3.0 KiB
TypeScript
import React from "react";
|
|
import { Link } from "react-router-dom";
|
|
import * as GQL from "src/core/generated-graphql";
|
|
import { TextUtils } from "src/utils";
|
|
import { TagLink, TruncatedText } from "src/components/Shared";
|
|
import { PerformerCard } from "src/components/Performers/PerformerCard";
|
|
import { RatingStars } from "src/components/Scenes/SceneDetails/RatingStars";
|
|
|
|
interface IImageDetailProps {
|
|
image: GQL.ImageDataFragment;
|
|
}
|
|
|
|
export const ImageDetailPanel: React.FC<IImageDetailProps> = (props) => {
|
|
function renderTags() {
|
|
if (props.image.tags.length === 0) return;
|
|
const tags = props.image.tags.map((tag) => (
|
|
<TagLink key={tag.id} tag={tag} tagType="image" />
|
|
));
|
|
return (
|
|
<>
|
|
<h6>Tags</h6>
|
|
{tags}
|
|
</>
|
|
);
|
|
}
|
|
|
|
function renderPerformers() {
|
|
if (props.image.performers.length === 0) return;
|
|
const cards = props.image.performers.map((performer) => (
|
|
<PerformerCard key={performer.id} performer={performer} />
|
|
));
|
|
|
|
return (
|
|
<>
|
|
<h6>Performers</h6>
|
|
<div className="row justify-content-center image-performers">
|
|
{cards}
|
|
</div>
|
|
</>
|
|
);
|
|
}
|
|
|
|
function renderGalleries() {
|
|
if (props.image.galleries.length === 0) return;
|
|
const tags = props.image.galleries.map((gallery) => (
|
|
<TagLink key={gallery.id} gallery={gallery} />
|
|
));
|
|
return (
|
|
<>
|
|
<h6>Galleries</h6>
|
|
{tags}
|
|
</>
|
|
);
|
|
}
|
|
|
|
// filename should use entire row if there is no studio
|
|
const imageDetailsWidth = props.image.studio ? "col-9" : "col-12";
|
|
|
|
return (
|
|
<>
|
|
<div className="row">
|
|
<div className={`${imageDetailsWidth} col-xl-12 image-details`}>
|
|
<div className="image-header d-xl-none">
|
|
<h3>
|
|
<TruncatedText
|
|
text={
|
|
props.image.title ??
|
|
TextUtils.fileNameFromPath(props.image.path)
|
|
}
|
|
/>
|
|
</h3>
|
|
</div>
|
|
{props.image.rating ? (
|
|
<h6>
|
|
Rating: <RatingStars value={props.image.rating} />
|
|
</h6>
|
|
) : (
|
|
""
|
|
)}
|
|
{renderGalleries()}
|
|
{props.image.file.width && props.image.file.height ? (
|
|
<h6>
|
|
Resolution:{" "}
|
|
{TextUtils.resolution(
|
|
props.image.file.width,
|
|
props.image.file.height
|
|
)}
|
|
</h6>
|
|
) : (
|
|
""
|
|
)}
|
|
</div>
|
|
{props.image.studio && (
|
|
<div className="col-3 d-xl-none">
|
|
<Link to={`/studios/${props.image.studio.id}`}>
|
|
<img
|
|
src={props.image.studio.image_path ?? ""}
|
|
alt={`${props.image.studio.name} logo`}
|
|
className="studio-logo float-right"
|
|
/>
|
|
</Link>
|
|
</div>
|
|
)}
|
|
</div>
|
|
<div className="row">
|
|
<div className="col-12">
|
|
{renderTags()}
|
|
{renderPerformers()}
|
|
</div>
|
|
</div>
|
|
</>
|
|
);
|
|
};
|