Skip to content

Commit

Permalink
chore(demo): Dropdown reuse component add options from DI
Browse files Browse the repository at this point in the history
  • Loading branch information
mdlufy committed Sep 27, 2024
1 parent 5ced7e5 commit 1f0cea5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion projects/demo/src/components/dropdown/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</tr>
<tr
*ngIf="!hiddenOptions.includes('open')"
name="[(tuiDropdownOpen)]"
name="[(open)]"
tuiDocAPIItem
type="boolean"
[(value)]="open"
Expand Down
21 changes: 12 additions & 9 deletions projects/demo/src/components/dropdown/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import {NgIf} from '@angular/common';
import {ChangeDetectionStrategy, Component, Input} from '@angular/core';
import {ChangeDetectionStrategy, Component, inject, Input} from '@angular/core';
import {RouterLink} from '@angular/router';
import {DemoRoute} from '@demo/routes';
import {TuiDocAPIItem} from '@taiga-ui/addon-doc';
import type {TuiLooseUnion} from '@taiga-ui/cdk';
import {
TUI_DROPDOWN_OPTIONS,
TuiDropdown,
type TuiDropdownAlign,
type TuiDropdownOptions,
Expand All @@ -22,6 +23,8 @@ import {
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class TuiDocDropdown {
private readonly options = inject(TUI_DROPDOWN_OPTIONS);

protected readonly routes = DemoRoute;

protected readonly aligns: readonly TuiDropdownAlign[] = ['left', 'right', 'center'];
Expand All @@ -38,13 +41,13 @@ export class TuiDocDropdown {
@Input()
public hiddenOptions: Array<TuiLooseUnion<keyof TuiDropdownOptions>> = [];

public open = false;

public align: TuiDropdownAlign = 'left';
public direction: TuiVerticalDirection | null = null;
public align: TuiDropdownAlign = this.options.align;
public direction: TuiVerticalDirection | null = this.options.direction;
public minHeight = this.options.minHeight;
public maxHeight = this.options.maxHeight;
public offset = this.options.offset;
public appearance = this.options.appearance;
public limitWidth: TuiDropdownWidth = 'fixed';
public minHeight = 80;
public maxHeight = 400;
public offset = 4;
public appearance = '';

public open = false;
}

0 comments on commit 1f0cea5

Please sign in to comment.