mirror of
https://framagit.org/tykayn/mastodon.git
synced 2023-08-25 08:33:12 +02:00
Add unread notifications badge to the navigation bar
This commit is contained in:
parent
0f155af32a
commit
2cdc00bc8b
@ -46,6 +46,7 @@ const messages = defineMessages({
|
|||||||
// The component.
|
// The component.
|
||||||
export default function DrawerHeader ({
|
export default function DrawerHeader ({
|
||||||
columns,
|
columns,
|
||||||
|
unreadNotifications,
|
||||||
intl,
|
intl,
|
||||||
onSettingsClick,
|
onSettingsClick,
|
||||||
}) {
|
}) {
|
||||||
@ -77,7 +78,12 @@ export default function DrawerHeader ({
|
|||||||
aria-label={intl.formatMessage(messages.notifications)}
|
aria-label={intl.formatMessage(messages.notifications)}
|
||||||
title={intl.formatMessage(messages.notifications)}
|
title={intl.formatMessage(messages.notifications)}
|
||||||
to='/notifications'
|
to='/notifications'
|
||||||
><Icon icon='bell' /></Link>
|
>
|
||||||
|
<span className='icon-badge-wrapper'>
|
||||||
|
<Icon icon='bell' />
|
||||||
|
{ unreadNotifications > 0 && <div className='icon-badge' />}
|
||||||
|
</span>
|
||||||
|
</Link>
|
||||||
))}
|
))}
|
||||||
{renderForColumn('COMMUNITY', (
|
{renderForColumn('COMMUNITY', (
|
||||||
<Link
|
<Link
|
||||||
@ -112,6 +118,7 @@ export default function DrawerHeader ({
|
|||||||
// Props.
|
// Props.
|
||||||
DrawerHeader.propTypes = {
|
DrawerHeader.propTypes = {
|
||||||
columns: ImmutablePropTypes.list,
|
columns: ImmutablePropTypes.list,
|
||||||
|
unreadNotifications: PropTypes.number,
|
||||||
intl: PropTypes.object,
|
intl: PropTypes.object,
|
||||||
onSettingsClick: PropTypes.func,
|
onSettingsClick: PropTypes.func,
|
||||||
};
|
};
|
||||||
|
@ -34,6 +34,7 @@ const mapStateToProps = state => ({
|
|||||||
searchHidden: state.getIn(['search', 'hidden']),
|
searchHidden: state.getIn(['search', 'hidden']),
|
||||||
searchValue: state.getIn(['search', 'value']),
|
searchValue: state.getIn(['search', 'value']),
|
||||||
submitted: state.getIn(['search', 'submitted']),
|
submitted: state.getIn(['search', 'submitted']),
|
||||||
|
unreadNotifications: state.getIn(['notifications', 'unread']),
|
||||||
});
|
});
|
||||||
|
|
||||||
// Dispatch mapping.
|
// Dispatch mapping.
|
||||||
@ -87,6 +88,7 @@ class Drawer extends React.Component {
|
|||||||
searchValue,
|
searchValue,
|
||||||
submitted,
|
submitted,
|
||||||
isSearchPage,
|
isSearchPage,
|
||||||
|
unreadNotifications,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const computedClass = classNames('drawer', `mbstobon-${elefriend}`);
|
const computedClass = classNames('drawer', `mbstobon-${elefriend}`);
|
||||||
|
|
||||||
@ -96,6 +98,7 @@ class Drawer extends React.Component {
|
|||||||
{multiColumn ? (
|
{multiColumn ? (
|
||||||
<DrawerHeader
|
<DrawerHeader
|
||||||
columns={columns}
|
columns={columns}
|
||||||
|
unreadNotifications={unreadNotifications}
|
||||||
intl={intl}
|
intl={intl}
|
||||||
onSettingsClick={onOpenSettings}
|
onSettingsClick={onOpenSettings}
|
||||||
/>
|
/>
|
||||||
@ -139,6 +142,7 @@ Drawer.propTypes = {
|
|||||||
searchHidden: PropTypes.bool,
|
searchHidden: PropTypes.bool,
|
||||||
searchValue: PropTypes.string,
|
searchValue: PropTypes.string,
|
||||||
submitted: PropTypes.bool,
|
submitted: PropTypes.bool,
|
||||||
|
unreadNotifications: PropTypes.number,
|
||||||
|
|
||||||
// Dispatch props.
|
// Dispatch props.
|
||||||
onChange: PropTypes.func,
|
onChange: PropTypes.func,
|
||||||
|
@ -1121,6 +1121,22 @@
|
|||||||
left: 0;
|
left: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.icon-badge-wrapper {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-badge {
|
||||||
|
position: absolute;
|
||||||
|
display: block;
|
||||||
|
right: -.25em;
|
||||||
|
top: -.25em;
|
||||||
|
background-color: $ui-highlight-color;
|
||||||
|
border-radius: 50%;
|
||||||
|
font-size: 75%;
|
||||||
|
width: 1em;
|
||||||
|
height: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
::-webkit-scrollbar-thumb {
|
::-webkit-scrollbar-thumb {
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user