GithubHelp home page GithubHelp logo

swup / a11y-plugin Goto Github PK

View Code? Open in Web Editor NEW
4.0 4.0 2.0 940 KB

A swup plugin for enhanced accessibility 🔉

Home Page: https://swup.js.org/plugins/a11y-plugin

License: MIT License

TypeScript 100.00%
a11y accessibility aria live-regions plugin swup

a11y-plugin's People

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

a11y-plugin's Issues

Declaration file not being found

Description of the issue

I just installed a11y-plugin in a fresh typescript project and got this error:

Could not find a declaration file for module '@swup/a11y-plugin'.

How to reproduce the issue

  • Start a new ts project
  • Install @swup/a11y-plugin

...seems like it's due to the missing toplevel "types" property. I thought it wasn't necessary anymore due to us providing it in the "exports" field anyways, but adding it made the error go away in VSCode.

CSS docs

Describe the problem

Intuitively, I would have thought that this CSS should hide any outline on the <main> element:

main:focus {
  outline: none;
}

But in the docs it recommends this approach:

main[tabindex="-1"] {
  outline: none;
}

In my tests, it works well with the simple :focus selector. Is there a reason for the [tabindex] form being chosen in the docs?

Allow dynamic focus target

Describe the problem

  • Some visits don't need to reset focus to the main element, e.g. fragment visits like filter UIs
  • Ideally, the custom focus target could be overwritten per visit
  • The fragment plugin and users can then just set visit.focus = '#list' or similar

Describe the proposed solution

  • New key in visit object: visit.focus — or maybe nested/grouped somewhere?
  • New hook content:focus that can be replaced

How important is this feature to you?

  • Nice to have
  • Would make my life a lot easier
  • I cannot use swup without it

Add `swup.say` method

Describe the problem

When using in-site app views that alter the URL but are being ignored by swup due to the use of resolveUrl, a11y plugin doesn't announce anything, since there is no swup visit happening.

Describe the proposed solution

It would be handy to be able to manually trigger announcements:

import SwupA11yPlugin from "@swup/a11y-plugin";
const swup = new Swup({
  plugins: [
    new SwupA11yPlugin(),
  ],
});

// sometime later:
createHistoryRecord(newUrl);
swup.say?.(`Navigated to filter ${currentFilterName}`);

How important is this feature to you?

  • Nice to have

Reduced motion feature overwrites existing animation state

Description of the issue

  • The check for reduced motion preference is implemented in a way to not respect the current setting
  • We're now also doing the opposite, i.e. re-enabling animations even when they're already disabled
  • Practically, this means that popstate visits are now always animated if this option is enabled

How to reproduce the issue

  • Enabled respectReducedMotion
  • Trigger a history visit
  • It's animated

Disable animations if user prefers reduced motion

Evaluate whether we should disable transitions for devices that request reduced motion:

  • Pro: Conceptually, it's well within this plugin's core idea
  • Con: Technically, this belongs in CSS
  • Con: Turning off animations isn't reducing but removing motion completely
  • Probably make this an optional feature turned off by default

Details

Revisiting the reduced motion media query

Example code

@media screen and
  (prefers-reduced-motion: reduce), 
  (update: slow) {
  .transition-fade {
    transition-duration: 0.001ms !important;
  }
}

Support multi-language announcements

Describe the problem

  • Currently, announcement templates are configured once
  • Navigating to a page with a different lang will not change the language of announcements

Describe the proposed solutions

Tending towards option 1, or a combination of 1 and 2.

  1. Allow keying the announcement templates by language: { en: 'Navigated to', de: 'Seite geladen' }
  2. Create a hook content:announce to modify these on the fly
  3. Read the announcement templates from the DOM: <meta name="swup-a11y-announce" content="Seite geladen">

Alternatives considered

  • Hard-reloading on language change
  • Possible, but not a great user experience by any means

How important is this feature to you?

  • Nice to have
  • Would make my life a lot easier
  • I cannot use swup without it

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.