mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-03-22 05:39:20 +01:00
Pass lang into media description
- Assume status lang applies to media description - Allow RTL for media description
This commit is contained in:
parent
30f6d50a68
commit
4dd706ff96
6 changed files with 41 additions and 14 deletions
|
@ -4,7 +4,7 @@ import { useState } from 'preact/hooks';
|
||||||
import Icon from './icon';
|
import Icon from './icon';
|
||||||
import TranslationBlock from './translation-block';
|
import TranslationBlock from './translation-block';
|
||||||
|
|
||||||
export default function MediaAltModal({ alt, onClose }) {
|
export default function MediaAltModal({ alt, lang, onClose }) {
|
||||||
const [forceTranslate, setForceTranslate] = useState(false);
|
const [forceTranslate, setForceTranslate] = useState(false);
|
||||||
return (
|
return (
|
||||||
<div class="sheet">
|
<div class="sheet">
|
||||||
|
@ -36,7 +36,7 @@ export default function MediaAltModal({ alt, onClose }) {
|
||||||
</Menu>
|
</Menu>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<main>
|
<main lang={lang} dir="auto">
|
||||||
<p
|
<p
|
||||||
style={{
|
style={{
|
||||||
whiteSpace: 'pre-wrap',
|
whiteSpace: 'pre-wrap',
|
||||||
|
|
|
@ -14,6 +14,7 @@ function MediaModal({
|
||||||
mediaAttachments,
|
mediaAttachments,
|
||||||
statusID,
|
statusID,
|
||||||
instance,
|
instance,
|
||||||
|
lang,
|
||||||
index = 0,
|
index = 0,
|
||||||
onClose = () => {},
|
onClose = () => {},
|
||||||
}) {
|
}) {
|
||||||
|
@ -138,14 +139,19 @@ function MediaModal({
|
||||||
class="media-alt"
|
class="media-alt"
|
||||||
hidden={!showControls}
|
hidden={!showControls}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setShowMediaAlt(media.description);
|
setShowMediaAlt({
|
||||||
|
alt: media.description,
|
||||||
|
lang,
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<span class="alt-badge">ALT</span>
|
<span class="alt-badge">ALT</span>
|
||||||
<span class="media-alt-desc">{media.description}</span>
|
<span class="media-alt-desc" lang={lang} dir="auto">
|
||||||
|
{media.description}
|
||||||
|
</span>
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
<Media media={media} showOriginal />
|
<Media media={media} showOriginal lang={lang} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
@ -279,7 +285,8 @@ function MediaModal({
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<MediaAltModal
|
<MediaAltModal
|
||||||
alt={showMediaAlt}
|
alt={showMediaAlt.alt || showMediaAlt}
|
||||||
|
lang={showMediaAlt?.lang}
|
||||||
onClose={() => setShowMediaAlt(false)}
|
onClose={() => setShowMediaAlt(false)}
|
||||||
/>
|
/>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
|
@ -29,7 +29,7 @@ audio = Audio track
|
||||||
|
|
||||||
const dataAltLabel = 'ALT';
|
const dataAltLabel = 'ALT';
|
||||||
const AltBadge = (props) => {
|
const AltBadge = (props) => {
|
||||||
const { alt, ...rest } = props;
|
const { alt, lang, ...rest } = props;
|
||||||
if (!alt || !alt.trim()) return null;
|
if (!alt || !alt.trim()) return null;
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
|
@ -39,7 +39,10 @@ const AltBadge = (props) => {
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
states.showMediaAlt = alt;
|
states.showMediaAlt = {
|
||||||
|
alt,
|
||||||
|
lang,
|
||||||
|
};
|
||||||
}}
|
}}
|
||||||
title="Media description"
|
title="Media description"
|
||||||
>
|
>
|
||||||
|
@ -50,7 +53,14 @@ const AltBadge = (props) => {
|
||||||
|
|
||||||
const MEDIA_CAPTION_LIMIT = 140;
|
const MEDIA_CAPTION_LIMIT = 140;
|
||||||
|
|
||||||
function Media({ media, to, showOriginal, autoAnimate, onClick = () => {} }) {
|
function Media({
|
||||||
|
media,
|
||||||
|
to,
|
||||||
|
lang,
|
||||||
|
showOriginal,
|
||||||
|
autoAnimate,
|
||||||
|
onClick = () => {},
|
||||||
|
}) {
|
||||||
const {
|
const {
|
||||||
blurhash,
|
blurhash,
|
||||||
description,
|
description,
|
||||||
|
@ -250,7 +260,7 @@ function Media({ media, to, showOriginal, autoAnimate, onClick = () => {} }) {
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<AltBadge alt={description} />
|
<AltBadge alt={description} lang={lang} />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</Parent>
|
</Parent>
|
||||||
|
@ -383,17 +393,24 @@ function Media({ media, to, showOriginal, autoAnimate, onClick = () => {} }) {
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{!showOriginal && !showInlineDesc && <AltBadge alt={description} />}
|
{!showOriginal && !showInlineDesc && (
|
||||||
|
<AltBadge alt={description} lang={lang} />
|
||||||
|
)}
|
||||||
</Parent>
|
</Parent>
|
||||||
{showInlineDesc && (
|
{showInlineDesc && (
|
||||||
<figcaption
|
<figcaption
|
||||||
class={`media-caption media-caption-${
|
class={`media-caption media-caption-${
|
||||||
description.length <= MEDIA_CAPTION_LIMIT ? 'short' : 'long'
|
description.length <= MEDIA_CAPTION_LIMIT ? 'short' : 'long'
|
||||||
}`}
|
}`}
|
||||||
|
lang={lang}
|
||||||
|
dir="auto"
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
states.showMediaAlt = description;
|
states.showMediaAlt = {
|
||||||
|
alt: description,
|
||||||
|
lang,
|
||||||
|
};
|
||||||
}}
|
}}
|
||||||
title={
|
title={
|
||||||
description.length > MEDIA_CAPTION_LIMIT ? description : undefined
|
description.length > MEDIA_CAPTION_LIMIT ? description : undefined
|
||||||
|
@ -431,7 +448,7 @@ function Media({ media, to, showOriginal, autoAnimate, onClick = () => {} }) {
|
||||||
<div class="media-play">
|
<div class="media-play">
|
||||||
<Icon icon="play" size="xl" />
|
<Icon icon="play" size="xl" />
|
||||||
</div>
|
</div>
|
||||||
<AltBadge alt={description} />
|
<AltBadge alt={description} lang={lang} />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</Parent>
|
</Parent>
|
||||||
|
|
|
@ -189,7 +189,8 @@ export default function Modals() {
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<MediaAltModal
|
<MediaAltModal
|
||||||
alt={snapStates.showMediaAlt}
|
alt={snapStates.showMediaAlt.alt || snapStates.showMediaAlt}
|
||||||
|
lang={snapStates.showMediaAlt?.lang}
|
||||||
onClose={() => {
|
onClose={() => {
|
||||||
states.showMediaAlt = false;
|
states.showMediaAlt = false;
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -1269,6 +1269,7 @@ function Status({
|
||||||
key={media.id}
|
key={media.id}
|
||||||
media={media}
|
media={media}
|
||||||
autoAnimate={isSizeLarge}
|
autoAnimate={isSizeLarge}
|
||||||
|
lang={language}
|
||||||
to={`/${instance}/s/${id}?${
|
to={`/${instance}/s/${id}?${
|
||||||
withinContext ? 'media' : 'media-only'
|
withinContext ? 'media' : 'media-only'
|
||||||
}=${i + 1}`}
|
}=${i + 1}`}
|
||||||
|
|
|
@ -135,6 +135,7 @@ function StatusPage(params) {
|
||||||
mediaAttachments={mediaAttachments}
|
mediaAttachments={mediaAttachments}
|
||||||
statusID={mediaStatusID || id}
|
statusID={mediaStatusID || id}
|
||||||
instance={instance}
|
instance={instance}
|
||||||
|
lang={heroStatus?.language}
|
||||||
index={mediaIndex - 1}
|
index={mediaIndex - 1}
|
||||||
onClose={handleMediaClose}
|
onClose={handleMediaClose}
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in a new issue