Merge branch 'fix-i1578' into 'main'
adding rtl languages support to announcements Closes #1578 See merge request soapbox-pub/soapbox!2825
This commit is contained in:
commit
7155f2a159
|
@ -1,6 +1,8 @@
|
||||||
import React, { useEffect, useRef } from 'react';
|
import React, { useEffect, useRef } from 'react';
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
|
|
||||||
|
import { getTextDirection } from 'soapbox/utils/rtl';
|
||||||
|
|
||||||
import type { Announcement as AnnouncementEntity, Mention as MentionEntity } from 'soapbox/types/entities';
|
import type { Announcement as AnnouncementEntity, Mention as MentionEntity } from 'soapbox/types/entities';
|
||||||
|
|
||||||
interface IAnnouncementContent {
|
interface IAnnouncementContent {
|
||||||
|
@ -11,6 +13,7 @@ const AnnouncementContent: React.FC<IAnnouncementContent> = ({ announcement }) =
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
|
||||||
const node = useRef<HTMLDivElement>(null);
|
const node = useRef<HTMLDivElement>(null);
|
||||||
|
const direction = getTextDirection(announcement.content);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
updateLinks();
|
updateLinks();
|
||||||
|
@ -76,7 +79,8 @@ const AnnouncementContent: React.FC<IAnnouncementContent> = ({ announcement }) =
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className='translate text-sm'
|
dir={direction}
|
||||||
|
className='text-sm ltr:ml-0 rtl:mr-0'
|
||||||
ref={node}
|
ref={node}
|
||||||
dangerouslySetInnerHTML={{ __html: announcement.contentHtml }}
|
dangerouslySetInnerHTML={{ __html: announcement.contentHtml }}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { FormattedDate } from 'react-intl';
|
||||||
|
|
||||||
import { Stack, Text } from 'soapbox/components/ui';
|
import { Stack, Text } from 'soapbox/components/ui';
|
||||||
import { useFeatures } from 'soapbox/hooks';
|
import { useFeatures } from 'soapbox/hooks';
|
||||||
|
import { getTextDirection } from 'soapbox/utils/rtl';
|
||||||
|
|
||||||
import AnnouncementContent from './announcement-content';
|
import AnnouncementContent from './announcement-content';
|
||||||
import ReactionsBar from './reactions-bar';
|
import ReactionsBar from './reactions-bar';
|
||||||
|
@ -27,11 +28,12 @@ const Announcement: React.FC<IAnnouncement> = ({ announcement, addReaction, remo
|
||||||
const skipYear = hasTimeRange && startsAt.getFullYear() === endsAt.getFullYear() && endsAt.getFullYear() === now.getFullYear();
|
const skipYear = hasTimeRange && startsAt.getFullYear() === endsAt.getFullYear() && endsAt.getFullYear() === now.getFullYear();
|
||||||
const skipEndDate = hasTimeRange && startsAt.getDate() === endsAt.getDate() && startsAt.getMonth() === endsAt.getMonth() && startsAt.getFullYear() === endsAt.getFullYear();
|
const skipEndDate = hasTimeRange && startsAt.getDate() === endsAt.getDate() && startsAt.getMonth() === endsAt.getMonth() && startsAt.getFullYear() === endsAt.getFullYear();
|
||||||
const skipTime = announcement.all_day;
|
const skipTime = announcement.all_day;
|
||||||
|
const direction = getTextDirection(announcement.content);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack className='w-full' space={2}>
|
<Stack className='w-full' space={2}>
|
||||||
{hasTimeRange && (
|
{hasTimeRange && (
|
||||||
<Text theme='muted'>
|
<Text theme='muted' direction={direction}>
|
||||||
<FormattedDate
|
<FormattedDate
|
||||||
value={startsAt}
|
value={startsAt}
|
||||||
hour12
|
hour12
|
||||||
|
|
Loading…
Reference in New Issue