Skip to content

Commit

Permalink
feat(kit): add tuiConnected directive for Stepper and Cell
Browse files Browse the repository at this point in the history
  • Loading branch information
mdlufy committed Jul 4, 2024
1 parent bf430d1 commit 15c4915
Show file tree
Hide file tree
Showing 13 changed files with 265 additions and 1 deletion.
82 changes: 82 additions & 0 deletions projects/demo/src/modules/components/cell/examples/8/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<tui-notification>
tuiConnected directive can be attached as host directive:
<code>hostDirectives: [TuiConnected]</code>
</tui-notification>

<div tuiConnected>
<label tuiCell>
<tui-badged-content>
<tui-icon
appearance="error"
icon="@tui.arrow-down-left"
size="s"
tuiBadge
tuiSlot="top"
/>
<tui-avatar
size="s"
src="@tui.phone"
/>
</tui-badged-content>
<div
tuiTitle
[style.color]="'var(--tui-text-negative)'"
>
Allow incoming
<div tuiSubtitle>Why would you?</div>
</div>
<input
tuiSwitch
type="checkbox"
[(ngModel)]="incoming"
/>
</label>
<label tuiCell>
<tui-badged-content>
<tui-icon
appearance="success"
icon="@tui.arrow-up-right"
size="s"
tuiBadge
tuiSlot="top"
/>
<tui-avatar
size="s"
src="@tui.phone"
/>
</tui-badged-content>
<div tuiTitle>Allow outgoing</div>
<input
tuiSwitch
type="checkbox"
[(ngModel)]="outgoing"
/>
</label>
<label tuiCell>
<tui-badged-content>
<tui-icon
appearance="error"
icon="@tui.arrow-down-left"
size="s"
tuiBadge
tuiSlot="top"
/>
<tui-avatar
size="s"
src="@tui.phone"
/>
</tui-badged-content>
<div
tuiTitle
[style.color]="'var(--tui-text-negative)'"
>
Allow incoming
<div tuiSubtitle>Why would you?</div>
</div>
<input
tuiSwitch
type="checkbox"
[(ngModel)]="incoming"
/>
</label>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
:host {
display: flex;
flex-direction: column;
max-width: 20rem;
gap: 1rem;
}
65 changes: 65 additions & 0 deletions projects/demo/src/modules/components/cell/examples/8/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import {NgFor} from '@angular/common';
import {Component} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {changeDetection} from '@demo/emulate/change-detection';
import {encapsulation} from '@demo/emulate/encapsulation';
import {TuiIcon, TuiNotification, TuiSurface} from '@taiga-ui/core';
import {
TuiAvatar,
TuiBadge,
TuiBadgedContent,
TuiConnected,
TuiDataListWrapper,
TuiSwitch,
} from '@taiga-ui/kit';
import {TuiCardLarge, TuiCell} from '@taiga-ui/layout';
import {TuiSelectModule, TuiTextfieldControllerModule} from '@taiga-ui/legacy';

@Component({
standalone: true,
imports: [
TuiNotification,
TuiCell,
TuiAvatar,
TuiSelectModule,
TuiDataListWrapper,
TuiTextfieldControllerModule,
TuiCardLarge,
TuiSurface,
NgFor,
FormsModule,
TuiBadgedContent,
TuiIcon,
TuiConnected,
TuiBadge,
TuiSwitch,
],
templateUrl: './index.html',
styleUrls: ['./index.less'],
encapsulation,
changeDetection,
})
export default class Example {
protected readonly items = [
{
icon: '@tui.eye',
title: 'Show more',
subtitle: 'Ctrl + Shift + M',
},
{
icon: '@tui.mail',
title: 'Send message',
subtitle: 'Keep it short',
},
{
icon: '@tui.lock',
title: 'Access',
subtitle: 'Block your account',
},
];

protected value = this.items[0];

protected incoming = false;
protected outgoing = true;
}
1 change: 1 addition & 0 deletions projects/demo/src/modules/components/cell/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ export default class Example {
'Long content',
'Actions',
'Combinations',
'Connected',
];
}
12 changes: 12 additions & 0 deletions projects/demo/src/modules/components/stepper/examples/4/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<tui-stepper
orientation="vertical"
tuiConnected
[activeItemIndex]="1"
>
<button
*ngFor="let step of steps"
tuiStep
>
{{ step }}
</button>
</tui-stepper>
Empty file.
16 changes: 16 additions & 0 deletions projects/demo/src/modules/components/stepper/examples/4/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {NgForOf} from '@angular/common';
import {Component} from '@angular/core';
import {changeDetection} from '@demo/emulate/change-detection';
import {encapsulation} from '@demo/emulate/encapsulation';
import {TuiConnected, TuiStepper} from '@taiga-ui/kit';

