-
Notifications
You must be signed in to change notification settings - Fork 471
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): add ability to use nested hints (#7376)
- Loading branch information
1 parent
8c5ed8b
commit 9ad7c8c
Showing
8 changed files
with
167 additions
and
71 deletions.
There are no files selected for viewing
This file contains 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 was deleted.
Oops, something went wrong.
This file contains 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,112 @@ | ||
import {TuiDocumentationPagePO, tuiGoto} from '@demo-playwright/utils'; | ||
import {expect, test} from '@playwright/test'; | ||
import type {TuiHintDirection} from '@taiga-ui/core'; | ||
|
||
test.describe('TuiHint', () => { | ||
test('TuiHint works', async ({page}) => { | ||
await tuiGoto(page, '/directives/hint'); | ||
const example = new TuiDocumentationPagePO(page).getExample('#multiple'); | ||
|
||
await example.locator('tui-avatar').hover(); | ||
|
||
await expect(example).toHaveScreenshot('01-hint.png'); | ||
}); | ||
|
||
test.describe('Manual hint works', () => { | ||
const directions: readonly TuiHintDirection[] = [ | ||
'bottom-left', | ||
'bottom-right', | ||
'bottom', | ||
'left-bottom', | ||
'left-top', | ||
'left', | ||
'right-bottom', | ||
'right-top', | ||
'right', | ||
'top-left', | ||
'top-right', | ||
'top', | ||
]; | ||
|
||
directions.forEach(direction => { | ||
[256, 1280].forEach(width => { | ||
test(`tuiHintDirection is ${direction}, viewport width is ${width}px`, async ({ | ||
page, | ||
}) => { | ||
await page.setViewportSize({width, height: 300}); | ||
await tuiGoto( | ||
page, | ||
`/directives/hint-manual/API?tuiHintManual=true&tuiHintDirection=${direction}`, | ||
); | ||
await new TuiDocumentationPagePO( | ||
page, | ||
).prepareApiPageBeforeScreenshot(); | ||
await expect(page).toHaveScreenshot( | ||
`02-hint-manual-direction__${direction}-and-width__${width}.png`, | ||
); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
['true', 'false'].forEach(mode => { | ||
test(`${mode} mode hint without delay`, async ({page}) => { | ||
await page.setViewportSize({width: 750, height: 200}); | ||
await tuiGoto(page, '/directives/hint/API?tuiHintShowDelay=0&tuiMode=onDark'); | ||
const example = new TuiDocumentationPagePO(page); | ||
|
||
await example.prepareApiPageBeforeScreenshot(); | ||
await example.apiPageExample.locator('span').hover(); | ||
|
||
await expect(page).toHaveScreenshot( | ||
`03-hint-mode-${mode}-tuiHintShowDelay-0.png`, | ||
); | ||
}); | ||
|
||
test(`${mode} mode hint with delay`, async ({page}) => { | ||
await page.setViewportSize({width: 750, height: 200}); | ||
await tuiGoto( | ||
page, | ||
'/directives/hint/API?tuiHintShowDelay=1000&tuiMode=onDark', | ||
); | ||
const example = new TuiDocumentationPagePO(page); | ||
|
||
await example.prepareApiPageBeforeScreenshot(); | ||
|
||
await example.apiPageExample.locator('span').hover(); | ||
await expect(page).toHaveScreenshot( | ||
`03-hint-mode-${mode}-tuiHintShowDelay-1000__wait-0.png`, | ||
); | ||
|
||
await page.waitForTimeout(500); | ||
await expect(page).toHaveScreenshot( | ||
`03-hint-mode-${mode}-tuiHintShowDelay-1000_wait-500.png`, | ||
); | ||
|
||
await page.waitForTimeout(500); | ||
await expect(page).toHaveScreenshot( | ||
`03-hint-mode-${mode}-tuiHintShowDelay-1000_wait-1000.png`, | ||
); | ||
}); | ||
}); | ||
|
||
test('Tooltip horizontal direction', async ({page}) => { | ||
await tuiGoto(page, '/components/tooltip'); | ||
const example = new TuiDocumentationPagePO(page).getExample('#example-base'); | ||
|
||
await example.locator('tui-tooltip').nth(0).hover(); | ||
|
||
await expect(example).toHaveScreenshot('04-tooltip-left.png'); | ||
}); | ||
|
||
test('Tooltip vertical direction', async ({page}) => { | ||
await tuiGoto(page, '/components/tooltip'); | ||
const example = new TuiDocumentationPagePO(page).getExample( | ||
'#repeating-template', | ||
); | ||
|
||
await example.locator('tui-tooltip').nth(0).hover(); | ||
|
||
await expect(example).toHaveScreenshot('05-tooltip-bottom.png'); | ||
}); | ||
}); |
17 changes: 17 additions & 0 deletions
17
projects/demo/src/modules/directives/hint/examples/3/index.html
This file contains 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,17 @@ | ||
<tui-badge | ||
appearance="accent" | ||
size="l" | ||
class="badge tui-space_left-2" | ||
[tuiHint]="badgeHint" | ||
[tuiHintAppearance]="'onDark'" | ||
> | ||
Hover me | ||
|
||
<ng-template #badgeHint> | ||
<a [tuiHint]="linkHint"> | ||
Hover me again | ||
|
||
<ng-template #linkHint>Nested hint</ng-template> | ||
</a> | ||
</ng-template> | ||
</tui-badge> |
11 changes: 11 additions & 0 deletions
11
projects/demo/src/modules/directives/hint/examples/3/index.ts
This file contains 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 {Component} from '@angular/core'; | ||
import {changeDetection} from '@demo/emulate/change-detection'; | ||
import {encapsulation} from '@demo/emulate/encapsulation'; | ||
|
||
@Component({ | ||
selector: 'tui-hint-example-3', | ||
templateUrl: './index.html', | ||
encapsulation, | ||
changeDetection, | ||
}) | ||
export class TuiHintExample3 {} |
This file contains 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 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 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