-
Notifications
You must be signed in to change notification settings - Fork 13.3k
feat(chip): add dynamic type support #27868
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
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
c158f66
Create ios & md style files
mapsandapps f979ce6
Update styles for dynamic type
mapsandapps 392ed7f
Add a screenshot test
mapsandapps cfa1f6f
Fix smooshing
mapsandapps ce48701
Fix math
mapsandapps 3eaf944
chore(): add updated snapshots
Ionitron 2679219
Change border-radius, margin, and padding to px
mapsandapps 35dd745
Merge branch 'FW-4425' of github.com:ionic-team/ionic-framework into …
mapsandapps ad19f8c
chore(): add updated snapshots
Ionitron 5f9af43
Change min-height to px
mapsandapps eb6e6d6
Merge branch 'FW-4425' of github.com:ionic-team/ionic-framework into …
mapsandapps 7e4d37b
chore(): add updated snapshots
Ionitron 6ca37a8
Change avatar and icon sizes to use em
mapsandapps 7f2ed81
Merge branch 'FW-4425' of github.com:ionic-team/ionic-framework into …
mapsandapps 2dc5088
Consolidate md & ios styles where they are the same
mapsandapps 83a3737
chore(): add updated snapshots
Ionitron 90604b1
Lint
mapsandapps 1cf317d
Correct calculation
mapsandapps 4fa9d97
chore(): add updated snapshots
Ionitron ed2ad44
Merge branch 'FW-4146' into FW-4425
mapsandapps 6674a4a
Improve readability
mapsandapps e77ffb1
Clarify
mapsandapps c2dc198
Import math
mapsandapps 9090e5f
Fix syntax
mapsandapps 11acd24
Address PR feedback
mapsandapps e834534
chore(): add updated snapshots
Ionitron 5db6f1c
chore: revert old screenshots
liamdebeasi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,11 @@ | ||
| @import "./chip"; | ||
| @import "./chip.vars"; | ||
|
|
||
| :host { | ||
| /** | ||
| * Main content should be prioritized on iOS, | ||
| * so we set max font size for chips. | ||
| * We add a min font size to keep the text legible. | ||
| */ | ||
| font-size: clamp(13px, $chip-base-font-size-rem, 22px); | ||
| } |
This file contains hidden or 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,6 @@ | ||
| @import "./chip"; | ||
| @import "./chip.vars"; | ||
|
|
||
| :host { | ||
| font-size: $chip-base-font-size-rem; | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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,13 @@ | ||
| @use "sass:math"; | ||
|
|
||
| /// @prop - Unitless font size of the chip before scaling | ||
| $chip-base-font-size: 14; | ||
|
|
||
| /// @prop - Font size of the chip in rem before scaling | ||
| $chip-base-font-size-rem: #{math.div($chip-base-font-size, 16)}rem; | ||
|
|
||
| /// @prop - Size of an icon within a chip (in em to scale as the font size of the chip scales) | ||
| $chip-icon-size: math.div(20em, $chip-base-font-size); | ||
|
|
||
| /// @prop - Size of an avatar within a chip (in em to scale as the font size of the chip scales) | ||
| $chip-avatar-size: math.div(24em, $chip-base-font-size); |
This file contains hidden or 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,67 @@ | ||
| import { expect } from '@playwright/test'; | ||
| import { configs, test } from '@utils/test/playwright'; | ||
|
|
||
| configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => { | ||
| /** | ||
| * Font scaling does not vary across directions. | ||
| */ | ||
| test.describe(title('chip: font scaling'), () => { | ||
| test('should scale text', async ({ page }) => { | ||
| await page.setContent( | ||
| ` | ||
| <style> | ||
| html { | ||
| font-size: 30px; | ||
| } | ||
| </style> | ||
| <ion-chip> | ||
| <ion-avatar> | ||
| <img | ||
| src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MTIgNTEyIj48cGF0aCBmaWxsPSIjYzVkYmZmIiBkPSJNMCAwaDUxMnY1MTJIMHoiLz48cGF0aCBkPSJNMjU2IDMwNGM2MS42IDAgMTEyLTUwLjQgMTEyLTExMlMzMTcuNiA4MCAyNTYgODBzLTExMiA1MC40LTExMiAxMTIgNTAuNCAxMTIgMTEyIDExMnptMCA0MGMtNzQuMiAwLTIyNCAzNy44LTIyNCAxMTJ2NTZoNDQ4di01NmMwLTc0LjItMTQ5LjgtMTEyLTIyNC0xMTJ6IiBmaWxsPSIjODJhZWZmIi8+PC9zdmc+" | ||
| /> | ||
| </ion-avatar> | ||
| <ion-label>With Icon and Avatar</ion-label> | ||
| <ion-icon name="close-circle"></ion-icon> | ||
| </ion-chip>`, | ||
| config | ||
| ); | ||
|
|
||
| const chip = page.locator('ion-chip'); | ||
|
|
||
| await expect(chip).toHaveScreenshot(screenshot('chip-scale')); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| configs({ directions: ['ltr'], modes: ['md'] }).forEach(({ title, screenshot, config }) => { | ||
| /** | ||
| * Font scaling does not vary across directions | ||
| * ios mode has a min font size | ||
| */ | ||
| test.describe(title('chip: contents at large scale'), () => { | ||
| test('should handle contents wider than chip', async ({ page }) => { | ||
| await page.setContent( | ||
| ` | ||
| <style> | ||
| html { | ||
| font-size: 48px; | ||
| } | ||
| </style> | ||
| <ion-chip> | ||
| <ion-avatar> | ||
| <img | ||
| src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MTIgNTEyIj48cGF0aCBmaWxsPSIjYzVkYmZmIiBkPSJNMCAwaDUxMnY1MTJIMHoiLz48cGF0aCBkPSJNMjU2IDMwNGM2MS42IDAgMTEyLTUwLjQgMTEyLTExMlMzMTcuNiA4MCAyNTYgODBzLTExMiA1MC40LTExMiAxMTIgNTAuNCAxMTIgMTEyIDExMnptMCA0MGMtNzQuMiAwLTIyNCAzNy44LTIyNCAxMTJ2NTZoNDQ4di01NmMwLTc0LjItMTQ5LjgtMTEyLTIyNC0xMTJ6IiBmaWxsPSIjODJhZWZmIi8+PC9zdmc+" | ||
| /> | ||
| </ion-avatar> | ||
| <ion-label>With Icon and Avatar</ion-label> | ||
| <ion-icon name="close-circle"></ion-icon> | ||
| </ion-chip>`, | ||
| config | ||
| ); | ||
|
|
||
| const chip = page.locator('ion-chip'); | ||
|
|
||
| await expect(chip).toHaveScreenshot(screenshot('chip-large-contents')); | ||
| }); | ||
| }); | ||
| }); |
Binary file added
BIN
+10.7 KB
...t/a11y/chip.e2e.ts-snapshots/chip-large-contents-md-ltr-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+11.3 KB
.../a11y/chip.e2e.ts-snapshots/chip-large-contents-md-ltr-Mobile-Firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.9 KB
...t/a11y/chip.e2e.ts-snapshots/chip-large-contents-md-ltr-Mobile-Safari-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.82 KB
...chip/test/a11y/chip.e2e.ts-snapshots/chip-scale-ios-ltr-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.67 KB
...hip/test/a11y/chip.e2e.ts-snapshots/chip-scale-ios-ltr-Mobile-Firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.38 KB
...chip/test/a11y/chip.e2e.ts-snapshots/chip-scale-ios-ltr-Mobile-Safari-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.81 KB
.../chip/test/a11y/chip.e2e.ts-snapshots/chip-scale-md-ltr-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.42 KB
...chip/test/a11y/chip.e2e.ts-snapshots/chip-scale-md-ltr-Mobile-Firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.96 KB
.../chip/test/a11y/chip.e2e.ts-snapshots/chip-scale-md-ltr-Mobile-Safari-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.