SiteBanner: support RTL

This commit is contained in:
Alex Gleason 2023-10-12 16:22:47 -05:00
parent dadd896a0d
commit 301ba68842
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
2 changed files with 13 additions and 5 deletions

View file

@ -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='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'
dir={dir}
>
{children} {children}
</h1> </h1>
); );

View file

@ -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>
); );