feat(a11y): add dynamic font scaling (#28314)
Issue number: resolves #24638, resolves #18592 --------- <!-- Please do not submit updates to dependencies unless it fixes an issue. --> <!-- Please try to limit your pull request to one type (bugfix, feature, etc). Submit multiple pull requests if needed. --> ## What is the current behavior? <!-- Please describe the current behavior that you are modifying. --> Developers have requested that Ionic Framework support the dynamic type feature on iOS for accessibility purposes. Ionic applications do not respond to font scaling on iOS which can create inaccessible applications particularly for users with low vision. Ionic apps on Android devices currently support the Android equivalent due to functionality in the Chromium webview. Developers have also requested a way of adjusting the fonts in their Ionic UI components consistently. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - Ionic components now use `rem` instead of `px` where appropriate. This means devs can change the font size on `html` and the text in supported Ionic components will scale up/down appropriately - Add support for Dynamic Type on iOS (the iOS version of Dynamic Font Scaling) ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this introduces a breaking change, please describe the impact and migration path for existing applications below. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. --> --------- Co-authored-by: Maria Hutt <thetaPC@users.noreply.github.com> Co-authored-by: Brandy Carney <brandyscarney@users.noreply.github.com> Co-authored-by: Shawn Taylor <shawn@ionic.io> Co-authored-by: ionitron <hi@ionicframework.com> Co-authored-by: Sean Perkins <sean@ionic.io> Co-authored-by: Sean Perkins <13732623+sean-perkins@users.noreply.github.com> Co-authored-by: Amanda Johnston <90629384+amandaejohnston@users.noreply.github.com>
76
core/src/components/title/test/a11y/title.e2e.ts
Normal file
@ -0,0 +1,76 @@
|
||||
import { expect } from '@playwright/test';
|
||||
import { configs, test } from '@utils/test/playwright';
|
||||
|
||||
configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
|
||||
test.describe(title('title: font scaling'), () => {
|
||||
test('should scale default title text on larger font sizes', async ({ page }) => {
|
||||
await page.setContent(
|
||||
`
|
||||
<style>
|
||||
html {
|
||||
font-size: 36px;
|
||||
}
|
||||
</style>
|
||||
<ion-header>
|
||||
<ion-toolbar>
|
||||
<ion-title>Title</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
`,
|
||||
config
|
||||
);
|
||||
|
||||
const title = page.locator('ion-title');
|
||||
|
||||
await expect(title).toHaveScreenshot(screenshot(`title-default-scale`));
|
||||
});
|
||||
|
||||
test('should scale small title text on larger font sizes', async ({ page }) => {
|
||||
await page.setContent(
|
||||
`
|
||||
<style>
|
||||
html {
|
||||
font-size: 36px;
|
||||
}
|
||||
</style>
|
||||
<ion-header>
|
||||
<ion-toolbar>
|
||||
<ion-title size="small">Title</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
`,
|
||||
config
|
||||
);
|
||||
|
||||
const title = page.locator('ion-title');
|
||||
|
||||
await expect(title).toHaveScreenshot(screenshot(`title-small-scale`));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
configs({ directions: ['ltr'], modes: ['ios'] }).forEach(({ title, screenshot, config }) => {
|
||||
test.describe(title('title: font scaling for large attribute'), () => {
|
||||
test('should scale text on larger font sizes', async ({ page }) => {
|
||||
await page.setContent(
|
||||
`
|
||||
<style>
|
||||
html {
|
||||
font-size: 36px;
|
||||
}
|
||||
</style>
|
||||
<ion-header>
|
||||
<ion-toolbar>
|
||||
<ion-title size="large">Title</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
`,
|
||||
config
|
||||
);
|
||||
|
||||
const title = page.locator('ion-title');
|
||||
|
||||
await expect(title).toHaveScreenshot(screenshot(`title-large-scale`));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 2.3 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
@ -14,7 +14,7 @@
|
||||
|
||||
transform: translateZ(0);
|
||||
|
||||
font-size: 17px;
|
||||
font-size: dynamic-font-max(17px, 1.2);
|
||||
font-weight: 600;
|
||||
|
||||
text-align: center;
|
||||
@ -31,7 +31,7 @@
|
||||
|
||||
position: relative;
|
||||
|
||||
font-size: 13px;
|
||||
font-size: dynamic-font-max(13px, 1.8);
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
@ -40,16 +40,17 @@
|
||||
// --------------------------------------------------
|
||||
|
||||
:host(.title-large) {
|
||||
@include padding(0, 16px);
|
||||
@include padding(2px, 12px, 4px, 12px);
|
||||
@include transform-origin(left, center);
|
||||
|
||||
bottom: 0;
|
||||
position: static;
|
||||
|
||||
align-items: flex-end;
|
||||
|
||||
min-width: 100%;
|
||||
|
||||
font-size: 34px;
|
||||
font-size: dynamic-font-max(34px, 1.8);
|
||||
|
||||
font-weight: 700;
|
||||
|
||||
text-align: start;
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
:host {
|
||||
@include padding(0, 20px);
|
||||
|
||||
font-size: 20px;
|
||||
font-size: dynamic-font(20px);
|
||||
font-weight: 500;
|
||||
|
||||
letter-spacing: .0125em;
|
||||
@ -20,7 +20,7 @@
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
font-size: 15px;
|
||||
font-size: dynamic-font(15px);
|
||||
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||