mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-02 14:16:39 +01:00
Group similar captions
Some folks really just copy/paste same desc for multiple media's
This commit is contained in:
parent
ed8c9e994b
commit
9786752a4f
2 changed files with 71 additions and 27 deletions
|
@ -1015,32 +1015,41 @@ body:has(#modal-container .carousel) .status .media img:hover {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
|
display: inline-flex;
|
||||||
|
gap: 4px;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
color: var(--text-color);
|
color: var(--text-color);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&:only-child {
|
||||||
|
white-space: pre-line;
|
||||||
|
overflow: auto;
|
||||||
|
text-overflow: unset;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sup {
|
sup {
|
||||||
opacity: 0.75;
|
opacity: 0.75;
|
||||||
font-variant-numeric: tabular-nums;
|
font-variant-numeric: tabular-nums;
|
||||||
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Only 4, for now. Would be better if this is a for loop */
|
/* Only 4, for now. Would be better if this is a for loop */
|
||||||
&:has(.media[data-has-alt]:nth-child(1):is(:hover, :focus))
|
&:has(.media[data-has-alt]:nth-child(1):is(:hover, :focus))
|
||||||
figcaption
|
figcaption
|
||||||
> div[data-caption-index='1'],
|
> div[data-caption-index~='1'],
|
||||||
&:has(.media[data-has-alt]:nth-child(2):is(:hover, :focus))
|
&:has(.media[data-has-alt]:nth-child(2):is(:hover, :focus))
|
||||||
figcaption
|
figcaption
|
||||||
> div[data-caption-index='2'],
|
> div[data-caption-index~='2'],
|
||||||
&:has(.media[data-has-alt]:nth-child(3):is(:hover, :focus))
|
&:has(.media[data-has-alt]:nth-child(3):is(:hover, :focus))
|
||||||
figcaption
|
figcaption
|
||||||
> div[data-caption-index='3'],
|
> div[data-caption-index~='3'],
|
||||||
&:has(.media[data-has-alt]:nth-child(4):is(:hover, :focus))
|
&:has(.media[data-has-alt]:nth-child(4):is(:hover, :focus))
|
||||||
figcaption
|
figcaption
|
||||||
> div[data-caption-index='4'] {
|
> div[data-caption-index~='4'] {
|
||||||
color: var(--text-color);
|
color: var(--text-color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -877,6 +877,62 @@ function Status({
|
||||||
displayedMediaAttachments.some(
|
displayedMediaAttachments.some(
|
||||||
(media) => !!media.description && !isMediaCaptionLong(media.description),
|
(media) => !!media.description && !isMediaCaptionLong(media.description),
|
||||||
);
|
);
|
||||||
|
const captionChildren = useMemo(() => {
|
||||||
|
if (!showMultipleMediaCaptions) return null;
|
||||||
|
const attachments = [];
|
||||||
|
displayedMediaAttachments.forEach((media, i) => {
|
||||||
|
if (!media.description) return;
|
||||||
|
const index = attachments.findIndex(
|
||||||
|
(attachment) => attachment.media.description === media.description,
|
||||||
|
);
|
||||||
|
if (index === -1) {
|
||||||
|
attachments.push({
|
||||||
|
media,
|
||||||
|
indices: [i],
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
attachments[index].indices.push(i);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return attachments.map(({ media, indices }) => (
|
||||||
|
<div
|
||||||
|
key={media.id}
|
||||||
|
data-caption-index={indices.map((i) => i + 1).join(' ')}
|
||||||
|
onClick={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
states.showMediaAlt = {
|
||||||
|
alt: media.description,
|
||||||
|
lang: language,
|
||||||
|
};
|
||||||
|
}}
|
||||||
|
title={media.description}
|
||||||
|
>
|
||||||
|
<sup>{indices.map((i) => i + 1).join(' ')}</sup> {media.description}
|
||||||
|
</div>
|
||||||
|
));
|
||||||
|
|
||||||
|
// return displayedMediaAttachments.map(
|
||||||
|
// (media, i) =>
|
||||||
|
// !!media.description && (
|
||||||
|
// <div
|
||||||
|
// key={media.id}
|
||||||
|
// data-caption-index={i + 1}
|
||||||
|
// onClick={(e) => {
|
||||||
|
// e.preventDefault();
|
||||||
|
// e.stopPropagation();
|
||||||
|
// states.showMediaAlt = {
|
||||||
|
// alt: media.description,
|
||||||
|
// lang: language,
|
||||||
|
// };
|
||||||
|
// }}
|
||||||
|
// title={media.description}
|
||||||
|
// >
|
||||||
|
// <sup>{i + 1}</sup> {media.description}
|
||||||
|
// </div>
|
||||||
|
// ),
|
||||||
|
// );
|
||||||
|
}, [showMultipleMediaCaptions, displayedMediaAttachments, language]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<article
|
<article
|
||||||
|
@ -1277,28 +1333,7 @@ function Status({
|
||||||
<MultipleMediaFigure
|
<MultipleMediaFigure
|
||||||
lang={language}
|
lang={language}
|
||||||
enabled={showMultipleMediaCaptions}
|
enabled={showMultipleMediaCaptions}
|
||||||
captionChildren={() => {
|
captionChildren={captionChildren}
|
||||||
return displayedMediaAttachments.map(
|
|
||||||
(media, i) =>
|
|
||||||
!!media.description && (
|
|
||||||
<div
|
|
||||||
key={media.id}
|
|
||||||
data-caption-index={i + 1}
|
|
||||||
onClick={(e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
e.stopPropagation();
|
|
||||||
states.showMediaAlt = {
|
|
||||||
alt: media.description,
|
|
||||||
lang: language,
|
|
||||||
};
|
|
||||||
}}
|
|
||||||
title={media.description}
|
|
||||||
>
|
|
||||||
<sup>{i + 1}</sup> {media.description}
|
|
||||||
</div>
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
ref={mediaContainerRef}
|
ref={mediaContainerRef}
|
||||||
|
@ -1533,7 +1568,7 @@ function MultipleMediaFigure(props) {
|
||||||
<figure class="media-figure-multiple">
|
<figure class="media-figure-multiple">
|
||||||
{children}
|
{children}
|
||||||
<figcaption lang={lang} dir="auto">
|
<figcaption lang={lang} dir="auto">
|
||||||
{captionChildren?.()}
|
{captionChildren}
|
||||||
</figcaption>
|
</figcaption>
|
||||||
</figure>
|
</figure>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue