PrimaryNavigation: active fill states
This commit is contained in:
parent
29da046a3a
commit
96a226a94b
3 changed files with 32 additions and 20 deletions
|
@ -8,6 +8,7 @@ import { FormattedMessage } from 'react-intl';
|
||||||
import { NavLink, withRouter } from 'react-router-dom';
|
import { NavLink, withRouter } from 'react-router-dom';
|
||||||
import Icon from 'soapbox/components/icon';
|
import Icon from 'soapbox/components/icon';
|
||||||
import IconWithCounter from 'soapbox/components/icon_with_counter';
|
import IconWithCounter from 'soapbox/components/icon_with_counter';
|
||||||
|
import classNames from 'classnames';
|
||||||
import { getFeatures } from 'soapbox/utils/features';
|
import { getFeatures } from 'soapbox/utils/features';
|
||||||
import { getSoapboxConfig } from 'soapbox/actions/soapbox';
|
import { getSoapboxConfig } from 'soapbox/actions/soapbox';
|
||||||
import { isStaff } from 'soapbox/utils/accounts';
|
import { isStaff } from 'soapbox/utils/accounts';
|
||||||
|
@ -45,23 +46,24 @@ class PrimaryNavigation extends React.PureComponent {
|
||||||
chatsCount: PropTypes.number,
|
chatsCount: PropTypes.number,
|
||||||
features: PropTypes.object.isRequired,
|
features: PropTypes.object.isRequired,
|
||||||
siteTitle: PropTypes.string,
|
siteTitle: PropTypes.string,
|
||||||
|
location: PropTypes.object,
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { account, features, notificationCount, chatsCount, dashboardCount, siteTitle } = this.props;
|
const { account, features, notificationCount, chatsCount, dashboardCount, siteTitle, location } = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='column-header__wrapper primary-navigation__wrapper'>
|
<div className='column-header__wrapper primary-navigation__wrapper'>
|
||||||
<h1 className='column-header primary-navigation'>
|
<h1 className='column-header primary-navigation'>
|
||||||
<NavLink to='/' exact className='btn grouped'>
|
<NavLink to='/' exact className='btn grouped'>
|
||||||
<Icon src={require('@tabler/icons/icons/home-2.svg')} className='primary-navigation__icon' />
|
<Icon src={location.pathname === '/' ? require('icons/home-2-filled.svg') : require('@tabler/icons/icons/home-2.svg')} className='primary-navigation__icon' />
|
||||||
<FormattedMessage id='tabs_bar.home' defaultMessage='Home' />
|
<FormattedMessage id='tabs_bar.home' defaultMessage='Home' />
|
||||||
</NavLink>
|
</NavLink>
|
||||||
|
|
||||||
{account && <NavLink key='notifications' className='btn grouped' to='/notifications' data-preview-title-id='column.notifications'>
|
{account && <NavLink key='notifications' className='btn grouped' to='/notifications' data-preview-title-id='column.notifications'>
|
||||||
<IconWithCounter
|
<IconWithCounter
|
||||||
src={notificationCount > 0 ? require('@tabler/icons/icons/bell-ringing-2.svg') : require('@tabler/icons/icons/bell.svg')}
|
src={notificationCount > 0 ? require('@tabler/icons/icons/bell-ringing-2.svg') : require('@tabler/icons/icons/bell.svg')}
|
||||||
className='primary-navigation__icon'
|
className={classNames('primary-navigation__icon', { 'svg-icon--active': location.pathname === '/notifications' })}
|
||||||
count={notificationCount}
|
count={notificationCount}
|
||||||
/>
|
/>
|
||||||
<FormattedMessage id='tabs_bar.notifications' defaultMessage='Notifications' />
|
<FormattedMessage id='tabs_bar.notifications' defaultMessage='Notifications' />
|
||||||
|
@ -70,7 +72,7 @@ class PrimaryNavigation extends React.PureComponent {
|
||||||
{(features.chats && account) && <NavLink key='chats' className='btn grouped' to='/chats' data-preview-title-id='column.chats'>
|
{(features.chats && account) && <NavLink key='chats' className='btn grouped' to='/chats' data-preview-title-id='column.chats'>
|
||||||
<IconWithCounter
|
<IconWithCounter
|
||||||
src={require('@tabler/icons/icons/messages.svg')}
|
src={require('@tabler/icons/icons/messages.svg')}
|
||||||
className='primary-navigation__icon'
|
className={classNames('primary-navigation__icon', { 'svg-icon--active': location.pathname === '/chats' })}
|
||||||
count={chatsCount}
|
count={chatsCount}
|
||||||
/>
|
/>
|
||||||
<FormattedMessage id='tabs_bar.chats' defaultMessage='Chats' />
|
<FormattedMessage id='tabs_bar.chats' defaultMessage='Chats' />
|
||||||
|
@ -78,7 +80,7 @@ class PrimaryNavigation extends React.PureComponent {
|
||||||
|
|
||||||
{(account && isStaff(account)) && <NavLink key='dashboard' className='btn grouped' to='/admin' data-preview-title-id='tabs_bar.dashboard'>
|
{(account && isStaff(account)) && <NavLink key='dashboard' className='btn grouped' to='/admin' data-preview-title-id='tabs_bar.dashboard'>
|
||||||
<IconWithCounter
|
<IconWithCounter
|
||||||
src={require('@tabler/icons/icons/dashboard.svg')}
|
src={location.pathname.startsWith('/admin') ? require('icons/dashboard-filled.svg') : require('@tabler/icons/icons/dashboard.svg')}
|
||||||
className='primary-navigation__icon'
|
className='primary-navigation__icon'
|
||||||
count={dashboardCount}
|
count={dashboardCount}
|
||||||
/>
|
/>
|
||||||
|
@ -89,7 +91,10 @@ class PrimaryNavigation extends React.PureComponent {
|
||||||
|
|
||||||
{features.federating ? (
|
{features.federating ? (
|
||||||
<NavLink to='/timeline/local' className='btn grouped'>
|
<NavLink to='/timeline/local' className='btn grouped'>
|
||||||
<Icon src={require('@tabler/icons/icons/users.svg')} className='primary-navigation__icon' />
|
<Icon
|
||||||
|
src={require('@tabler/icons/icons/users.svg')}
|
||||||
|
className={classNames('primary-navigation__icon', { 'svg-icon--active': location.pathname === '/timeline/local' })}
|
||||||
|
/>
|
||||||
{siteTitle}
|
{siteTitle}
|
||||||
</NavLink>
|
</NavLink>
|
||||||
) : (
|
) : (
|
||||||
|
|
|
@ -5,11 +5,31 @@
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
|
||||||
> svg {
|
svg {
|
||||||
// Apparently this won't skew the image as long as it has a viewbox
|
// Apparently this won't skew the image as long as it has a viewbox
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&--active {
|
||||||
|
.icon-tabler-search {
|
||||||
|
stroke-width: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-tabler-bell,
|
||||||
|
.icon-tabler-messages {
|
||||||
|
path:nth-child(2) {
|
||||||
|
fill: var(--primary-text-color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-tabler-users {
|
||||||
|
circle,
|
||||||
|
circle + path {
|
||||||
|
fill: var(--primary-text-color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.icon-button > div {
|
.icon-button > div {
|
||||||
|
|
|
@ -78,19 +78,6 @@
|
||||||
svg {
|
svg {
|
||||||
stroke-width: 1px;
|
stroke-width: 1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
&--active {
|
|
||||||
svg.icon-tabler-search {
|
|
||||||
stroke-width: 2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
svg.icon-tabler-bell,
|
|
||||||
svg.icon-tabler-messages {
|
|
||||||
path:nth-child(2) {
|
|
||||||
fill: var(--primary-text-color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.icon-with-counter__counter {
|
.icon-with-counter__counter {
|
||||||
|
|
Loading…
Reference in a new issue