-
Notifications
You must be signed in to change notification settings - Fork 13.4k
feat(thumbnail): add recipe and tokens #31166
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
base: ionic-modular
Are you sure you want to change the base?
Changes from all commits
d432cdd
4149d8f
c0e8d6b
b3d4c38
0153a0b
2896277
ca3a6f0
6b24703
2b4b30b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ import { expect } from '@playwright/test'; | |
| import { configs, test } from '@utils/test/playwright'; | ||
|
|
||
| /** | ||
| * ion-thumbnail does not have mode/RTL-specific logic | ||
| * This behavior does not vary across modes/directions | ||
| */ | ||
| configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, screenshot, config }) => { | ||
| test.describe(title('thumbnail: rendering'), () => { | ||
|
|
@@ -22,8 +22,15 @@ configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, screenshot, c | |
|
|
||
| await page.setContent( | ||
| ` | ||
| <style> | ||
| ion-item { | ||
| --ion-item-thumbnail-width: 20px; | ||
| --ion-item-thumbnail-height: 20px; | ||
| } | ||
| </style> | ||
|
Comment on lines
+25
to
+30
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this set
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| <ion-item> | ||
| <ion-thumbnail style="--size: 20px"> | ||
| <ion-thumbnail> | ||
| <img src="/src/components/thumbnail/test/thumbnail.svg" /> | ||
| </ion-thumbnail> | ||
| </ion-item> | ||
|
|
@@ -34,6 +41,29 @@ configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, screenshot, c | |
| const item = page.locator('ion-item'); | ||
| await expect(item).toHaveScreenshot(screenshot(`thumbnail-ion-item-size-diff`)); | ||
| }); | ||
|
|
||
| test('size should be customizable in <ion-item-divider>', async ({ page }) => { | ||
| await page.setContent( | ||
| ` | ||
| <style> | ||
| ion-item-divider { | ||
| --ion-item-divider-thumbnail-width: 20px; | ||
| --ion-item-divider-thumbnail-height: 20px; | ||
| } | ||
| </style> | ||
|
|
||
| <ion-item-divider> | ||
| <ion-thumbnail> | ||
| <img src="/src/components/thumbnail/test/thumbnail.svg" /> | ||
| </ion-thumbnail> | ||
| </ion-item-divider> | ||
| `, | ||
| config | ||
| ); | ||
|
|
||
| const itemDivider = page.locator('ion-item-divider'); | ||
| await expect(itemDivider).toHaveScreenshot(screenshot(`thumbnail-ion-item-divider-size`)); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
|
|
@@ -53,5 +83,11 @@ configs().forEach(({ title, screenshot, config }) => { | |
|
|
||
| await expect(referenceEl).toHaveScreenshot(screenshot(`thumbnail-ion-item-diff`)); | ||
| }); | ||
|
|
||
| test('should not have visual regressions when rendering inside of an <ion-item-divider>', async ({ page }) => { | ||
| const referenceEl = page.locator('#ion-item-divider'); | ||
|
|
||
| await expect(referenceEl).toHaveScreenshot(screenshot('thumbnail-ion-item-divider')); | ||
| }); | ||
| }); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| export type IonThumbnailRecipe = { | ||
| height?: string; | ||
| width?: string; | ||
|
|
||
| border?: { | ||
| radius?: string; | ||
| }; | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,27 +1,25 @@ | ||
| @import "../../themes/native/native.globals"; | ||
| @use "../../themes/mixins" as mixins; | ||
|
|
||
| // Thumbnail | ||
| // -------------------------------------------------- | ||
|
|
||
| :host { | ||
| /** | ||
| * @prop --border-radius: Border radius of the thumbnail | ||
| * @prop --size: Size of the thumbnail | ||
| * @prop --ion-thumbnail-width: Width of the thumbnail | ||
| * @prop --ion-thumbnail-height: Height of the thumbnail | ||
| * @prop --ion-thumbnail-border-radius: Border radius of the thumbnail and the slotted image | ||
| */ | ||
| --size: 48px; // TODO(FW-6862): separate width and height tokens for thumbnails | ||
| --border-radius: 0; | ||
|
|
||
| @include border-radius(var(--border-radius)); | ||
| @include mixins.border-radius(var(--ion-thumbnail-border-radius)); | ||
|
|
||
| display: block; | ||
|
|
||
| width: var(--size, 48px); | ||
| height: var(--size, 48px); | ||
| width: var(--ion-thumbnail-width); | ||
|
Comment on lines
15
to
+16
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| height: var(--ion-thumbnail-height); | ||
| } | ||
|
|
||
| ::slotted(ion-img), | ||
| ::slotted(img) { | ||
| @include border-radius(var(--border-radius)); | ||
| @include mixins.border-radius(var(--ion-thumbnail-border-radius)); | ||
|
|
||
| width: 100%; | ||
| height: 100%; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If these tokens are not set then default to the size that was set prior like the original
--ion-thumbnail-width/--ion-thumbnail-height.