Skip to content

Commit

Permalink
feat(kit): add pulse component (#7544)
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode authored May 24, 2024
1 parent f1cfb16 commit b6c95d0
Show file tree
Hide file tree
Showing 14 changed files with 185 additions and 0 deletions.
5 changes: 5 additions & 0 deletions projects/demo/src/modules/app/app.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,11 @@ export const ROUTES: Routes = [
title: 'Rating',
loadComponent: async () => import('../components/rating'),
}),
route({
path: DemoRoute.Pulse,
title: 'Pulse',
loadComponent: async () => import('../components/pulse'),
}),
route({
path: DemoRoute.Range,
loadChildren: async () =>
Expand Down
1 change: 1 addition & 0 deletions projects/demo/src/modules/app/demo-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export const DemoRoute = {
Pagination: '/navigation/pagination',
Radio: '/components/radio',
Rating: '/components/rating',
Pulse: '/components/pulse',
Range: '/components/range',
CalendarRange: '/components/calendar-range',
Select: '/components/select',
Expand Down
6 changes: 6 additions & 0 deletions projects/demo/src/modules/app/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,12 @@ export const pages: TuiDocPages = [
keywords: 'рейтинг, оценка, звезда, rating, star, rate',
route: DemoRoute.Rating,
},
{
section: 'Components',
title: 'Pulse',
keywords: 'сигнал, пульс, pulse, signal',
route: DemoRoute.Pulse,
},
{
section: 'Components',
title: 'Selects',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<button
appearance="outline"
tuiButton
>
Pulse
<tui-pulse />
</button>
14 changes: 14 additions & 0 deletions projects/demo/src/modules/components/pulse/examples/1/index.ts
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 {TuiButtonDirective} from '@taiga-ui/core';
import {TuiPulseComponent} from '@taiga-ui/kit';

@Component({
standalone: true,
imports: [TuiPulseComponent, TuiButtonDirective],
templateUrl: './index.html',
encapsulation,
changeDetection,
})
export default class ExampleComponent {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
```ts
import {TuiPulseComponent} from '@taiga-ui/kit';
// ...

@Component({
standalone: true,
imports: [
// ...
TuiPulseComponent,
],
})
export class MyComponent {}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```html
<tui-pulse [playing]="value"></tui-pulse>
```
16 changes: 16 additions & 0 deletions projects/demo/src/modules/components/pulse/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<tui-doc-page
header="Pulse"
package="KIT"
type="components"
>
<ng-template pageTab>
<tui-doc-example
id="pulse"
heading="Pulse"
[component]="1 | tuiComponent"
[content]="1 | tuiExample: 'html,ts'"
/>
</ng-template>

<tui-setup *pageTab="'Setup'" />
</tui-doc-page>
11 changes: 11 additions & 0 deletions projects/demo/src/modules/components/pulse/index.ts
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 {TuiDemo} from '@demo/utils';

@Component({
standalone: true,
imports: [TuiDemo],
templateUrl: './index.html',
changeDetection,
})
export default class PageComponent {}
1 change: 1 addition & 0 deletions projects/kit/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export * from '@taiga-ui/kit/components/pdf-viewer';
export * from '@taiga-ui/kit/components/pin';
export * from '@taiga-ui/kit/components/preview';
export * from '@taiga-ui/kit/components/progress';
export * from '@taiga-ui/kit/components/pulse';
export * from '@taiga-ui/kit/components/push';
export * from '@taiga-ui/kit/components/radio';
export * from '@taiga-ui/kit/components/radio-list';
Expand Down
1 change: 1 addition & 0 deletions projects/kit/components/pulse/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './pulse.component';
5 changes: 5 additions & 0 deletions projects/kit/components/pulse/ng-package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"lib": {
"entryFile": "index.ts"
}
}
27 changes: 27 additions & 0 deletions projects/kit/components/pulse/pulse.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {ChangeDetectionStrategy, Component, inject, Input} from '@angular/core';
import {
TUI_ANIMATIONS_SPEED,
tuiFadeIn,
tuiScaleIn,
tuiToAnimationOptions,
} from '@taiga-ui/core';

@Component({
standalone: true,
selector: 'tui-pulse',
template: '',
styleUrls: ['./pulse.style.less'],
changeDetection: ChangeDetectionStrategy.OnPush,
animations: [tuiFadeIn, tuiScaleIn],
host: {
'[@tuiFadeIn]': 'animation',
'[@tuiScaleIn]': 'animation',
'[style.--t-animation-state]': "playing ? 'running' : 'paused'",
},
})
export class TuiPulseComponent {
@Input()
public playing = true;

protected readonly animation = tuiToAnimationOptions(inject(TUI_ANIMATIONS_SPEED));
}
75 changes: 75 additions & 0 deletions projects/kit/components/pulse/pulse.style.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
@keyframes tuiPulse {
0% {
opacity: 0.3;
transform: scale(1);
}

20% {
opacity: 0;
transform: scale(0.5);
}

25% {
opacity: 0.3;
transform: scale(1);
}

45% {
opacity: 0;
transform: scale(0.5);
}

50% {
opacity: 0.3;
transform: scale(1);
}

70% {
opacity: 0;
transform: scale(0.5);
}

75% {
opacity: 0.3;
transform: scale(1);
}

95% {
opacity: 0;
transform: scale(0.5);
}

100% {
opacity: 0.3;
transform: scale(1);
}
}

:host {
position: relative;
color: var(--tui-primary);

&:before {
content: '';
position: absolute;
top: -0.5rem;
left: -0.5rem;
width: 1rem;
height: 1rem;
border-radius: 100%;
background: currentColor;
opacity: 0.3;
animation: tuiPulse 3s ease-in-out infinite;
animation-play-state: var(--t-animation-state);
}

&:after {
content: '';
position: absolute;
width: 0.5rem;
height: 0.5rem;
border-radius: 100%;
transform: translate(-50%, -50%);
background: currentColor;
}
}

0 comments on commit b6c95d0

Please sign in to comment.