Giter VIP home page Giter VIP logo

react_accessible_dropdown's Introduction

Accessible Dropdown Menu

live Example - external site

Contents

Intro

There are a lot of dropdowns that are not accessible to screen readers

This can be due to any number of things but commonly will be:

  • Incorrect use of Aria
  • Keyboard navigation controls that either are non-standard or trap the user.
  • Non-visible focus states
  • Use of non semantic Elements
๐Ÿ“– Awesome resources to learn more about accessible dropdowns and what needs to be covered

Installation

This application is created wih React. If you would like to setup this Application on your personal machine these are the steps required.

Instructions
  • fork and clone the Repo
  • navigate into the Dropdown repo
  • npm install
  • npm run start will open the example component on port 3000: localhost:3000 external site

About

The App is a compound component. The state is passed from the parent <Dropdown> โฌ‡๏ธ to the children ๐Ÿšธ:

  • <Trigger>
  • <Content>
  • <Item>

The dropdown menu is unstyled except for the initial dropdown functionality.

โš ๏ธ Further styling is required to personalise the dropdown/ ensure colour contrast for the site it will be used on.

Each component can accept props (classNames, functions, atttributes etc), and a variant (currently only default available).

  • Written in React & Typescript with Functional Components
  • State shared using Context
  • Functionality hidden from developer to make easy to implement

Examples

Example Code for menu
<Dropdown>
  <Dropdown.Trigger variant="default">Menu</Dropdown.Trigger>
  <Dropdown.Content>
    <Dropdown.Item>
      <button>hello</button>
    </Dropdown.Item>
    <Dropdown.Item>
      <a href="/#">world</a>
    </Dropdown.Item>
    <Dropdown.Item>
      <p>hello</p>
    </Dropdown.Item>
  </Dropdown.Content>
</Dropdown>

Variants

WORK in Progress



default: basic styling added to the component.

  • White background
  • Grey border
  • Hover/ Focus/ Active states

WORK in Progress



Work in Progress more to come!


Functionality

Keyboard

Each focusable child passed to Dropdown. Item can be programmatically focused using the keyboard once the menu has been opened. focusable children include:

  • <a> - must have a href
  • <button>
  • input
  • <textarea>
  • <select>
  • <details>
  • any other element you have added a tabindex to that is not -1

Note: All elements listed above will have tabindex={-1} added to it for management of focus state

TODO

  • Tests
  • Add submenu functionality
  • Detect menu collision with edge of Window - move appropriately to remain in view
  • Add to NPM
  • Additional Variants

react_accessible_dropdown's People

Contributors

codercarl1 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.