npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ember-self-focused

v0.1.5

Published

make an ember application screen reader friendly

Downloads

20

Readme

ember-self-focused

Helps make a ember (single page) application more friendly to screen readers.

The screen reader reads out the content of a web page on load or page refresh. In Single Page Application (SPA) there is no page refresh after the initial page load, the UI gets updated without page refresh, which makes it difficult for a screen reader user to be aware of the UI change. However, if the container of the dynamic content can be focused, the screen reader will start reading out the content of the focused container.

Focusing the content of the dynamic container can be a tedious and repeated job.

For ember applications, this addon solves the problem.

ember-self-focused

Installation

ember install ember-self-focused

Usage

Add the self-focused component to all the desired templates/component corresponding to the routes.

{{#self-focused}}
  <!-- html block to be yielded -->
{{/self-focused}}

if the html block to be yielded is a component and accepting attributes to act upon, the same attribute needs to be passed to the self-focus component.

{{#self-focused foo=bar}}
  <!-- {{custom-component foo=bar}} -->
{{/self-focused}}

Since the div will be focused, it will have a focus outline/highlight, if that is not desired, please add the following styles:

.self-focused:focus {
  outline: none
}

Probably also add the following or similar styles:

// following will serve as a visual hint for currently active link to the sighted users
a.active {
  background: #000000;
  color: #ffffff;
}
// following will serve as a visual hint for currently active link to the sighted users
a.active after {
  content: 'Currently active link.';
  font-size: 0;
}

Implementation overview

  • self-focused component
    • on initialization invokes updateIsFirstRender method of the focus-manager service.
    • on render invokes the setNodeToBeFocused method of the focus-manager service, passing the self HTML node as the argument.
  • focus-manager service carries out the functionality of focusing the desired node.
    • focus-manager utilizes two state variables, namely isFirstRender and nodeToBeFocused.
      • initial value of the isFirstRender is set to true
      • initial value of the nodeToBeFocused is set to null
    • focus-manager has two private methods namely _setFocus and _removeTabIndex.
      • _setFocus method
        • adds tabindex=-1 to the nodeToBeFocused
        • invokes native focus() method on it
        • attaches _removeTabIndex method to the nodeToBeFocused as the click and blur event handler
        • sets nodeToBeFocused to null
      • _removeTabIndex method, removes the tabindex, click and blur event handler from nodeToBeFocused
    • focus-manager service exposes two methods, namely updateIsFirstRender and setNodeToBeFocused, which are consumed by self-focused component.
      • updateIsFirstRender sets isFirstRender to false if it is not already.
      • setNodeToBeFocused method
        • accepts a HTML node as an argument.
        • verifies the state of isFirstRender and if isFirstRender is true, which is the case for very first invocation, it bails out.
        • if nodeToBeFocused is not null, it bails out.
        • otherwise, it updates nodeToBeFocused with the passed argument, and schedules the private _setFocus method, in the afterRender queue.

Contributing

Running tests

  • ember test – Runs the test suite on the current Ember version
  • ember test --server – Runs the test suite in "watch mode"
  • ember try:each – Runs the test suite against multiple Ember versions

Running the dummy application

License

This project is licensed under the BSD-2-Clause License.