-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: add keyboard support in year grid
- Loading branch information
Showing
7 changed files
with
113 additions
and
19 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
File renamed without changes.
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,29 @@ | ||
import { keyCodesRecord } from '../constants.js'; | ||
import type { ToNextSelectableYearInit } from './typings.js'; | ||
|
||
const { | ||
ARROW_DOWN, | ||
ARROW_LEFT, | ||
ARROW_RIGHT, | ||
ARROW_UP, | ||
END, | ||
HOME, | ||
} = keyCodesRecord; | ||
|
||
export function toNextSelectedYear({ | ||
keyCode, | ||
max, | ||
min, | ||
year, | ||
}: ToNextSelectableYearInit): number { | ||
switch (keyCode) { | ||
case ARROW_UP: return year - 4; | ||
case ARROW_DOWN: return year + 4; | ||
case ARROW_LEFT: return year - 1; | ||
case ARROW_RIGHT: return year + 1; | ||
case END: return max.getUTCFullYear(); | ||
case HOME: return min.getUTCFullYear(); | ||
default: | ||
return year; | ||
} | ||
} |
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
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