-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SpeedDial] Implement navigation behavior
Following the proposed spec with alternative B
- Loading branch information
Showing
2 changed files
with
67 additions
and
21 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
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,28 @@ | ||
/** | ||
* An arrow key on the keyboard | ||
* @typedef {'up'|'right'|'down'|'left'} ArrowKey | ||
*/ | ||
|
||
/** | ||
* | ||
* @param direction {string} | ||
* @returns value useable in aria-orientation or undefined if no ArrowKey given | ||
*/ | ||
export function getOrientation(direction) { | ||
if (direction === 'up' || direction === 'down') { | ||
return 'vertical'; | ||
} | ||
if (direction === 'right' || direction === 'left') { | ||
return 'horizontal'; | ||
} | ||
return undefined; | ||
} | ||
|
||
/** | ||
* @param {string} directionA | ||
* @param {string} directionB | ||
* @returns {boolean} | ||
*/ | ||
export function sameOrientation(directionA, directionB) { | ||
return getOrientation(directionA) === getOrientation(directionB); | ||
} |