Refactor components to simplify them
This commit is contained in:
parent
3cf5b14913
commit
077ed9d3bf
36 changed files with 202 additions and 216 deletions
7
src/helper/add-support-for-tab-navigation.ts
Normal file
7
src/helper/add-support-for-tab-navigation.ts
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
export const addSupportForTabNavigation = () =>
|
||||
document.addEventListener('keydown', (e) => {
|
||||
if (e.key === ' ') {
|
||||
(document.activeElement as HTMLElement)?.click();
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
|
@ -3,7 +3,9 @@ export class Random {
|
|||
|
||||
public get next(): number {
|
||||
// result is in [0, 1)
|
||||
return ((2 ** 31 - 1) & (this.seed = Math.imul(48271, this.seed))) / 2 ** 31;
|
||||
|
||||
this.seed = Math.imul(48271, this.seed);
|
||||
return ((2 ** 31 - 1) & this.seed) / 2 ** 31;
|
||||
}
|
||||
|
||||
public choose<T>(list: Array<T>): T {
|
||||
|
|
|
|||
4
src/helper/remove-unnecessary-outlines.ts
Normal file
4
src/helper/remove-unnecessary-outlines.ts
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
export const removeUnnecessaryOutlines = () =>
|
||||
document.addEventListener('click', () =>
|
||||
(document.activeElement as HTMLElement).blur?.()
|
||||
);
|
||||
6
src/helper/scroll-to-fragment.ts
Normal file
6
src/helper/scroll-to-fragment.ts
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
export const scrollToFragment = () => {
|
||||
// it might be necessary when the page takes too long to load
|
||||
if (location.hash) {
|
||||
document.getElementById(location.hash.slice(1))?.scrollIntoView();
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue