-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(field): add LyFieldDefaultOptions
- Loading branch information
Showing
3 changed files
with
190 additions
and
118 deletions.
There are no files selected for viewing
180 changes: 100 additions & 80 deletions
180
src/app/docs/components/field-demo/field-playground/field-playground.component.html
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,84 +1,104 @@ | ||
<ly-radio-group [formControl]="appearance"> | ||
<span>Appearance:</span> | ||
<ly-radio value="standard" checked>Standard</ly-radio> | ||
<ly-radio value="outlined">Outlined</ly-radio> | ||
<ly-radio value="filled">Filled</ly-radio> | ||
</ly-radio-group> | ||
|
||
<br /> | ||
|
||
formControl(password): | ||
<ly-checkbox | ||
[formControl]="isDisabled" | ||
(change)="$event.checked ? password.disable() : password.enable()" | ||
>Is disabled</ly-checkbox> | ||
<ly-checkbox [formControl]="isReadonly">Is readonly</ly-checkbox> | ||
<button ly-button color="primary" (click)="password.reset()" [disabled]="password.untouched">reset</button> | ||
<ly-grid container [lyAlignItems]="'center'" [spacingX]="16"> | ||
<ly-grid item [col]="'6 12@XSmall'"> | ||
<ly-field fullWidth #_field [appearance]="appearance.value"> | ||
<input | ||
lyNativeControl | ||
placeholder="********" | ||
[type]="hide ? 'password' : 'text'" | ||
[formControl]="password" | ||
[readonly]="isReadonly.value" | ||
<div [class]="classes.exampleContainer"> | ||
<ly-radio-group [formControl]="appearance"> | ||
<span>Appearance:</span> | ||
<ly-radio value="standard" checked>Standard</ly-radio> | ||
<ly-radio value="outlined">Outlined</ly-radio> | ||
<ly-radio value="filled">Filled</ly-radio> | ||
</ly-radio-group> | ||
<br /> | ||
<ly-radio-group [formControl]="color"> | ||
<span>Color:</span> | ||
<ly-radio color="primary" value="primary" checked>Primary</ly-radio> | ||
<ly-radio color="accent" value="accent">Accent</ly-radio> | ||
<ly-radio color="warn" value="warn">Warn</ly-radio> | ||
<ly-radio color="#00bcd4" value="#00bcd4">Cyan (#00bcd4)</ly-radio> | ||
</ly-radio-group> | ||
<ly-checkbox | ||
[formControl]="isDisabled" | ||
(change)="$event.checked ? password.disable() : password.enable()" | ||
>Is disabled</ly-checkbox> | ||
<ly-checkbox [formControl]="isReadonly">Is readonly</ly-checkbox> | ||
<button ly-button color="primary" (click)="password.reset()" [disabled]="password.untouched">reset</button> | ||
<ly-grid container [lyAlignItems]="'center'" [spacingX]="16"> | ||
<ly-grid item [col]="'6 12@XSmall'"> | ||
<ly-field #_field | ||
[appearance]="appearance.value" | ||
[lyWidth]="1" | ||
[color]="color.value" | ||
> | ||
<ly-label>Enter your password</ly-label> | ||
<button ly-button | ||
appearance="icon" | ||
lySuffix | ||
(click)="hide = !hide" | ||
[disabled]="isDisabled.value" | ||
[color]="_field.errorState ? 'warn' : 'text'" | ||
<input | ||
lyNativeControl | ||
placeholder="********" | ||
[type]="hide ? 'password' : 'text'" | ||
[formControl]="password" | ||
[readonly]="isReadonly.value" | ||
> | ||
<ly-label>Enter your password</ly-label> | ||
<button ly-button | ||
appearance="icon" | ||
lySuffix | ||
(click)="hide = !hide" | ||
[disabled]="isDisabled.value" | ||
[color]="_field.errorState ? 'warn' : 'text'" | ||
> | ||
<ly-icon>{{ hide ? 'visibility' : 'visibility_off' }}</ly-icon> | ||
</button> | ||
<ly-hint>Hint</ly-hint> | ||
<ly-hint [align]="'after'">{{ password.value?.length || 0 }}</ly-hint> | ||
<ly-error *ngIf="password.hasError('minlength')">Min 8 characters</ly-error> | ||
<ly-error *ngIf="password.hasError('required')">Required</ly-error> | ||
</ly-field> | ||
</ly-grid> | ||
|
||
<ly-grid item [col]="'6 12@XSmall'"> | ||
<ly-field [lyWidth]="1" [appearance]="appearance.value" [color]="color.value"> | ||
<ly-label>Clearable</ly-label> | ||
<input #_input | ||
lyNativeControl | ||
[value]="'Text'" | ||
[disabled]="isDisabled.value" | ||
placeholder="Placeholder" | ||
type="text" | ||
maxlength="10" | ||
> | ||
<ly-hint>Hint</ly-hint> | ||
<ly-hint [align]="'after'">{{ _input.value?.length || 0 }}/10</ly-hint> | ||
<button ly-button | ||
*ngIf="_input.value" | ||
appearance="icon" | ||
lySuffix | ||
(click)="_input.value = ''" | ||
> | ||
<ly-icon>close</ly-icon> | ||
</button> | ||
</ly-field> | ||
</ly-grid> | ||
|
||
<ly-grid item [col]="'6 12@XSmall'"> | ||
<ly-field | ||
[lyWidth]="1" | ||
[appearance]="appearance.value" | ||
[color]="color.value" | ||
> | ||
<ly-icon>{{ hide ? 'visibility' : 'visibility_off' }}</ly-icon> | ||
</button> | ||
<ly-hint>Hint</ly-hint> | ||
<ly-hint [align]="'after'">{{ password.value?.length || 0 }}</ly-hint> | ||
<ly-error *ngIf="password.hasError('minlength')">Min 8 characters</ly-error> | ||
<ly-error *ngIf="password.hasError('required')">Required</ly-error> | ||
</ly-field> | ||
</ly-grid> | ||
|
||
<ly-grid item [col]="'6 12@XSmall'"> | ||
<ly-field fullWidth [appearance]="appearance.value"> | ||
<ly-label>Clearable</ly-label> | ||
<input #_input | ||
lyNativeControl | ||
[value]="'Text'" | ||
placeholder="Placeholder" | ||
type="text" | ||
maxlength="10" | ||
> | ||
<ly-hint>Hint</ly-hint> | ||
<ly-hint [align]="'after'">{{ _input.value?.length || 0 }}/10</ly-hint> | ||
<button ly-button | ||
*ngIf="_input.value" | ||
appearance="icon" | ||
lySuffix | ||
(click)="_input.value = ''" | ||
<ly-label>Label</ly-label> | ||
<ly-placeholder>Placeholder</ly-placeholder> | ||
<textarea lyNativeControl [disabled]="isDisabled.value"></textarea> | ||
<ly-hint>Hint</ly-hint> | ||
</ly-field> | ||
</ly-grid> | ||
|
||
<ly-grid item [col]="'6 12@XSmall'"> | ||
<ly-field | ||
[appearance]="appearance.value" | ||
floatingLabel | ||
[lyMaxWidth]="125" | ||
[color]="color.value" | ||
> | ||
<ly-icon>close</ly-icon> | ||
</button> | ||
</ly-field> | ||
</ly-grid> | ||
|
||
<ly-grid item [col]="'6 12@XSmall'"> | ||
<ly-field fullWidth [appearance]="appearance.value"> | ||
<ly-label>Label</ly-label> | ||
<ly-placeholder>Placeholder</ly-placeholder> | ||
<textarea lyNativeControl></textarea> | ||
<ly-hint>Hint</ly-hint> | ||
</ly-field> | ||
</ly-grid> | ||
|
||
<ly-grid item [col]="'6 12@XSmall'"> | ||
<ly-field [appearance]="appearance.value" floatingLabel style="max-width: 125px"> | ||
<ly-label>Price</ly-label> | ||
<span>$ </span> | ||
<input lyNativeControl type="number" [value]="10"> | ||
<ly-hint>Hint</ly-hint> | ||
</ly-field> | ||
<ly-label>Price</ly-label> | ||
<span>$ </span> | ||
<input lyNativeControl type="number" [value]="10" [disabled]="isDisabled.value"> | ||
<ly-hint>Hint</ly-hint> | ||
</ly-field> | ||
</ly-grid> | ||
</ly-grid> | ||
</ly-grid> | ||
</div> |
29 changes: 28 additions & 1 deletion
29
src/app/docs/components/field-demo/field-playground/field-playground.component.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,15 +1,42 @@ | ||
import { lyl, StyleRenderer, ThemeRef, ThemeVariables } from '@alyle/ui'; | ||
import { STYLES as RADIO_STYLES } from '@alyle/ui/radio'; | ||
import { STYLES as CHECKBOX_STYLES } from '@alyle/ui/checkbox'; | ||
import { Component, ChangeDetectionStrategy } from '@angular/core'; | ||
import { FormControl, Validators } from '@angular/forms'; | ||
|
||
export const STYLES = (_: ThemeVariables, ref: ThemeRef) => { | ||
const radio = ref.renderStyleSheet(RADIO_STYLES); | ||
const checkbox = ref.renderStyleSheet(CHECKBOX_STYLES); | ||
return { | ||
exampleContainer: lyl `{ | ||
> * { | ||
margin: 8px 0 | ||
} | ||
.${radio.radio}, | ||
.${checkbox.root} { | ||
margin: 0 12px | ||
} | ||
}` | ||
}; | ||
}; | ||
|
||
@Component({ | ||
selector: 'aui-field-playground', | ||
templateUrl: './field-playground.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
providers: [ | ||
StyleRenderer | ||
] | ||
}) | ||
export class FieldPlaygroundComponent { | ||
readonly classes = this.sRenderer.renderSheet(STYLES); | ||
hide = true; | ||
appearance = new FormControl(); | ||
color = new FormControl('primary'); | ||
isReadonly = new FormControl(); | ||
isDisabled = new FormControl(); | ||
password = new FormControl('', [Validators.required, Validators.minLength(8)]); | ||
constructor( | ||
readonly sRenderer: StyleRenderer | ||
) { } | ||
} |
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