2024-08-22 19:12:35 +02:00
|
|
|
import { FormattedMessage } from 'react-intl';
|
|
|
|
|
|
|
|
export enum BannerVariant {
|
2024-10-23 11:47:23 +02:00
|
|
|
Warning = 'warning',
|
|
|
|
Filter = 'filter',
|
2024-08-22 19:12:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export const StatusBanner: React.FC<{
|
|
|
|
children: React.ReactNode;
|
|
|
|
variant: BannerVariant;
|
|
|
|
expanded?: boolean;
|
|
|
|
onClick?: () => void;
|
|
|
|
}> = ({ children, variant, expanded, onClick }) => (
|
2024-10-23 11:47:23 +02:00
|
|
|
<label
|
2024-08-22 19:12:35 +02:00
|
|
|
className={
|
2024-10-23 11:47:23 +02:00
|
|
|
variant === BannerVariant.Warning
|
2024-08-22 19:12:35 +02:00
|
|
|
? 'content-warning'
|
|
|
|
: 'content-warning content-warning--filter'
|
|
|
|
}
|
|
|
|
>
|
|
|
|
{children}
|
|
|
|
|
|
|
|
<button className='link-button' onClick={onClick}>
|
|
|
|
{expanded ? (
|
|
|
|
<FormattedMessage
|
|
|
|
id='content_warning.hide'
|
|
|
|
defaultMessage='Hide post'
|
|
|
|
/>
|
2024-10-23 11:47:23 +02:00
|
|
|
) : variant === BannerVariant.Warning ? (
|
|
|
|
<FormattedMessage
|
|
|
|
id='content_warning.show_more'
|
|
|
|
defaultMessage='Show more'
|
|
|
|
/>
|
2024-08-22 19:12:35 +02:00
|
|
|
) : (
|
|
|
|
<FormattedMessage
|
|
|
|
id='content_warning.show'
|
|
|
|
defaultMessage='Show anyway'
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</button>
|
2024-10-23 11:47:23 +02:00
|
|
|
</label>
|
2024-08-22 19:12:35 +02:00
|
|
|
);
|