Merge branch 'site-banner-rtl' into 'main'

SiteBanner: support RTL

Closes #1560

See merge request soapbox-pub/soapbox!2802
environments/review-main-yi2y9f/deployments/4154
Alex Gleason 11 months ago
commit c3673638d7

@ -1,13 +1,16 @@
import React from 'react'; import React from 'react';
interface ILogoText { interface ILogoText extends Pick<React.HTMLAttributes<HTMLHeadingElement>, 'dir'> {
children: React.ReactNode; children: React.ReactNode;
} }
/** Big text in site colors, for displaying the site name. Resizes itself according to the screen size. */ /** Big text in site colors, for displaying the site name. Resizes itself according to the screen size. */
const LogoText: React.FC<ILogoText> = ({ children }) => { const LogoText: React.FC<ILogoText> = ({ children, dir }) => {
return ( return (
<h1 className='overflow-hidden text-ellipsis bg-gradient-to-br from-accent-500 via-primary-500 to-gradient-end bg-clip-text text-5xl font-extrabold text-transparent sm:leading-none lg:text-6xl xl:text-7xl'> <h1
className='-my-5 overflow-hidden text-ellipsis bg-gradient-to-br from-accent-500 via-primary-500 to-gradient-end bg-clip-text text-5xl font-extrabold !leading-normal text-transparent lg:text-6xl xl:text-7xl'
dir={dir}
>
{children} {children}
</h1> </h1>
); );

@ -3,19 +3,24 @@ import React from 'react';
import Markup from 'soapbox/components/markup'; import Markup from 'soapbox/components/markup';
import { Stack } from 'soapbox/components/ui'; import { Stack } from 'soapbox/components/ui';
import { useInstance } from 'soapbox/hooks'; import { useInstance } from 'soapbox/hooks';
import { getTextDirection } from 'soapbox/utils/rtl';
import { LogoText } from './logo-text'; import { LogoText } from './logo-text';
const SiteBanner: React.FC = () => { const SiteBanner: React.FC = () => {
const instance = useInstance(); const instance = useInstance();
const description = instance.short_description || instance.description;
return ( return (
<Stack space={3}> <Stack space={3}>
<LogoText>{instance.title}</LogoText> <LogoText dir={getTextDirection(instance.title)}>
{instance.title}
</LogoText>
<Markup <Markup
size='lg' size='lg'
dangerouslySetInnerHTML={{ __html: instance.short_description || instance.description }} dangerouslySetInnerHTML={{ __html: description }}
direction={getTextDirection(description)}
/> />
</Stack> </Stack>
); );

Loading…
Cancel
Save