-
Notifications
You must be signed in to change notification settings - Fork 477
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(demo):
Textfield
add reuse component & migrate `TextfieldCont…
…roller` to new approach
- Loading branch information
Showing
4 changed files
with
110 additions
and
73 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<tr> | ||
<td colspan="3"> | ||
<span tuiTitle> | ||
<a | ||
tuiLink | ||
[routerLink]="routes.Textfield" | ||
> | ||
<strong>Textfield</strong> | ||
</a> | ||
<span tuiSubtitle>Applied as a host directive</span> | ||
</span> | ||
</td> | ||
</tr> | ||
<tr | ||
*ngIf="!hiddenOptions.includes('cleaner')" | ||
name="[tuiTextfieldCleaner]" | ||
tuiDocAPIItem | ||
type="boolean" | ||
[(value)]="cleaner" | ||
> | ||
Shows a cross to reset a value | ||
</tr> | ||
<tr | ||
*ngIf="!hiddenOptions.includes('customContent')" | ||
name="[tuiTextfieldCustomContent]" | ||
tuiDocAPIItem | ||
type="PolymorpheusContent" | ||
[items]="customContentVariants" | ||
[(value)]="customContent" | ||
> | ||
Right content (e.g. avatar with maximum size 32x32px) | ||
</tr> | ||
<tr | ||
*ngIf="!hiddenOptions.includes('labelOutside')" | ||
name="[tuiTextfieldLabelOutside]" | ||
tuiDocAPIItem | ||
type="boolean" | ||
[(value)]="labelOutside" | ||
> | ||
Label is outside a component and made with | ||
<a | ||
tuiLink | ||
[routerLink]="routes.Label" | ||
> | ||
<code>Label</code> | ||
</a> | ||
</tr> | ||
<tr | ||
*ngIf="!hiddenOptions.includes('size')" | ||
name="[tuiTextfieldSize]" | ||
tuiDocAPIItem | ||
type="TuiSizeS | TuiSizeL" | ||
[items]="sizeVariants" | ||
[(value)]="size" | ||
> | ||
Size | ||
</tr> |
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import {NgIf} from '@angular/common'; | ||
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_TEXTFIELD_OPTIONS, | ||
TuiLink, | ||
type TuiSizeL, | ||
type TuiSizeS, | ||
type TuiTextfieldOptions, | ||
TuiTitle, | ||
} from '@taiga-ui/core'; | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: 'tbody[tuiDocTextfield]', | ||
imports: [NgIf, RouterLink, TuiDocAPIItem, TuiLink, TuiTitle], | ||
templateUrl: './index.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class TuiDocTextfield { | ||
private readonly options = inject(TUI_TEXTFIELD_OPTIONS); | ||
|
||
protected readonly routes = DemoRoute; | ||
|
||
protected readonly sizeVariants: ReadonlyArray<TuiSizeL | TuiSizeS> = ['s', 'm', 'l']; | ||
protected readonly customContentVariants = ['', '@tui.bell']; | ||
|
||
@Input() | ||
public tuiDocTextfield: readonly string[] | '' = ''; | ||
|
||
@Input() | ||
public hiddenOptions: Array<TuiLooseUnion<keyof TuiTextfieldOptions>> = []; | ||
|
||
public cleaner: boolean = this.options.cleaner(); | ||
public size: TuiSizeL | TuiSizeS = this.options.size(); | ||
public labelOutside = false; | ||
public customContent = this.customContentVariants[0]; | ||
} |
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