clean up side navigation
This commit is contained in:
parent
f89d13885b
commit
a43fea6e9a
6 changed files with 39 additions and 9 deletions
|
@ -10,7 +10,7 @@ type Props = {
|
||||||
function ChannelDiscussion(props: Props) {
|
function ChannelDiscussion(props: Props) {
|
||||||
const uri = props.uri;
|
const uri = props.uri;
|
||||||
return (
|
return (
|
||||||
<div className="">
|
<div>
|
||||||
<section className="section">
|
<section className="section">
|
||||||
<CommentCreate uri={uri} />
|
<CommentCreate uri={uri} />
|
||||||
</section>
|
</section>
|
||||||
|
|
|
@ -23,6 +23,7 @@ const perform = dispatch => ({
|
||||||
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),
|
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),
|
||||||
signOut: () => dispatch(doSignOut()),
|
signOut: () => dispatch(doSignOut()),
|
||||||
openMobileNavigation: () => dispatch(doOpenModal(MODALS.MOBILE_NAVIGATION)),
|
openMobileNavigation: () => dispatch(doOpenModal(MODALS.MOBILE_NAVIGATION)),
|
||||||
|
openChannelCreate: () => dispatch(doOpenModal(MODALS.CREATE_CHANNEL)),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(
|
export default connect(
|
||||||
|
|
|
@ -28,6 +28,7 @@ type Props = {
|
||||||
syncError: ?string,
|
syncError: ?string,
|
||||||
signOut: () => void,
|
signOut: () => void,
|
||||||
openMobileNavigation: () => void,
|
openMobileNavigation: () => void,
|
||||||
|
openChannelCreate: () => void,
|
||||||
};
|
};
|
||||||
|
|
||||||
const Header = (props: Props) => {
|
const Header = (props: Props) => {
|
||||||
|
@ -43,6 +44,7 @@ const Header = (props: Props) => {
|
||||||
signOut,
|
signOut,
|
||||||
syncError,
|
syncError,
|
||||||
openMobileNavigation,
|
openMobileNavigation,
|
||||||
|
openChannelCreate,
|
||||||
} = props;
|
} = props;
|
||||||
const authenticated = Boolean(email);
|
const authenticated = Boolean(email);
|
||||||
|
|
||||||
|
@ -142,11 +144,11 @@ const Header = (props: Props) => {
|
||||||
<Icon size={18} icon={ICONS.PUBLISH} />
|
<Icon size={18} icon={ICONS.PUBLISH} />
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
<MenuList className="menu__list--header">
|
<MenuList className="menu__list--header">
|
||||||
<MenuItem className="menu__link" onSelect={() => history.push(`/$/${PAGES.SETTINGS}`)}>
|
<MenuItem className="menu__link" onSelect={() => history.push(`/$/${PAGES.PUBLISH}`)}>
|
||||||
<Icon aria-hidden tootlip icon={ICONS.PUBLISH} />
|
<Icon aria-hidden icon={ICONS.PUBLISH} />
|
||||||
{__('New Publish')}
|
{__('New Publish')}
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem className="menu__link" onSelect={() => history.push(`/$/${PAGES.HELP}`)}>
|
<MenuItem className="menu__link" onSelect={openChannelCreate}>
|
||||||
<Icon aria-hidden icon={ICONS.CHANNEL} />
|
<Icon aria-hidden icon={ICONS.CHANNEL} />
|
||||||
{__('New Channel')}
|
{__('New Channel')}
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
|
|
@ -7,6 +7,10 @@ import Button from 'component/button';
|
||||||
import Tag from 'component/tag';
|
import Tag from 'component/tag';
|
||||||
import StickyBox from 'react-sticky-box/dist/esnext';
|
import StickyBox from 'react-sticky-box/dist/esnext';
|
||||||
import Spinner from 'component/spinner';
|
import Spinner from 'component/spinner';
|
||||||
|
import usePersistedState from 'effects/use-persisted-state';
|
||||||
|
|
||||||
|
const SHOW_CHANNELS = 'SHOW_CHANNELS';
|
||||||
|
const SHOW_TAGS = 'SHOW_TAGS';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
subscriptions: Array<Subscription>,
|
subscriptions: Array<Subscription>,
|
||||||
|
@ -34,6 +38,31 @@ function SideNavigation(props: Props) {
|
||||||
} = props;
|
} = props;
|
||||||
const { pathname } = location;
|
const { pathname } = location;
|
||||||
const isAuthenticated = Boolean(email);
|
const isAuthenticated = Boolean(email);
|
||||||
|
const [sideInformation, setSideInformation] = usePersistedState(
|
||||||
|
'side-navigation:information',
|
||||||
|
getSideInformation(pathname)
|
||||||
|
);
|
||||||
|
|
||||||
|
function getSideInformation(path) {
|
||||||
|
switch (path) {
|
||||||
|
case `/$/${PAGES.CHANNELS_FOLLOWING}`:
|
||||||
|
return SHOW_CHANNELS;
|
||||||
|
|
||||||
|
case `/$/${PAGES.TAGS_FOLLOWING}`:
|
||||||
|
return SHOW_TAGS;
|
||||||
|
|
||||||
|
case `/$/${PAGES.DISCOVER}`:
|
||||||
|
return null;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return sideInformation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
const sideInfo = getSideInformation(pathname);
|
||||||
|
setSideInformation(sideInfo);
|
||||||
|
}, [pathname, setSideInformation]);
|
||||||
|
|
||||||
function buildLink(path, label, icon, onClick) {
|
function buildLink(path, label, icon, onClick) {
|
||||||
return {
|
return {
|
||||||
|
@ -138,7 +167,7 @@ function SideNavigation(props: Props) {
|
||||||
)}
|
)}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
{pathname.includes(PAGES.TAGS_FOLLOWING) && (
|
{sideInformation === SHOW_TAGS && (
|
||||||
<ul className="navigation__secondary navigation-links--small tags--vertical">
|
<ul className="navigation__secondary navigation-links--small tags--vertical">
|
||||||
{followedTags.map(({ name }, key) => (
|
{followedTags.map(({ name }, key) => (
|
||||||
<li className="navigation-link__wrapper" key={name}>
|
<li className="navigation-link__wrapper" key={name}>
|
||||||
|
@ -148,7 +177,7 @@ function SideNavigation(props: Props) {
|
||||||
</ul>
|
</ul>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{pathname.includes(PAGES.CHANNELS_FOLLOWING) && (
|
{sideInformation === SHOW_CHANNELS && (
|
||||||
<ul className="navigation__secondary navigation-links--small">
|
<ul className="navigation__secondary navigation-links--small">
|
||||||
{subscriptions.map(({ uri, channelName }, index) => (
|
{subscriptions.map(({ uri, channelName }, index) => (
|
||||||
<li key={uri} className="navigation-link__wrapper">
|
<li key={uri} className="navigation-link__wrapper">
|
||||||
|
|
|
@ -88,6 +88,7 @@ svg + .button__label,
|
||||||
&:last-of-type {
|
&:last-of-type {
|
||||||
border-top-right-radius: var(--border-radius);
|
border-top-right-radius: var(--border-radius);
|
||||||
border-bottom-right-radius: var(--border-radius);
|
border-bottom-right-radius: var(--border-radius);
|
||||||
|
margin-right: var(--spacing-small);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,11 +23,8 @@
|
||||||
|
|
||||||
.claim-list__dropdown {
|
.claim-list__dropdown {
|
||||||
padding: 0 var(--spacing-medium);
|
padding: 0 var(--spacing-medium);
|
||||||
margin-left: var(--spacing-medium);
|
|
||||||
margin-right: var(--spacing-medium);
|
|
||||||
|
|
||||||
@media (max-width: $breakpoint-small) {
|
@media (max-width: $breakpoint-small) {
|
||||||
margin-top: var(--spacing-small);
|
|
||||||
margin-left: 0;
|
margin-left: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue