Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(icon): support for dynamic type #1246

Merged
merged 11 commits into from
Aug 9, 2023
10 changes: 6 additions & 4 deletions src/components/icon/icon.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
fill: currentColor;

box-sizing: content-box !important;

font-size: 1rem;
}

:host .ionicon {
Expand Down Expand Up @@ -36,7 +38,7 @@ svg {
/* Icon RTL
* -----------------------------------------------------------
*/

/**
* Safari <16.4 incorrectly reports
* that it supports :dir(rtl) when it does not.
Expand All @@ -53,7 +55,7 @@ svg {
transform: scaleX(-1);
}
}

/**
* Fallback for browsers that support
* neither :host-context nor :dir.
Expand Down Expand Up @@ -91,11 +93,11 @@ svg {
*/

:host(.icon-small) {
font-size: 18px !important;
font-size: 1.125rem !important;
}

:host(.icon-large) {
font-size: 32px !important;
font-size: 2rem !important;
}

/* Icon Colors
Expand Down
1 change: 1 addition & 0 deletions src/components/icon/test/icon.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,5 @@ test.describe('icon: basic', () => {
await expect(iconLoc).toHaveAttribute('name', 'brush');
await expect(iconLoc).not.toHaveClass(/flip-rtl/);
});

});
19 changes: 19 additions & 0 deletions src/components/test/dynamic-type/icon.e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { expect } from '@playwright/test';
import { test } from '../../../utils/test/playwright';

test.describe('icon: dynamic type', () => {

test.beforeEach(async ({ page }) => {
await page.goto('/test/dynamic-type');
});

test('should scale text on larger font sizes', async ({ page }) => {
// Wait for all SVGs to be lazily loaded before taking screenshots
await page.waitForLoadState('networkidle');

const icons = page.locator('#icons');

expect(await icons.screenshot()).toMatchSnapshot(`icon-dynamic-type-diff.png`);
});

});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions src/components/test/dynamic-type/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html dir="ltr" lang="en" mode="ios">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0" />
<meta
http-equiv="Content-Security-Policy"
content="default-src 'none'; script-src 'self' 'unsafe-eval'; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com/*; img-src 'self'; connect-src 'self'; font-src https://fonts.gstatic.com/*'"
/>
<title>IonIcon - Dynamic Type</title>
<script type="module" src="../../build/ionicons.esm.js"></script>
<script nomodule src="../../build/ionicons.js"></script>
<style>
html {
font-size: 28px;
}
</style>
</head>

<body>
<div id="icons">
<ion-icon name="star"></ion-icon>
<ion-icon name="star" size="small"></ion-icon>
<ion-icon name="star" size="large"></ion-icon>
</div>
</body>
</html>
5 changes: 4 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,13 @@ <h2>Base64 url</h2>
</p>

<style>
html {
font-size: 32px;
}

body {
margin: 0;
padding: 16px;
font-size: 32px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

Expand Down