[Glitch] Redesign Content Warning and filters

Port 393f0a0159f8c12316e903979f6a506e44ea2b50 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
Claire 2024-10-23 11:47:23 +02:00
parent cfa2e0503a
commit 624b942c2e
5 changed files with 38 additions and 39 deletions

View File

@ -17,9 +17,15 @@ export const ContentWarning: React.FC<{
aria-expanded={expanded} aria-expanded={expanded}
> >
{expanded ? ( {expanded ? (
<FormattedMessage id='status.show_less' defaultMessage='Show less' /> <FormattedMessage
id='content_warning.hide'
defaultMessage='Hide post'
/>
) : ( ) : (
<FormattedMessage id='status.show_more' defaultMessage='Show more' /> <FormattedMessage
id='content_warning.show_more'
defaultMessage='Show more'
/>
)} )}
{icons} {icons}
</button> </button>

View File

@ -10,13 +10,16 @@ export const FilterWarning: React.FC<{
<StatusBanner <StatusBanner
expanded={expanded} expanded={expanded}
onClick={onClick} onClick={onClick}
variant={BannerVariant.Blue} variant={BannerVariant.Filter}
> >
<p> <p>
<FormattedMessage <FormattedMessage
id='filter_warning.matches_filter' id='filter_warning.matches_filter'
defaultMessage='Matches filter “{title}”' defaultMessage='Matches filter “<span>{title}</span>”'
values={{ title }} values={{
title,
span: (chunks) => <span className='filter-name'>{chunks}</span>,
}}
/> />
</p> </p>
</StatusBanner> </StatusBanner>

View File

@ -1,8 +1,8 @@
import { FormattedMessage } from 'react-intl'; import { FormattedMessage } from 'react-intl';
export enum BannerVariant { export enum BannerVariant {
Yellow = 'yellow', Warning = 'warning',
Blue = 'blue', Filter = 'filter',
} }
export const StatusBanner: React.FC<{ export const StatusBanner: React.FC<{
@ -11,9 +11,9 @@ export const StatusBanner: React.FC<{
expanded?: boolean; expanded?: boolean;
onClick?: () => void; onClick?: () => void;
}> = ({ children, variant, expanded, onClick }) => ( }> = ({ children, variant, expanded, onClick }) => (
<div <label
className={ className={
variant === BannerVariant.Yellow variant === BannerVariant.Warning
? 'content-warning' ? 'content-warning'
: 'content-warning content-warning--filter' : 'content-warning content-warning--filter'
} }
@ -26,6 +26,11 @@ export const StatusBanner: React.FC<{
id='content_warning.hide' id='content_warning.hide'
defaultMessage='Hide post' defaultMessage='Hide post'
/> />
) : variant === BannerVariant.Warning ? (
<FormattedMessage
id='content_warning.show_more'
defaultMessage='Show more'
/>
) : ( ) : (
<FormattedMessage <FormattedMessage
id='content_warning.show' id='content_warning.show'
@ -33,5 +38,5 @@ export const StatusBanner: React.FC<{
/> />
)} )}
</button> </button>
</div> </label>
); );

View File

@ -154,7 +154,5 @@
"status.is_poll": "This toot is a poll", "status.is_poll": "This toot is a poll",
"status.local_only": "Only visible from your instance", "status.local_only": "Only visible from your instance",
"status.show_filter_reason": "Show anyway", "status.show_filter_reason": "Show anyway",
"status.show_less": "Show less",
"status.show_more": "Show more",
"status.uncollapse": "Uncollapse" "status.uncollapse": "Uncollapse"
} }

View File

@ -11651,19 +11651,21 @@ noscript {
} }
.content-warning { .content-warning {
display: block;
box-sizing: border-box; box-sizing: border-box;
background: rgba($ui-highlight-color, 0.05); background: rgba($ui-highlight-color, 0.05);
color: $secondary-text-color; color: $secondary-text-color;
border-top: 1px solid; border: 1px solid rgba($ui-highlight-color, 0.15);
border-bottom: 1px solid; border-radius: 8px;
border-color: rgba($ui-highlight-color, 0.15);
padding: 8px (5px + 8px); padding: 8px (5px + 8px);
position: relative; position: relative;
font-size: 15px; font-size: 15px;
line-height: 22px; line-height: 22px;
cursor: pointer;
p { p {
margin-bottom: 8px; margin-bottom: 8px;
font-weight: 500;
} }
.link-button { .link-button {
@ -11672,31 +11674,16 @@ noscript {
font-weight: 500; font-weight: 500;
} }
&::before, &--filter {
&::after { color: $darker-text-color;
content: '';
display: block;
position: absolute;
height: 100%;
background: url('~images/warning-stripes.svg') repeat-y;
width: 5px;
top: 0;
}
&::before { p {
border-start-start-radius: 4px; font-weight: normal;
border-end-start-radius: 4px; }
inset-inline-start: 0;
}
&::after { .filter-name {
border-start-end-radius: 4px; font-weight: 500;
border-end-end-radius: 4px; color: $secondary-text-color;
inset-inline-end: 0; }
}
&--filter::before,
&--filter::after {
background-image: url('~images/filter-stripes.svg');
} }
} }