• Stars
    star
    147
  • Rank 251,347 (Top 5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 5 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A clear, beautiful and easy to implement focus-state solution.

Floating Focus

Build status Package version Package license

A clear, beautiful and easy to implement focus-state solution that improves accessibility and usability.

https://engineering.q42.nl/floating-focus/

Drag Racing


Installation

With npm installed, run

$ npm install @q42/floating-focus-a11y --save

Usage

Import the package and instantiate the class on page load:

import FloatingFocus from '@q42/floating-focus-a11y';
new FloatingFocus(containerElement); // Element is an optional parameter which defaults to `document.body`

Define a default outline and outline-offset. Either of these values can be overruled per component:

/* Hide all default focus states if a mouse is used, this is completely optional ofcourse */
*:focus {
  outline: none;
}

/* Default outline value, which will be applied to all elements receiving focus, this is a required step. */
/* The .focus class is used by the focus target, more below. */
.floating-focus-enabled :focus, .floating-focus-enabled .focus {
  outline: dodgerblue solid 2px;
  outline-offset: 8px;
}

/* Give all buttons a green focus state instead of dodgerblue, this is optional in case it's needed. */
.floating-focus-enabled [type="button"]:focus {
  outline-color: green;
  outline-offset: 4px;
}

Focus target

Sometimes the actual element that receives focus is hidden from view, as is common with a custom input field. In this case it's possible to define a focus-target attribute on the focusable element.

<input type="file" class="hidden" id="file-upload-123" focus-target="file-upload-123-label"/>
<label id="file-upload-123-label" for="file-upload-123">Please upload a file</label>

This will append the focus class to the target element and make the visual focus box appear around the target element, instead of the element that actually has the native focus.

Separate stylesheet

For convenience, the styles are included in the script by default. There is also an option to include the stylesheet separately. This is particularly useful with strict style-src 'self' CORS headers.

Import unstyled dist file:

import FloatingFocus from '@q42/floating-focus-a11y/dist/unstyled';

The stylesheet can then be separately imported with your favorite CSS preprocessor:

@import '@q42/floating-focus-a11y/dist/unstyled';

Extra cautions

  • Watch out with CSS transitions: if an element that will be focused has a transition for outline-color / outline-width / outline-style (including all !), the floating focus will not display correctly on that element.

Develop

$ npm run build
$ npm run watch
$ npm run test

Deploy

# bump version
$ npm version [major | minor | patch | premajor | preminor | prepatch | prerelease]

# publish
$ npm publish

License

MIT

More Repositories

1

AndroidScrollingImageView

An Android view for displaying repeated continuous side scrolling images. This can be used to create a parallax animation effect.
Java
1,782
star
2

delighters

Add CSS animations to delight users as they scroll down.
HTML
748
star
3

TrelloScrum

Add Scrum to Trello
JavaScript
447
star
4

coffeehack

Hack of our Jura coffee machine
Arduino
140
star
5

hue-libs

A community created list of Hue libraries in several languages
123
star
6

Q42.WinRT

Useful library for data driven Windows Phone 8 and Windows 8 C# / XAML WinRT projects
C#
109
star
7

meteor-gce

Install scripts to run Meteor on Google Compute Engine
Shell
56
star
8

LiveJS

Live.js makes sure you're always looking at the latest version of the page you're working on, whether you're writing HTML, CSS or Javascript.
JavaScript
53
star
9

Qlassified-Android

An Android Wrapper Library for easy Keystore Encryption
Java
48
star
10

meteor-gke

Deploy scripts to run Meteor on Google Container Engine and Kubernetes
Shell
45
star
11

vue-dotnet-validator

Client-side validator of .NET data-annotations using vue.js
JavaScript
44
star
12

QreditRoll

JavaScript
36
star
13

RxPromise

A Promise wrapper around RxJava's Observable
Java
27
star
14

openapi-typescript-validator

Generate typescript with ajv validation based on openapi schemas
TypeScript
26
star
15

sanity-plugin-page-tree

TypeScript
25
star
16

Tolbaaken

A pure Kotlin logging library for Android with zero overhead.
Kotlin
24
star
17

Bindable

Simple Swift Variable<Value>
Swift
24
star
18

fabricjs-opentypejs-demo

Demo of fabricjs rendering fonts using opentypejs
JavaScript
22
star
19

RefreshableScrollView

A SwiftUI scroll view that supports pull to refresh
Swift
20
star
20

meteor-autoform-markdown

A simple markdown textarea with preview using perak:markdown
JavaScript
16
star
21

autovars

Reactive state management for Meteor + React
JavaScript
15
star
22

Jue

Philips Hue API for Java
Java
14
star
23

SimpleOAIHarvester

Example implementation of an OAI harvester as a python script.
Python
14
star
24

StyledString

Easy Attributed Strings in Swift
Swift
14
star
25

vue-multi-loader

Vue.js component loader for webpack, using webpack loaders for the parts
JavaScript
14
star
26

SEE

SEE! Chrome extension helps you imagine what it’s like to be visually impaired
JavaScript
12
star
27

Orchard-DbTranslations

Enables interface translation feature directly in Orchard's admin panels instead of .po files
C#
12
star
28

meteor-accounts-microsoft

A login service for Microsoft accounts.
JavaScript
11
star
29

pomotv-app

iOS client for http://pomo.tv
Swift
11
star
30

CT-3000

A tool for teaching Computational Thinking to kids
JavaScript
10
star
31

DecorJS

The Decor JS framework
JavaScript
10
star
32

HaagsTranslator

C#
10
star
33

MarzipanDemoApp

Demo app used in β€œHacking Marzipan” talk at Do iOS 2018
Swift
9
star
34

Q42.RijksmuseumApi

Open source library for interaction with the Rijksmuseum API
C#
8
star
35

meteor-admin-assetmanager

Easily upload files to Meteor Admin (yogiben:admin).
JavaScript
7
star
36

lesswatch

LESS folder watcher with optional debug information
7
star
37

Template.Android

Kotlin
7
star
38

ValidationKit

A Swift library for validating user input, for example in forms.
Swift
7
star
39

meteor-gke-example

An example Meteor app that can run on Kubernetes.
JavaScript
6
star
40

json-typescript-decoder

Type safe JSON validation for Typescript
TypeScript
6
star
41

Salad

Lightweight Cucumber-style UI tests for iOS.
Swift
6
star
42

Q42Stats

Project to gather some statistics around how platform features are used
Swift
6
star
43

sanity-plugin-user-guide

A Sanity plugin to add a simple user guide to the CMS
TypeScript
6
star
44

meteor-ezpublish

publish a collection once and let subscibers determine the details
JavaScript
6
star
45

meteor-microsoft

An implementation of the Microsoft OAuth flow.
JavaScript
6
star
46

Q42.ImagePreview.swift

iOS client for the Q42.ImagePreview.net images.
Swift
6
star
47

ElementDiff

Animate tableview for view model arrays.
Swift
5
star
48

meteor-memcached

Memcached package for meteor without Npm module requirements, based on 3rd-Eden node-memcached: https://github.com/3rd-Eden/node-memcached
JavaScript
5
star
49

Q42Stats.Android

Project to gather some statistics around how platform features are used
Kotlin
4
star
50

meteor-wait-for-image

JavaScript
4
star
51

meteor-iBeacons

just a quick hack combining Meteor with iBeacons using petermetz' Cordova plugin
JavaScript
4
star
52

mc-robot

MC Robot. A multi-cluster automator.
Go
4
star
53

Q42.ImageResizert

Image resizing for dotnet core mvc projects using ImageMagick
C#
4
star
54

VR-Fullbody

Fullbody Mocap VR Demo
C#
4
star
55

RefreshableScrollViewDemo

Sample code for refreshable custom SwiftUI views
Swift
4
star
56

OneBridge

To rule them all
Go
3
star
57

android-things-rainbow-hat-kotlin

A Kotlin demo app to play with Android Things running on a Raspberry Pi and a Rainbow Hat.
Kotlin
3
star
58

q42.wheels.caching

C# Nuget package with wrappers for caching functionality
C#
3
star
59

lighthouse-plugin-social-sharing

Lighthouse Plugin for an audit on Social Sharing meta tags
JavaScript
3
star
60

pending-changes

Meteor package to keep track of pending changes on collections
JavaScript
3
star
61

lighthouse-plugin-sample-project

A sample project for showing an integration with Lighthouse CI & Lighthouse Plugin in GitHub Actions.
3
star
62

NoticeWindow

A customizable notice component for iOS
Swift
3
star
63

dftool

A tool to export Dialogflow intents and config from one project and import them into another
JavaScript
3
star
64

logo

Q42 logorepo
JavaScript
2
star
65

meteor-installable-web-app

Make your Meteor app installable to the home screen
JavaScript
2
star
66

hillchart-q42-nl

The Amazing Hill Chart Drawing Tool
Vue
2
star
67

Meteor-Promissum

A Promise wrapper for Meteor
Swift
2
star
68

The.Hitchhikers.Readme

Opiniated readme template for your closed source project
2
star
69

hue2

Hue Limited Edition Android app
Java
2
star
70

3D

Everything 3D, STL's, Fusion files, step files, Prusa Slicer projects, gcode files
2
star
71

Q42.ImagePreview.Net

C#
2
star
72

ci-tools-n-scripts

Continuous Integration tools & scripts frequently used and re-used between projects
Shell
2
star
73

Q42.Logging.ApplicationInsights

Log to ApplicationInsights using the default ILogger
C#
2
star
74

Picker

Pick a value using a promise
Swift
2
star
75

meteor-mind-meld

Easily transfer collection data from one Meteor instance to another.
JavaScript
2
star
76

meteor-continuous-deployment

A helping hand in utilizing Meteor UP and Travis with a few scripts.
JavaScript
2
star
77

tslint-react-native-a11y

TSLint rules to enhance accessibility in React Native apps.
TypeScript
2
star
78

Orchard-AdminSpecificCulture

Orchard Module to enable a specific culture for the admin
C#
1
star
79

gcp-sema

Command-line utility to access and update GCP SecretManager secrets
Go
1
star
80

Minesweeper.iOS

Minesweeper voor iOS, gebouwd in SwiftUI door Kalle en MathijsB
Swift
1
star
81

meteor-custom-scheme

A wrapper for the Cordova Custom-URL-scheme plugin by EddyVerbruggen
JavaScript
1
star
82

MWHackathon

Museums and the Web Hackathon april 2012
C#
1
star
83

CATiledLayerBug

Demonstration of CATiledLayer shows previous tiles bug
Swift
1
star
84

template-ios

A template for creating iOS projects at Q42.
Swift
1
star
85

gcode-sort

Optimize a GCODE file by reducing the total time spent moving the bit (G0) vs cutting or carving (G1)
Svelte
1
star
86

fastlane-plugin-qr_code

Fastlane plugin that generates QR codes that you may use in the rest of your workflow.
Ruby
1
star
87

yaml-templater

Go
1
star
88

Q42.ImagePreview.java

Android client for the Q42.ImagePreview.net images.
Kotlin
1
star
89

blurpaderp

Generate random pronouncable ids
JavaScript
1
star
90

Tondor.iOS

Re-creation of the Tinder user interface in SwiftUI
Swift
1
star
91

GrantForTheWeb.MicrioConcepts

Micrio POCs with the Web Monetization API
HTML
1
star
92

hue-traffic-light

Indicate your current mood by setting a traffic light color on one of your Hue lights
Svelte
1
star
93

OculusUnrift

JavaScript
1
star
94

IAP-prog-auth

Google Identity Aware Proxy Programmatic Authentication
TypeScript
1
star
95

vuejs-firestore-demo

Demo for Smashing Magazine
JavaScript
1
star
96

NBA.Client

Naturalis Netherlands Biodiversity API Client
C#
1
star
97

w00tcamp-ptsm

Stop spam & get your deserved financial reward for reading mails. Let senders pay for emailing you.
Go
1
star