-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(theme): form field component (#2238)
- Loading branch information
Showing
30 changed files
with
802 additions
and
12 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 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
4 changes: 2 additions & 2 deletions
4
src/framework/theme/components/chat/chat-form.component.spec.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
76 changes: 76 additions & 0 deletions
76
src/framework/theme/components/form-field/_form-field.component.theme.scss
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,76 @@ | ||
/** | ||
* @license | ||
* Copyright Akveo. All Rights Reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*/ | ||
|
||
@mixin nb-form-field-theme() { | ||
.nb-form-field-addon { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
z-index: 1; | ||
@include nb-component-animation(color); | ||
|
||
&-disabled { | ||
color: nb-theme(form-field-addon-disabled-text-color); | ||
} | ||
} | ||
|
||
@each $status in nb-get-statuses() { | ||
.nb-form-field-addon-#{$status} { | ||
color: nb-theme(form-field-addon-#{$status}-text-color); | ||
|
||
&-highlight { | ||
color: nb-theme(form-field-addon-#{$status}-highlight-text-color); | ||
} | ||
} | ||
} | ||
|
||
@each $size in nb-get-sizes() { | ||
$addon-height: nb-theme(form-field-addon-#{$size}-height); | ||
$addon-width: nb-theme(form-field-addon-#{$size}-width); | ||
|
||
.nb-form-field-prefix-#{$size}, | ||
.nb-form-field-suffix-#{$size} { | ||
height: $addon-height; | ||
width: $addon-width; | ||
font-size: nb-theme(form-field-addon-#{$size}-font-size); | ||
line-height: nb-theme(form-field-addon-#{$size}-line-height); | ||
font-weight: nb-theme(form-field-addon-#{$size}-font-weight); | ||
|
||
nb-icon { | ||
font-size: nb-theme(form-field-addon-#{$size}-icon-size); | ||
line-height: nb-theme(form-field-addon-#{$size}-icon-size); | ||
} | ||
} | ||
|
||
.nb-form-field-prefix-#{$size} { | ||
@include nb-ltr(margin-right, calc(#{$addon-width} * -1)); | ||
@include nb-rtl(margin-left, calc(#{$addon-width} * -1)); | ||
} | ||
|
||
.nb-form-field-suffix-#{$size} { | ||
@include nb-ltr(margin-left, calc(#{$addon-width} * -1)); | ||
@include nb-rtl(margin-right, calc(#{$addon-width} * -1)); | ||
} | ||
} | ||
} | ||
|
||
@mixin nb-form-field-with-prefix($selector, $size) { | ||
$addon-width: nb-theme(form-field-addon-#{$size}-width); | ||
|
||
.nb-form-field-control-with-prefix #{$selector} { | ||
@include nb-ltr(padding-left, $addon-width); | ||
@include nb-rtl(padding-right, $addon-width); | ||
} | ||
} | ||
|
||
@mixin nb-form-field-with-suffix($selector, $size) { | ||
$addon-width: nb-theme(form-field-addon-#{$size}-width); | ||
|
||
.nb-form-field-control-with-suffix #{$selector} { | ||
@include nb-ltr(padding-right, $addon-width); | ||
@include nb-rtl(padding-left, $addon-width); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/framework/theme/components/form-field/form-field-control.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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* @license | ||
* Copyright Akveo. All Rights Reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*/ | ||
|
||
import { Injectable } from '@angular/core'; | ||
import { NbComponentStatus } from '../component-status'; | ||
import { NbComponentSize } from '../component-size'; | ||
import { Observable } from 'rxjs'; | ||
|
||
/* | ||
* Class used as injection token to provide form element. | ||
**/ | ||
@Injectable() | ||
export abstract class NbFormFieldControl { | ||
status$: Observable<NbComponentStatus>; | ||
size$: Observable<NbComponentSize>; | ||
focused$: Observable<boolean>; | ||
disabled$: Observable<boolean>; | ||
} | ||
|
||
/* | ||
* Optional config to be provided on NbFormFieldControl to alter default settings. | ||
**/ | ||
@Injectable() | ||
export class NbFormFieldControlConfig { | ||
supportsPrefix = true; | ||
supportsSuffix = true; | ||
} | ||
|
||
export interface NbFormControlState { | ||
status: NbComponentStatus; | ||
size: NbComponentSize; | ||
focused: boolean; | ||
disabled: boolean; | ||
} |
12 changes: 12 additions & 0 deletions
12
src/framework/theme/components/form-field/form-field.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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<div *ngIf="shouldShowPrefix()" [ngClass]="prefixClasses$ | async"> | ||
<ng-content select="[nbPrefix]"></ng-content> | ||
</div> | ||
|
||
<div [class.nb-form-field-control-with-prefix]="shouldShowPrefix()" | ||
[class.nb-form-field-control-with-suffix]="shouldShowSuffix()"> | ||
<ng-content></ng-content> | ||
</div> | ||
|
||
<div *ngIf="shouldShowSuffix()" [ngClass]="suffixClasses$ | async"> | ||
<ng-content select="[nbSuffix]"></ng-content> | ||
</div> |
10 changes: 10 additions & 0 deletions
10
src/framework/theme/components/form-field/form-field.component.scss
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,10 @@ | ||
/** | ||
* @license | ||
* Copyright Akveo. All Rights Reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*/ | ||
|
||
:host { | ||
display: flex; | ||
align-items: center; | ||
} |
Oops, something went wrong.