-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
98bbd71
commit 3388b24
Showing
8 changed files
with
4,043 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "airbnb-base" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
language: node_js | ||
node_js: | ||
- 8 | ||
env: | ||
- FRESH_DEPS=false | ||
cache: | ||
directories: | ||
- $HOME/.npm | ||
before_install: | ||
- npm install --global [email protected] | ||
- npm --version | ||
install: | ||
- if [[ ${FRESH_DEPS} == "true" ]]; then npm install --no-shrinkwrap --prefer-online; else npm install --prefer-offline; fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,36 @@ | ||
# VueJS Roving Tabindex Mixin | ||
|
||
A VueJS mixin for handling roving tabindex | ||
|
||
## Usage | ||
|
||
Add `v-navigation-list="<list-name>"` to elements, to create a roving tabindex for the elements with the same `<list-name>`. | ||
|
||
*Example:* | ||
|
||
```html | ||
<template> | ||
<div> | ||
<ul> | ||
<li v-navigation-list="'myList'">Element 1</li> | ||
<li v-navigation-list="'myList'">Element 2</li> | ||
<li v-navigation-list="'myList'">Element 3</li> | ||
</ul> | ||
|
||
<ul> | ||
<li v-navigation-list="'myOtherList'">Element 4</li> | ||
<li v-navigation-list="'myOtherList'">Element 5</li> | ||
</ul> | ||
</div> | ||
</template> | ||
<script> | ||
import rovingTabIndexMixin from 'vue-mixin-roving-tabindex' | ||
export default { | ||
mixins: [rovingTabIndexMixin], | ||
data: () => ({}) | ||
} | ||
</script> | ||
``` | ||
|
||
In the example above there are two seperate roving tabindex lists (`myList` and `myOtherList`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,5 @@ | ||
import { __, always, defaultTo, ifElse, equals, prop } from 'ramda'; | ||
import NavigationList from 'roving-tabindex-element-list'; | ||
import navigationListDirective from './src/navigation-list-directive'; | ||
|
||
|
||
/** | ||
* @type {object.<string, NavigationList>} | ||
*/ | ||
const navigationLists = {}; | ||
|
||
/** | ||
* Gets the key from the binding, or 'default | ||
* | ||
* @param {*} binding | ||
* @return {string} | ||
*/ | ||
const getKeyFromBinding = ifElse(equals('true'), always('default'), prop('value')); | ||
|
||
|
||
/** | ||
* Appends a value to an array, creating the array if it is undefined | ||
*/ | ||
const keyboard = { | ||
bind: function(el, binding, vnode) { | ||
const key = getKeyFromBinding(binding); | ||
|
||
if(!navigationLists[key]) { | ||
navigationLists[key] = new NavigationList({ | ||
sortBeforeUpdate: defaultTo(false, binding.modifiers.sort) | ||
}); | ||
} | ||
|
||
navigationLists[key].registerElement(el); | ||
}, | ||
|
||
unbind: function(el, binding) { | ||
const key = getKeyFromBinding(binding); | ||
navigationLists[key].unregisterElement(el); | ||
} | ||
export default { | ||
directives: { navigationList: navigationListDirective }, | ||
}; | ||
|
||
const KeyboardMixin = { | ||
directives: { keyboard } | ||
}; | ||
|
||
export default KeyboardMixin; |
Oops, something went wrong.