diff --git a/projects/kit/components/arrow/arrow-options.ts b/projects/kit/components/arrow/arrow-options.ts new file mode 100644 index 000000000000..9dcd609e5dda --- /dev/null +++ b/projects/kit/components/arrow/arrow-options.ts @@ -0,0 +1,24 @@ +import {InjectionToken} from '@angular/core'; +import {PolymorpheusContent} from '@tinkoff/ng-polymorpheus'; + +export interface TuiArrowOptions { + readonly iconSmall: PolymorpheusContent; + readonly iconLarge: PolymorpheusContent; +} + +// TODO: remove in ivy compilation +export const TUI_ARROW_ICON_SMALL = 'tuiIconChevronDown'; +export const TUI_ARROW_ICON_LARGE = 'tuiIconChevronDownLarge'; + +/** Default values for arrow options */ +export const TUI_ARROW_DEFAULT_OPTIONS: TuiArrowOptions = { + iconSmall: TUI_ARROW_ICON_SMALL, + iconLarge: TUI_ARROW_ICON_LARGE, +}; + +export const TUI_ARROW_OPTIONS = new InjectionToken( + 'Default parameters for arrow component', + { + factory: () => TUI_ARROW_DEFAULT_OPTIONS, + }, +); diff --git a/projects/kit/components/arrow/arrow.component.ts b/projects/kit/components/arrow/arrow.component.ts index 77f26c748c12..146e21965a10 100644 --- a/projects/kit/components/arrow/arrow.component.ts +++ b/projects/kit/components/arrow/arrow.component.ts @@ -5,7 +5,9 @@ import { TuiHostedDropdownComponent, TuiTextfieldSizeDirective, } from '@taiga-ui/core'; -import {PolymorpheusComponent} from '@tinkoff/ng-polymorpheus'; +import {PolymorpheusComponent, PolymorpheusContent} from '@tinkoff/ng-polymorpheus'; + +import {TUI_ARROW_OPTIONS, TuiArrowOptions} from './arrow-options'; @Component({ selector: 'tui-arrow', @@ -19,12 +21,13 @@ export class TuiArrowComponent { readonly dropdown: TuiHostedDropdownComponent, @Inject(TUI_TEXTFIELD_SIZE) private readonly textfieldSize: TuiTextfieldSizeDirective, + @Inject(TUI_ARROW_OPTIONS) private readonly options: TuiArrowOptions, ) {} - get arrowIcon(): string { + get arrowIcon(): PolymorpheusContent { return sizeBigger(this.textfieldSize.size) - ? 'tuiIconChevronDownLarge' - : 'tuiIconChevronDown'; + ? this.options.iconLarge + : this.options.iconSmall; } } diff --git a/projects/kit/components/arrow/arrow.module.ts b/projects/kit/components/arrow/arrow.module.ts index da98da2e9100..e825243af0db 100644 --- a/projects/kit/components/arrow/arrow.module.ts +++ b/projects/kit/components/arrow/arrow.module.ts @@ -1,11 +1,12 @@ import {CommonModule} from '@angular/common'; import {NgModule} from '@angular/core'; import {TuiSvgModule} from '@taiga-ui/core'; +import {PolymorpheusModule} from '@tinkoff/ng-polymorpheus'; import {TuiArrowComponent} from './arrow.component'; @NgModule({ - imports: [CommonModule, TuiSvgModule], + imports: [CommonModule, TuiSvgModule, PolymorpheusModule], declarations: [TuiArrowComponent], exports: [TuiArrowComponent], entryComponents: [TuiArrowComponent], diff --git a/projects/kit/components/arrow/arrow.style.less b/projects/kit/components/arrow/arrow.style.less index c5f3b85945eb..fb952e6c4b92 100644 --- a/projects/kit/components/arrow/arrow.style.less +++ b/projects/kit/components/arrow/arrow.style.less @@ -2,6 +2,7 @@ .icon { .transition(transform); + display: block; cursor: pointer; pointer-events: none; diff --git a/projects/kit/components/arrow/arrow.template.html b/projects/kit/components/arrow/arrow.template.html index 174a66d947f2..f71def9901f2 100644 --- a/projects/kit/components/arrow/arrow.template.html +++ b/projects/kit/components/arrow/arrow.template.html @@ -1,5 +1,10 @@ - + [content]="arrowIcon" +> + + + + diff --git a/projects/kit/components/arrow/index.ts b/projects/kit/components/arrow/index.ts index 2c4b82a3db2d..de022cf3a677 100644 --- a/projects/kit/components/arrow/index.ts +++ b/projects/kit/components/arrow/index.ts @@ -1,2 +1,3 @@ export * from './arrow.component'; export * from './arrow.module'; +export * from './arrow-options';