Browse Source

Merge pull request #659 from sophiebits/a11y

Improve a11y of docs
main
Alex Krolick 7 years ago
committed by GitHub
parent
commit
c091475f92
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      src/templates/components/Sidebar/Section.js

16
src/templates/components/Sidebar/Section.js

@ -10,7 +10,10 @@ import isItemActive from 'utils/isItemActive';
import MetaTitle from '../MetaTitle'; import MetaTitle from '../MetaTitle';
import ChevronSvg from '../ChevronSvg'; import ChevronSvg from '../ChevronSvg';
const Section = ({ class Section extends React.Component {
state = {uid: ('' + Math.random()).replace(/\D/g, '')};
render() {
const {
activeItemId, activeItemId,
createLink, createLink,
isActive, isActive,
@ -19,9 +22,13 @@ const Section = ({
onLinkClick, onLinkClick,
onSectionTitleClick, onSectionTitleClick,
section, section,
}) => ( } = this.props;
const uid = 'section_' + this.state.uid;
return (
<div> <div>
<button <button
aria-expanded={isActive}
aria-controls={uid}
css={{ css={{
cursor: 'pointer', cursor: 'pointer',
backgroundColor: 'transparent', backgroundColor: 'transparent',
@ -54,6 +61,7 @@ const Section = ({
</MetaTitle> </MetaTitle>
</button> </button>
<ul <ul
id={uid}
css={{ css={{
marginBottom: 10, marginBottom: 10,
@ -98,6 +106,8 @@ const Section = ({
))} ))}
</ul> </ul>
</div> </div>
); );
}
}
export default Section; export default Section;

Loading…
Cancel
Save