Giter Club home page Giter Club logo

a11ize's Introduction

a11ize

Demo of a11ize

A React-based accessibility toolkit to make any website accessible. a11ize is fast, extensible, and most importantly, lightweight (21.55 kb gzipped without core-js).

Check out a live demo at https://risingyouth.ca.

a11ize is based on the Fluid preferences framework.

Features

  • Text Sizing
  • Font Style
    • Bundles Open Dyslexic by default
  • Line Spacing
  • Word Spacing
  • Custom high-contrast colour filters
  • Enhanced Inputs
  • Table of Contents
    • Dynamically generated from semantic HTML
  • i18n Support (PRs welcomed!)

Usage notes

  • Ensure that text sizes are defined in rems

Installation

npm install @takingitglobal/a11ize

React usage

Wrap the content you want to be modified by a11ize in the AccessibilityButton tag.

  import A11yWrapper from "@takingitglobal/a11ize"
  ...
  <A11yWrapper {...options}>
    Site content here.
  </A11yWrapper>

Non-React usage

Add the id of accessible-content to an element so that it wraps the content you want a11ize to affect (generally the entire page).

<div id="accessible-content">Site content here.</div>
<script>
  A11ySettings = {
    ...options,
  };
</script>
<script src="https://cdn.jsdelivr.net/npm/@takingitglobal/a11ize@1/dist/with-react/index.js"></script>

For wider browser compability, use the version with CoreJS bundled in.

<div id="accessible-content">Site content here.</div>
<script>
  A11ySettings = {
    ...options,
  };
</script>
<script src="https://cdn.jsdelivr.net/npm/@takingitglobal/a11ize@1/dist/with-react-cjs/index.js"></script>

Cache times on jsdelivr are relatively long, so if you want the latest release replace the @1 with the version you'd like to use.

Options

All options are optional and default to the values below.

{
  primaryColor: '#921d5b',
  secondaryColor: '#01364c',
  buttonColor: '#fff', // text colour of the a11y button
  activePanels: [ // enable/disable panels as needed
    'textsize',
    'fontfamily',
    'linespacing',
    'letterspacing',
    'wordspacing',
    'contrast',
    'clickables',
    'toc',
  ],
  lang: 'en', // fallback to 'en' if set ISO code is not found
  sticky: false, // make the menu stick to the top while scrolling
  // for non-React usage
  wrapperId: 'accessible-content' // override the a11ize target element
}

Contributing

Translations & i18n

If you're able to translate the text in a11ize to another language, please make a PR with the new YAML file of translations. Example YAML files are in src/i18n/en.yml. The translated text should match to the appropriate key, with the language code as the filename.

Credits

a11ize is largely inspired by OCAD University's Infusion framework, which is a part of the Fluid Project. We aimed to create a lighter, and more widely usable a11y toolkit that could work for any website with minimal modifications.

Font Usage

a11ize bundles the Open Dyslexic font face by default. Please make sure to abide by their licensing rules if you choose to use Open Dyslexic in your own projects.

a11ize's People

Contributors

davidli3100 avatar err53 avatar gaeljacquin avatar mfurdyk avatar retrocraft avatar semantic-release-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

gaeljacquin

a11ize's Issues

Development setup

How do I set it up in an existing React app for local development?

Console errors - React usage

Description

I followed the instructions for React usage and while the toolkit is functional, it returns the following errors in the console:

Warning: Failed prop type: Invalid prop `children` of type `array` supplied to `d`, expected a single ReactElement.
    in d (created by _)
    in _ (at src/index.js:9)
Warning: An effect function must not return anything besides a function, which is used for clean-up.

It looks like you wrote useEffect(async () => ...) or returned a Promise. Instead, write the async function inside your effect and call it immediately:

useEffect(() => {
  async function fetchData() {
    // You can await here
    const response = await MyAPI.getData(someId);
    // ...
  }
  fetchData();
}, [someId]); // Or [] if effect doesn't need props or state

Learn more about data fetching with Hooks: https://fb.me/react-hooks-data-fetching
    in _ (at src/index.js:9)

I installed it on my website and the following 3 example projects from the React official website: Calculator, Emoji Search, and Snap Shot. The only difference is I'm not getting the second error on my website.

Screenshots

1 - mysite

2 - snapshot

3 - calculator

4 - emoji-search

To Reproduce

Import the component into index.js or App.js and wrap the content with A11yWrapper.

...
import A11yWrapper from "@takingitglobal/a11ize"


ReactDOM.render(<A11yWrapper><App /></A11yWrapper>, document.getElementById("root"));
...
import A11yWrapper from "@takingitglobal/a11ize"

class App extends Component {
  ...
   
  render() {
    return (
      <A11yWrapper>
       ...
      </A11yWrapper>
    );
  }
}

export default App;

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.