mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 04:41:36 +08:00
feat(core): first class a11y support (#8909)
This commit is contained in:

committed by
Nathan Walker

parent
ef9c3b1f5f
commit
c46da3fad9
15
packages/core/accessibility/font-scale-common.ts
Normal file
15
packages/core/accessibility/font-scale-common.ts
Normal file
@ -0,0 +1,15 @@
|
||||
export const VALID_FONT_SCALES = global.isIOS // iOS supports a wider number of font scales than Android does.
|
||||
? [0.5, 0.7, 0.85, 1, 1.15, 1.3, 1.5, 2, 2.5, 3, 3.5, 4]
|
||||
: [0.85, 1, 1.15, 1.3];
|
||||
|
||||
export function getClosestValidFontScale(fontScale: number): number {
|
||||
fontScale = Number(fontScale) || 1;
|
||||
|
||||
return VALID_FONT_SCALES.sort((a, b) => Math.abs(fontScale - a) - Math.abs(fontScale - b)).shift();
|
||||
}
|
||||
|
||||
export enum FontScaleCategory {
|
||||
ExtraSmall = 'extra-small',
|
||||
Medium = 'medium',
|
||||
ExtraLarge = 'extra-large',
|
||||
}
|
Reference in New Issue
Block a user