this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Group similar captions

Some folks really just copy/paste same desc for multiple media's

+71 -27
+13 -4
src/components/status.css
··· 1015 1015 white-space: nowrap; 1016 1016 overflow: hidden; 1017 1017 text-overflow: ellipsis; 1018 + display: inline-flex; 1019 + gap: 4px; 1018 1020 1019 1021 &:hover { 1020 1022 color: var(--text-color); 1021 1023 cursor: pointer; 1022 1024 } 1025 + 1026 + &:only-child { 1027 + white-space: pre-line; 1028 + overflow: auto; 1029 + text-overflow: unset; 1030 + } 1023 1031 } 1024 1032 1025 1033 sup { 1026 1034 opacity: 0.75; 1027 1035 font-variant-numeric: tabular-nums; 1036 + flex-shrink: 0; 1028 1037 } 1029 1038 } 1030 1039 1031 1040 /* Only 4, for now. Would be better if this is a for loop */ 1032 1041 &:has(.media[data-has-alt]:nth-child(1):is(:hover, :focus)) 1033 1042 figcaption 1034 - > div[data-caption-index='1'], 1043 + > div[data-caption-index~='1'], 1035 1044 &:has(.media[data-has-alt]:nth-child(2):is(:hover, :focus)) 1036 1045 figcaption 1037 - > div[data-caption-index='2'], 1046 + > div[data-caption-index~='2'], 1038 1047 &:has(.media[data-has-alt]:nth-child(3):is(:hover, :focus)) 1039 1048 figcaption 1040 - > div[data-caption-index='3'], 1049 + > div[data-caption-index~='3'], 1041 1050 &:has(.media[data-has-alt]:nth-child(4):is(:hover, :focus)) 1042 1051 figcaption 1043 - > div[data-caption-index='4'] { 1052 + > div[data-caption-index~='4'] { 1044 1053 color: var(--text-color); 1045 1054 } 1046 1055 }
+58 -23
src/components/status.jsx
··· 877 877 displayedMediaAttachments.some( 878 878 (media) => !!media.description && !isMediaCaptionLong(media.description), 879 879 ); 880 + const captionChildren = useMemo(() => { 881 + if (!showMultipleMediaCaptions) return null; 882 + const attachments = []; 883 + displayedMediaAttachments.forEach((media, i) => { 884 + if (!media.description) return; 885 + const index = attachments.findIndex( 886 + (attachment) => attachment.media.description === media.description, 887 + ); 888 + if (index === -1) { 889 + attachments.push({ 890 + media, 891 + indices: [i], 892 + }); 893 + } else { 894 + attachments[index].indices.push(i); 895 + } 896 + }); 897 + return attachments.map(({ media, indices }) => ( 898 + <div 899 + key={media.id} 900 + data-caption-index={indices.map((i) => i + 1).join(' ')} 901 + onClick={(e) => { 902 + e.preventDefault(); 903 + e.stopPropagation(); 904 + states.showMediaAlt = { 905 + alt: media.description, 906 + lang: language, 907 + }; 908 + }} 909 + title={media.description} 910 + > 911 + <sup>{indices.map((i) => i + 1).join(' ')}</sup> {media.description} 912 + </div> 913 + )); 914 + 915 + // return displayedMediaAttachments.map( 916 + // (media, i) => 917 + // !!media.description && ( 918 + // <div 919 + // key={media.id} 920 + // data-caption-index={i + 1} 921 + // onClick={(e) => { 922 + // e.preventDefault(); 923 + // e.stopPropagation(); 924 + // states.showMediaAlt = { 925 + // alt: media.description, 926 + // lang: language, 927 + // }; 928 + // }} 929 + // title={media.description} 930 + // > 931 + // <sup>{i + 1}</sup> {media.description} 932 + // </div> 933 + // ), 934 + // ); 935 + }, [showMultipleMediaCaptions, displayedMediaAttachments, language]); 880 936 881 937 return ( 882 938 <article ··· 1277 1333 <MultipleMediaFigure 1278 1334 lang={language} 1279 1335 enabled={showMultipleMediaCaptions} 1280 - captionChildren={() => { 1281 - return displayedMediaAttachments.map( 1282 - (media, i) => 1283 - !!media.description && ( 1284 - <div 1285 - key={media.id} 1286 - data-caption-index={i + 1} 1287 - onClick={(e) => { 1288 - e.preventDefault(); 1289 - e.stopPropagation(); 1290 - states.showMediaAlt = { 1291 - alt: media.description, 1292 - lang: language, 1293 - }; 1294 - }} 1295 - title={media.description} 1296 - > 1297 - <sup>{i + 1}</sup> {media.description} 1298 - </div> 1299 - ), 1300 - ); 1301 - }} 1336 + captionChildren={captionChildren} 1302 1337 > 1303 1338 <div 1304 1339 ref={mediaContainerRef} ··· 1533 1568 <figure class="media-figure-multiple"> 1534 1569 {children} 1535 1570 <figcaption lang={lang} dir="auto"> 1536 - {captionChildren?.()} 1571 + {captionChildren} 1537 1572 </figcaption> 1538 1573 </figure> 1539 1574 );