Skip to content

Commit

Permalink
a11y: remove extra Link stuff from settings Nav
Browse files Browse the repository at this point in the history
  • Loading branch information
beyackle committed Mar 19, 2020
1 parent cbb5b4a commit 13d0efb
Showing 1 changed file with 20 additions and 36 deletions.
56 changes: 20 additions & 36 deletions Composer/packages/client/src/pages/setting/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

/** @jsx jsx */
import { jsx } from '@emotion/core';
import { Fragment, useContext, useState } from 'react';
import { Fragment, useContext } from 'react';
import formatMessage from 'format-message';
import { Nav } from 'office-ui-fabric-react/lib/Nav';
import { Link, RouteComponentProps } from '@reach/router';
import { Nav, INavLinkGroup } from 'office-ui-fabric-react/lib/Nav';
import { RouteComponentProps } from '@reach/router';

import { StoreContext } from '../../store';
import { ToolBar } from '../../components/ToolBar';
Expand All @@ -18,7 +18,7 @@ import { MainContent } from '../../components/MainContent/index';
import { TestController } from '../../TestController';

import Routes from './router';
import { title, fileList, contentEditor, linkItem } from './styles';
import { title, fileList, contentEditor } from './styles';

const settingLabels = {
title: formatMessage('Configuration'),
Expand All @@ -41,30 +41,11 @@ const links = [
];

const SettingPage: React.FC<RouteComponentProps> = () => {
const [active, setActive] = useState();
const { state } = useContext(StoreContext);
const { projectId } = state;
const makeProjectLink = (id, path) => {
return `/bot/${id}${path}`;
};
function onRenderLink(link) {
return (
<Link
to={link.key}
css={linkItem(link.disabled)}
tabIndex={-1}
getProps={linkProps => {
if (linkProps.isCurrent && active !== link.key) {
setActive(link.key);
}
return {};
}}
onClick={() => {}}
>
{link.name}
</Link>
);
}

const toolbarItems = [
{
Expand All @@ -74,26 +55,29 @@ const SettingPage: React.FC<RouteComponentProps> = () => {
},
];

const _onRenderGroupHeader = (group: INavLinkGroup | undefined) => {
return <div css={title}>{group?.name}</div>;
};

return (
<Fragment>
<ToolBar toolbarItems={toolbarItems} />
<MainContent>
<Fragment>
<div css={fileList}>
<Tree variant="large">
<div>
<div css={title}>{settingLabels.title}</div>
<Nav
groups={[{ links }]}
onRenderLink={onRenderLink}
selectedKey={active}
onLinkClick={(e, item) => {
if (item && item.key) {
navigateTo(makeProjectLink(projectId, item.key));
}
}}
/>
</div>
<Nav
onRenderGroupHeader={_onRenderGroupHeader}
groups={[
{
name: settingLabels.title,
links,
},
]}
onLinkClick={(e, item) => {
navigateTo(makeProjectLink(projectId, item?.key));
}}
/>
</Tree>
</div>
<Conversation css={contentEditor}>
Expand Down

0 comments on commit 13d0efb

Please sign in to comment.