-
Notifications
You must be signed in to change notification settings - Fork 474
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
1 parent
40781b4
commit 557a5fc
Showing
12 changed files
with
15 additions
and
121 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
This file was deleted.
Oops, something went wrong.
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: 0 additions & 12 deletions
12
projects/experimental/directives/button-close/button-close.component.ts
This file was deleted.
Oops, something went wrong.
46 changes: 9 additions & 37 deletions
46
projects/experimental/directives/button-close/button-close.directive.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 |
---|---|---|
@@ -1,51 +1,23 @@ | ||
import {Directive, Inject} from '@angular/core'; | ||
import { | ||
TUI_PLATFORM, | ||
TuiDirectiveStylesService, | ||
tuiIsString, | ||
TuiPlatform, | ||
TuiStringHandler, | ||
} from '@taiga-ui/cdk'; | ||
import { | ||
TUI_BUTTON_DEFAULT_OPTIONS, | ||
TUI_BUTTON_OPTIONS, | ||
} from '@taiga-ui/experimental/components'; | ||
import {TuiStringHandler} from '@taiga-ui/cdk'; | ||
import {tuiButtonOptionsProvider} from '@taiga-ui/experimental/components'; | ||
import {TUI_ICON_RESOLVER} from '@taiga-ui/experimental/tokens'; | ||
|
||
import {TuiButtonCloseStylesComponent} from './button-close.component'; | ||
import {TUI_BUTTON_CLOSE_OPTIONS, TuiButtonCloseOptions} from './button-close.options'; | ||
import {TUI_BUTTON_CLOSE_ICON} from './button-close.options'; | ||
|
||
@Directive({ | ||
selector: 'button[tuiIconButton][tuiButtonClose]', | ||
providers: [ | ||
{ | ||
provide: TUI_BUTTON_OPTIONS, | ||
deps: [TuiButtonCloseDirective], | ||
useFactory: ({options}: TuiButtonCloseDirective) => ({ | ||
...TUI_BUTTON_DEFAULT_OPTIONS, | ||
...options, | ||
}), | ||
}, | ||
], | ||
selector: '[tuiIconButton][tuiButtonClose]', | ||
providers: [tuiButtonOptionsProvider({appearance: 'neutral', size: 's'})], | ||
host: { | ||
'[style.--t-mask-left]': '"url(" + resolver(icon) + ")"', | ||
'[attr.data-platform]': 'platform', | ||
'[style.--t-radius.%]': '100', | ||
'[style.--tui-height-s.rem]': '1.875', | ||
'[class._icon-left]': 'true', | ||
}, | ||
}) | ||
export class TuiButtonCloseDirective { | ||
get icon(): string { | ||
const {icons} = this.options; | ||
|
||
return tuiIsString(icons) ? icons : icons[this.platform]; | ||
} | ||
|
||
constructor( | ||
@Inject(TUI_ICON_RESOLVER) readonly resolver: TuiStringHandler<string>, | ||
@Inject(TUI_BUTTON_CLOSE_OPTIONS) readonly options: TuiButtonCloseOptions, | ||
@Inject(TUI_PLATFORM) private readonly platform: TuiPlatform, | ||
@Inject(TuiDirectiveStylesService) directiveStyles: TuiDirectiveStylesService, | ||
) { | ||
directiveStyles.addComponent(TuiButtonCloseStylesComponent); | ||
} | ||
@Inject(TUI_BUTTON_CLOSE_ICON) readonly icon: string, | ||
) {} | ||
} |
6 changes: 2 additions & 4 deletions
6
projects/experimental/directives/button-close/button-close.module.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 |
---|---|---|
@@ -1,13 +1,11 @@ | ||
import {CommonModule} from '@angular/common'; | ||
import {NgModule} from '@angular/core'; | ||
import {TuiLoaderModule, TuiSvgModule} from '@taiga-ui/core'; | ||
|
||
import {TuiButtonCloseStylesComponent} from './button-close.component'; | ||
import {TuiButtonCloseDirective} from './button-close.directive'; | ||
|
||
@NgModule({ | ||
imports: [CommonModule, TuiSvgModule, TuiLoaderModule], | ||
declarations: [TuiButtonCloseDirective, TuiButtonCloseStylesComponent], | ||
imports: [CommonModule], | ||
declarations: [TuiButtonCloseDirective], | ||
exports: [TuiButtonCloseDirective], | ||
}) | ||
export class TuiButtonCloseModule {} |
27 changes: 2 additions & 25 deletions
27
projects/experimental/directives/button-close/button-close.options.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 |
---|---|---|
@@ -1,26 +1,3 @@ | ||
import {Provider} from '@angular/core'; | ||
import {tuiCreateToken, TuiPlatform, tuiProvideOptions} from '@taiga-ui/cdk'; | ||
import {tuiCreateToken} from '@taiga-ui/cdk'; | ||
|
||
export interface TuiButtonCloseOptions { | ||
readonly size: 's' | 'xs'; | ||
readonly appearance: string | 'close' | 'glass'; | ||
readonly icons: Record<TuiPlatform, string> | string; | ||
} | ||
|
||
export const TUI_BUTTON_CLOSE_DEFAULT_OPTIONS: TuiButtonCloseOptions = { | ||
size: `s`, | ||
appearance: `close`, | ||
icons: `tuiIconClose`, | ||
}; | ||
|
||
export const TUI_BUTTON_CLOSE_OPTIONS = tuiCreateToken(TUI_BUTTON_CLOSE_DEFAULT_OPTIONS); | ||
|
||
export function tuiButtonCloseOptionsProvider( | ||
options: Partial<TuiButtonCloseOptions>, | ||
): Provider { | ||
return tuiProvideOptions( | ||
TUI_BUTTON_CLOSE_OPTIONS, | ||
options, | ||
TUI_BUTTON_CLOSE_DEFAULT_OPTIONS, | ||
); | ||
} | ||
export const TUI_BUTTON_CLOSE_ICON = tuiCreateToken('tuiIconClose'); |
23 changes: 0 additions & 23 deletions
23
projects/experimental/directives/button-close/button-close.style.less
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
export * from './button-close.component'; | ||
export * from './button-close.directive'; | ||
export * from './button-close.module'; | ||
export * from './button-close.options'; |
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