@Component({
standalone: true,
imports: [TuiStepper, TuiConnected, NgForOf],
templateUrl: './index.html',
encapsulation,
changeDetection,
})
export default class Example {
protected readonly steps = ['Start Up', 'Cash In', 'Sell Out', 'Bro Down'];
}
7 changes: 6 additions & 1 deletion projects/demo/src/modules/components/stepper/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ import {TuiStepper} from '@taiga-ui/kit';
export default class Page {
protected activeItemIndex = 0;

protected readonly examples = ['Basic', 'Vertical', 'Vertical autoscroll'];
protected readonly examples = [
'Basic',
'Vertical',
'Vertical autoscroll',
'Vertical connected',
];

protected readonly orientationVariants: readonly TuiOrientation[] = [
'horizontal',
Expand Down
30 changes: 30 additions & 0 deletions projects/kit/directives/connected/connected.directive.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import {
ChangeDetectionStrategy,
Component,
Directive,
ViewEncapsulation,
} from '@angular/core';
import {tuiWithStyles} from '@taiga-ui/cdk/utils/miscellaneous';

@Component({
standalone: true,
template: '',
styleUrls: ['./connected.style.less'],
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
host: {
class: 'tui-connected-styles',
},
})
class TuiConnectedStyles {}

@Directive({
standalone: true,
selector: '[tuiConnected]',
host: {
tuiConnected: '',
},
})
export class TuiConnected {
protected readonly nothing = tuiWithStyles(TuiConnectedStyles);
}
40 changes: 40 additions & 0 deletions projects/kit/directives/connected/connected.style.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
@import '@taiga-ui/core/styles/taiga-ui-local';

[tuiConnected] {
--tui-icon-height: 2rem;
--tui-icon-width: 2rem;
--tui-left-offset: 1rem;
--tui-vertical-offset: calc((100% + var(--tui-icon-height)) / 2 + 4px);
--tui-connected-height: calc(100% - var(--tui-vertical-offset));

&[tuiCardLarge] [tuiCell],
[tuiCell],
[tuiStep] {
&:not(:first-of-type):before,
&:not(:last-of-type):after {
content: '';
position: absolute;
bottom: var(--tui-vertical-offset);
left: calc(var(--tui-icon-width) / 2 + var(--tui-left-offset));
height: var(--tui-connected-height);
width: 1px;
background-color: var(--tui-border-normal);
}

&:not(:last-of-type):after {
top: var(--tui-vertical-offset);
}
}

&[tuiCardLarge] [tuiCell] {
--tui-left-offset: 0.5rem;
--tui-icon-height: 2.5rem;
--tui-icon-width: 2.5rem;
}

[tuiStep] {
--tui-left-offset: 0rem;
--tui-vertical-margin: 1.25rem;
--tui-connected-height: calc(100% - var(--tui-vertical-offset) + var(--tui-vertical-margin) / 2);
}
}
1 change: 1 addition & 0 deletions projects/kit/directives/connected/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './connected.directive';
5 changes: 5 additions & 0 deletions projects/kit/directives/connected/ng-package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"lib": {
"entryFile": "index.ts"
}
}
1 change: 1 addition & 0 deletions projects/kit/directives/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export * from '@taiga-ui/kit/directives/button-group';
export * from '@taiga-ui/kit/directives/button-vertical';
export * from '@taiga-ui/kit/directives/chevron';
export * from '@taiga-ui/kit/directives/comment';
export * from '@taiga-ui/kit/directives/connected';
export * from '@taiga-ui/kit/directives/data-list-dropdown-manager';
export * from '@taiga-ui/kit/directives/fade';
export * from '@taiga-ui/kit/directives/highlight';
Expand Down

0 comments on commit 15c4915

Please sign in to comment.