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