-
Notifications
You must be signed in to change notification settings - Fork 470
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
470 additions
and
0 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 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,70 @@ | ||
import {DemoRoute} from '@demo/routes'; | ||
import {TuiDocumentationPagePO, tuiGoto} from '@demo-playwright/utils'; | ||
import {expect, test} from '@playwright/test'; | ||
|
||
test.describe('TuiLike', () => { | ||
test.describe('Examples', () => { | ||
test('Basic like', async ({page}) => { | ||
await tuiGoto(page, DemoRoute.Like); | ||
const example = new TuiDocumentationPagePO(page).getExample('#basic'); | ||
|
||
await example.locator('[tuiLike]').first().click(); | ||
|
||
await expect(example).toHaveScreenshot('01-basic-like.png'); | ||
}); | ||
|
||
test('External icon loads', async ({page}) => { | ||
await tuiGoto(page, DemoRoute.Like); | ||
const example = new TuiDocumentationPagePO(page).getExample( | ||
'#external-icons', | ||
); | ||
|
||
await example.locator('[tuiLike]').first().click(); | ||
|
||
await expect(example).toHaveScreenshot('02-external-icon-like.png'); | ||
}); | ||
|
||
test('Other appearances hover', async ({page}) => { | ||
await tuiGoto(page, DemoRoute.Like); | ||
const example = new TuiDocumentationPagePO(page).getExample( | ||
'#other-appearances', | ||
); | ||
|
||
await example.locator('[tuiLike]').nth(1).hover(); | ||
|
||
await expect(example).toHaveScreenshot('03-other-appearances-hover-like.png'); | ||
}); | ||
|
||
test('Other appearances click', async ({page}) => { | ||
await tuiGoto(page, DemoRoute.Like); | ||
const example = new TuiDocumentationPagePO(page).getExample( | ||
'#other-appearances', | ||
); | ||
|
||
await example.locator('[tuiLike]').nth(1).click(); | ||
|
||
await expect(example).toHaveScreenshot('04-other-appearances-click-like.png'); | ||
}); | ||
|
||
test('With forms click', async ({page}) => { | ||
await tuiGoto(page, DemoRoute.Like); | ||
const example = new TuiDocumentationPagePO(page).getExample('#with-forms'); | ||
|
||
await example.locator('[tuiLike]').nth(0).click(); | ||
|
||
await expect(example).toHaveScreenshot( | ||
'05-with-forms-ngModel-click-like.png', | ||
); | ||
|
||
await example.locator('[tuiLike]').nth(1).click(); | ||
|
||
await expect(example).toHaveScreenshot( | ||
'06-with-forms-reactive-forms-click-like.png', | ||
); | ||
|
||
await example.locator('[tuiButton]').click(); | ||
|
||
await expect(example).toHaveScreenshot('07-with-forms-click-toggle.png'); | ||
}); | ||
}); | ||
}); |
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
12 changes: 12 additions & 0 deletions
12
projects/demo/src/modules/components/like/examples/1/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,12 @@ | ||
<input | ||
tuiLike="var(--tui-status-negative)" | ||
type="checkbox" | ||
/> | ||
|
||
<input | ||
size="s" | ||
tuiLike | ||
type="checkbox" | ||
[checkedIcon]="'@tui.star-filled'" | ||
[uncheckedIcon]="'@tui.star'" | ||
/> |
14 changes: 14 additions & 0 deletions
14
projects/demo/src/modules/components/like/examples/1/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,14 @@ | ||
import {Component} from '@angular/core'; | ||
import {changeDetection} from '@demo/emulate/change-detection'; | ||
import {encapsulation} from '@demo/emulate/encapsulation'; | ||
import {TuiLike} from '@taiga-ui/kit'; | ||
|
||
@Component({ | ||
standalone: true, | ||
imports: [TuiLike], | ||
templateUrl: './index.html', | ||
styles: [':host { display: flex; gap: 1rem; align-items: center; }'], | ||
encapsulation, | ||
changeDetection, | ||
}) | ||
export default class Example {} |
4 changes: 4 additions & 0 deletions
4
projects/demo/src/modules/components/like/examples/2/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,4 @@ | ||
<input | ||
tuiLike="var(--tui-status-warning)" | ||
type="checkbox" | ||
/> |
19 changes: 19 additions & 0 deletions
19
projects/demo/src/modules/components/like/examples/2/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,19 @@ | ||
import {Component} from '@angular/core'; | ||
import {changeDetection} from '@demo/emulate/change-detection'; | ||
import {encapsulation} from '@demo/emulate/encapsulation'; | ||
import {TuiLike, tuiLikeOptionsProvider} from '@taiga-ui/kit'; | ||
|
||
@Component({ | ||
standalone: true, | ||
imports: [TuiLike], | ||
templateUrl: './index.html', | ||
styles: [':host { display: flex; gap: 1rem; align-items: center; }'], | ||
encapsulation, | ||
changeDetection, | ||
providers: [ | ||
tuiLikeOptionsProvider({ | ||
icons: {unchecked: '@tui.star', checked: '@tui.star-filled'}, | ||
}), | ||
], | ||
}) | ||
export default class Example {} |
4 changes: 4 additions & 0 deletions
4
projects/demo/src/modules/components/like/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,4 @@ | ||
<input | ||
tuiLike | ||
type="checkbox" | ||
/> |
23 changes: 23 additions & 0 deletions
23
projects/demo/src/modules/components/like/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,23 @@ | ||
import {Component} from '@angular/core'; | ||
import {changeDetection} from '@demo/emulate/change-detection'; | ||
import {encapsulation} from '@demo/emulate/encapsulation'; | ||
import {TuiLike, tuiLikeOptionsProvider} from '@taiga-ui/kit'; | ||
|
||
@Component({ | ||
standalone: true, | ||
imports: [TuiLike], | ||
templateUrl: './index.html', | ||
styles: [':host { display: flex; gap: 1rem; align-items: center; }'], | ||
encapsulation, | ||
changeDetection, | ||
providers: [ | ||
tuiLikeOptionsProvider({ | ||
icons: { | ||
unchecked: | ||
'https://raw.githubusercontent.com/MarsiBarsi/readme-icons/main/github.svg', | ||
checked: 'https://cdn-icons-png.flaticon.com/64/12710/12710759.png', | ||
}, | ||
}), | ||
], | ||
}) | ||
export default class Example {} |
6 changes: 6 additions & 0 deletions
6
projects/demo/src/modules/components/like/examples/4/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,6 @@ | ||
<input | ||
*ngFor="let appearance of appearances" | ||
tuiLike | ||
type="checkbox" | ||
[appearance]="appearance" | ||
/> |
17 changes: 17 additions & 0 deletions
17
projects/demo/src/modules/components/like/examples/4/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,17 @@ | ||
import {NgForOf} from '@angular/common'; | ||
import {Component} from '@angular/core'; | ||
import {changeDetection} from '@demo/emulate/change-detection'; | ||
import {encapsulation} from '@demo/emulate/encapsulation'; | ||
import {TuiLike} from '@taiga-ui/kit'; | ||
|
||
@Component({ | ||
standalone: true, | ||
imports: [NgForOf, TuiLike], | ||
templateUrl: './index.html', | ||
styles: [':host { display: flex; gap: 1rem; align-items: center; }'], | ||
encapsulation, | ||
changeDetection, | ||
}) | ||
export default class Example { | ||
protected readonly appearances = ['error', 'success', 'warning', 'flat'] as const; | ||
} |
35 changes: 35 additions & 0 deletions
35
projects/demo/src/modules/components/like/examples/5/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,35 @@ | ||
<div> | ||
<p class="tui-text_body-xl">NgModel</p> | ||
|
||
<input | ||
tuiLike="var(--tui-status-negative)" | ||
type="checkbox" | ||
[(ngModel)]="liked" | ||
/> | ||
|
||
<p class="tui-text_body-m-2">Liked: {{ liked }}</p> | ||
</div> | ||
|
||
<div> | ||
<p class="tui-text_body-xl">Reactive form</p> | ||
|
||
<form [formGroup]="likeForm"> | ||
<input | ||
formControlName="liked" | ||
tuiLike="var(--tui-status-negative)" | ||
type="checkbox" | ||
/> | ||
</form> | ||
|
||
<p class="tui-text_body-m-2">Liked: {{ likeForm.value.liked }}</p> | ||
</div> | ||
|
||
<button | ||
size="m" | ||
tuiButton | ||
type="button" | ||
[style.width.%]="100" | ||
(click)="changeValue()" | ||
> | ||
Toggle | ||
</button> |
30 changes: 30 additions & 0 deletions
30
projects/demo/src/modules/components/like/examples/5/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,30 @@ | ||
import {CommonModule} from '@angular/common'; | ||
import {Component} from '@angular/core'; | ||
import {FormControl, FormGroup, FormsModule, ReactiveFormsModule} from '@angular/forms'; | ||
import {changeDetection} from '@demo/emulate/change-detection'; | ||
import {encapsulation} from '@demo/emulate/encapsulation'; | ||
import {TuiButton} from '@taiga-ui/core'; | ||
import {TuiLike} from '@taiga-ui/kit'; | ||
|
||
@Component({ | ||
standalone: true, | ||
imports: [CommonModule, FormsModule, ReactiveFormsModule, TuiButton, TuiLike], | ||
templateUrl: './index.html', | ||
styles: [ | ||
':host { display: flex; column-gap: 3rem; justify-content: space-between; flex-wrap: wrap; }', | ||
], | ||
encapsulation, | ||
changeDetection, | ||
}) | ||
export default class Example { | ||
protected liked = false; | ||
|
||
protected likeForm = new FormGroup({ | ||
liked: new FormControl(false), | ||
}); | ||
|
||
protected changeValue(): void { | ||
this.liked = !this.liked; | ||
this.likeForm.setValue({liked: !this.likeForm.value.liked}); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
projects/demo/src/modules/components/like/examples/import/import.md
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,14 @@ | ||
```ts | ||
import {Component} from '@angular/core'; | ||
import {TuiLike} from '@taiga-ui/kit'; | ||
// ... | ||
|
||
@Component({ | ||
standalone: true, | ||
imports: [ | ||
// ... | ||
TuiLike, | ||
], | ||
}) | ||
export class Example {} | ||
``` |
6 changes: 6 additions & 0 deletions
6
projects/demo/src/modules/components/like/examples/import/template.md
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,6 @@ | ||
```html | ||
<input | ||
tuiLike | ||
type="checkbox" | ||
/> | ||
``` |
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,23 @@ | ||
<tui-doc-page | ||
header="Like" | ||
package="KIT" | ||
type="components" | ||
> | ||
<ng-template pageTab> | ||
<p> | ||
A like component based on native checkbox with icons and custom color for icon when | ||
<code>:checked</code> | ||
state. | ||
</p> | ||
|
||
<tui-doc-example | ||
*ngFor="let example of examples; let index = index" | ||
[component]="index + 1 | tuiComponent" | ||
[content]="index + 1 | tuiExample: 'html,ts'" | ||
[heading]="example" | ||
[id]="example | tuiKebab" | ||
/> | ||
</ng-template> | ||
|
||
<tui-setup *pageTab="'Setup'" /> | ||
</tui-doc-page> |
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,19 @@ | ||
import {Component} from '@angular/core'; | ||
import {changeDetection} from '@demo/emulate/change-detection'; | ||
import {TuiDemo} from '@demo/utils'; | ||
|
||
@Component({ | ||
standalone: true, | ||
imports: [TuiDemo], | ||
templateUrl: './index.html', | ||
changeDetection, | ||
}) | ||
export default class Page { | ||
protected readonly examples = [ | ||
'Basic', | ||
'Icons from DI', | ||
'External icons', | ||
'Other appearances', | ||
'With forms', | ||
]; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './like.component'; | ||
export * from './like.options'; |
Oops, something went wrong.