From 96010b5d9772518d881db07d5f89c2daece4ee20 Mon Sep 17 00:00:00 2001 From: Sophie Alpert Date: Sat, 3 Mar 2018 19:01:18 -0800 Subject: [PATCH] Improve a11y of docs * Add placeholder/label to input on homepage demo * Mark sections with aria-expanded ![screenshot of markup with aria-expanded for sections](https://user-images.githubusercontent.com/6820/36941651-2f851bee-1f15-11e8-8090-e93e596b3d11.png) --- content/home/examples/an-application.js | 4 +- src/templates/components/Sidebar/Section.js | 178 +++++++++++--------- 2 files changed, 97 insertions(+), 85 deletions(-) diff --git a/content/home/examples/an-application.js b/content/home/examples/an-application.js index 7b516861..ec855876 100644 --- a/content/home/examples/an-application.js +++ b/content/home/examples/an-application.js @@ -13,6 +13,8 @@ class TodoApp extends React.Component {
@@ -56,4 +58,4 @@ class TodoList extends React.Component { } } -ReactDOM.render(, mountNode); \ No newline at end of file +ReactDOM.render(, mountNode); diff --git a/src/templates/components/Sidebar/Section.js b/src/templates/components/Sidebar/Section.js index bf6db263..2738c853 100644 --- a/src/templates/components/Sidebar/Section.js +++ b/src/templates/components/Sidebar/Section.js @@ -10,94 +10,104 @@ import isItemActive from 'utils/isItemActive'; import MetaTitle from '../MetaTitle'; import ChevronSvg from '../ChevronSvg'; -const Section = ({ - activeItemId, - createLink, - isActive, - isScrollSync, - location, - onLinkClick, - onSectionTitleClick, - section, -}) => ( -
- -
    + + {section.title} + - {section.items.map(item => ( -
  • + + +
      - {createLink({ - isActive: isScrollSync - ? activeItemId === item.id - : isItemActive(location, item), - item, - location, - onLinkClick, - section, - })} + {section.items.map(item => ( +
    • + {createLink({ + isActive: isScrollSync + ? activeItemId === item.id + : isItemActive(location, item), + item, + location, + onLinkClick, + section, + })} - {item.subitems && ( -
        - {item.subitems.map(subitem => ( -
      • - {createLink({ - isActive: isScrollSync - ? activeItemId === subitem.id - : isItemActive(location, subitem), - item: subitem, - location, - onLinkClick, - section, - })} -
      • - ))} -
      - )} -
    • - ))} -
    -
-); + {item.subitems && ( +
    + {item.subitems.map(subitem => ( +
  • + {createLink({ + isActive: isScrollSync + ? activeItemId === subitem.id + : isItemActive(location, subitem), + item: subitem, + location, + onLinkClick, + section, + })} +
  • + ))} +
+ )} + + ))} + + + ); + } +} export default Section;