kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
Birthdays: Accessibility improvements/fixes
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>improve-ci
rodzic
bcc0e0983b
commit
e0d7f2dd87
|
@ -39,6 +39,7 @@ class BirthdayReminders extends ImmutablePureComponent {
|
||||||
birthdays: ImmutablePropTypes.orderedSet,
|
birthdays: ImmutablePropTypes.orderedSet,
|
||||||
intl: PropTypes.object.isRequired,
|
intl: PropTypes.object.isRequired,
|
||||||
dispatch: PropTypes.func.isRequired,
|
dispatch: PropTypes.func.isRequired,
|
||||||
|
onMoveDown: PropTypes.func,
|
||||||
};
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
@ -55,6 +56,7 @@ class BirthdayReminders extends ImmutablePureComponent {
|
||||||
getHandlers() {
|
getHandlers() {
|
||||||
return {
|
return {
|
||||||
open: this.handleOpenBirthdaysModal,
|
open: this.handleOpenBirthdaysModal,
|
||||||
|
moveDown: this.props.onMoveDown,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,6 +104,31 @@ class BirthdayReminders extends ImmutablePureComponent {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
renderMessageForScreenReader = () => {
|
||||||
|
const { intl, birthdays, account } = this.props;
|
||||||
|
|
||||||
|
if (birthdays.size === 1) {
|
||||||
|
return intl.formatMessage({ id: 'notification.birthday', defaultMessage: '{name} has birthday today' }, { name: account.get('display_name') });
|
||||||
|
}
|
||||||
|
|
||||||
|
return intl.formatMessage(
|
||||||
|
{
|
||||||
|
id: 'notification.birthday_plural',
|
||||||
|
defaultMessage: '{name} and {more} have birthday today',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: account.get('display_name'),
|
||||||
|
more: intl.formatMessage(
|
||||||
|
{
|
||||||
|
id: 'notification.birthday.more',
|
||||||
|
defaultMessage: '{count} more {count, plural, one {friend} other {friends}}',
|
||||||
|
},
|
||||||
|
{ count: birthdays.size - 1 },
|
||||||
|
),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { birthdays } = this.props;
|
const { birthdays } = this.props;
|
||||||
|
|
||||||
|
@ -109,7 +136,7 @@ class BirthdayReminders extends ImmutablePureComponent {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<HotKeys handlers={this.getHandlers()}>
|
<HotKeys handlers={this.getHandlers()}>
|
||||||
<div className='notification notification-birthday'>
|
<div className='notification notification-birthday focusable' tabIndex='0' title={this.renderMessageForScreenReader()}>
|
||||||
<div className='notification__message'>
|
<div className='notification__message'>
|
||||||
<div className='notification__icon-wrapper'>
|
<div className='notification__icon-wrapper'>
|
||||||
<Icon src={require('@tabler/icons/icons/ballon.svg')} />
|
<Icon src={require('@tabler/icons/icons/ballon.svg')} />
|
||||||
|
|
|
@ -51,6 +51,8 @@ const mapStateToProps = state => {
|
||||||
const settings = getSettings(state);
|
const settings = getSettings(state);
|
||||||
const instance = state.get('instance');
|
const instance = state.get('instance');
|
||||||
const features = getFeatures(instance);
|
const features = getFeatures(instance);
|
||||||
|
const showBirthdayReminders = settings.getIn(['notifications', 'birthdays', 'show']) && settings.getIn(['notifications', 'quickFilter', 'active']) === 'all' && features.birthDates;
|
||||||
|
const birthdays = showBirthdayReminders && state.getIn(['user_lists', 'birthday_reminders', state.get('me')]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
showFilterBar: settings.getIn(['notifications', 'quickFilter', 'show']),
|
showFilterBar: settings.getIn(['notifications', 'quickFilter', 'show']),
|
||||||
|
@ -59,7 +61,8 @@ const mapStateToProps = state => {
|
||||||
isUnread: state.getIn(['notifications', 'unread']) > 0,
|
isUnread: state.getIn(['notifications', 'unread']) > 0,
|
||||||
hasMore: state.getIn(['notifications', 'hasMore']),
|
hasMore: state.getIn(['notifications', 'hasMore']),
|
||||||
totalQueuedNotificationsCount: state.getIn(['notifications', 'totalQueuedNotificationsCount'], 0),
|
totalQueuedNotificationsCount: state.getIn(['notifications', 'totalQueuedNotificationsCount'], 0),
|
||||||
showBirthdayReminders: settings.getIn(['notifications', 'birthdays', 'show']) && settings.getIn(['notifications', 'quickFilter', 'active']) === 'all' && features.birthDates,
|
showBirthdayReminders,
|
||||||
|
hasBirthdays: !!birthdays,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -78,6 +81,7 @@ class Notifications extends React.PureComponent {
|
||||||
dequeueNotifications: PropTypes.func,
|
dequeueNotifications: PropTypes.func,
|
||||||
totalQueuedNotificationsCount: PropTypes.number,
|
totalQueuedNotificationsCount: PropTypes.number,
|
||||||
showBirthdayReminders: PropTypes.bool,
|
showBirthdayReminders: PropTypes.bool,
|
||||||
|
hasBirthdays: PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
|
@ -114,15 +118,25 @@ class Notifications extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
handleMoveUp = id => {
|
handleMoveUp = id => {
|
||||||
const elementIndex = this.props.notifications.findIndex(item => item !== null && item.get('id') === id) - 1;
|
const { hasBirthdays } = this.props;
|
||||||
|
|
||||||
|
let elementIndex = this.props.notifications.findIndex(item => item !== null && item.get('id') === id) - 1;
|
||||||
|
if (hasBirthdays) elementIndex++;
|
||||||
this._selectChild(elementIndex, true);
|
this._selectChild(elementIndex, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleMoveDown = id => {
|
handleMoveDown = id => {
|
||||||
const elementIndex = this.props.notifications.findIndex(item => item !== null && item.get('id') === id) + 1;
|
const { hasBirthdays } = this.props;
|
||||||
|
|
||||||
|
let elementIndex = this.props.notifications.findIndex(item => item !== null && item.get('id') === id) + 1;
|
||||||
|
if (hasBirthdays) elementIndex++;
|
||||||
this._selectChild(elementIndex, false);
|
this._selectChild(elementIndex, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleMoveBelowBirthdays = () => {
|
||||||
|
this._selectChild(1, false);
|
||||||
|
}
|
||||||
|
|
||||||
_selectChild(index, align_top) {
|
_selectChild(index, align_top) {
|
||||||
const container = this.column.node;
|
const container = this.column.node;
|
||||||
const element = container.querySelector(`article:nth-of-type(${index + 1}) .focusable`);
|
const element = container.querySelector(`article:nth-of-type(${index + 1}) .focusable`);
|
||||||
|
@ -175,7 +189,12 @@ class Notifications extends React.PureComponent {
|
||||||
/>
|
/>
|
||||||
));
|
));
|
||||||
|
|
||||||
if (showBirthdayReminders) scrollableContent = scrollableContent.unshift(<BirthdayReminders key='birthdays' />);
|
if (showBirthdayReminders) scrollableContent = scrollableContent.unshift(
|
||||||
|
<BirthdayReminders
|
||||||
|
key='birthdays'
|
||||||
|
onMoveDown={this.handleMoveBelowBirthdays}
|
||||||
|
/>,
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
scrollableContent = null;
|
scrollableContent = null;
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue