1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-18 01:03:35 +00:00

[PM-2136] feat: add ability to remove form field bottom margin

(cherry picked from commit 05925ff77ed47f3865c2aecade8271390d9e2fa6)
This commit is contained in:
Andreas Coroiu
2023-04-26 10:58:42 +02:00
parent db687238c3
commit b287ab3398

View File

@@ -1,8 +1,11 @@
import { coerceBooleanProperty } from "@angular/cdk/coercion";
import { import {
AfterContentChecked, AfterContentChecked,
Component, Component,
ContentChild, ContentChild,
ContentChildren, ContentChildren,
HostBinding,
Input,
QueryList, QueryList,
ViewChild, ViewChild,
} from "@angular/core"; } from "@angular/core";
@@ -17,9 +20,6 @@ import { BitSuffixDirective } from "./suffix.directive";
@Component({ @Component({
selector: "bit-form-field", selector: "bit-form-field",
templateUrl: "./form-field.component.html", templateUrl: "./form-field.component.html",
host: {
class: "tw-mb-6 tw-block",
},
}) })
export class BitFormFieldComponent implements AfterContentChecked { export class BitFormFieldComponent implements AfterContentChecked {
@ContentChild(BitFormFieldControl) input: BitFormFieldControl; @ContentChild(BitFormFieldControl) input: BitFormFieldControl;
@@ -30,6 +30,19 @@ export class BitFormFieldComponent implements AfterContentChecked {
@ContentChildren(BitPrefixDirective) prefixChildren: QueryList<BitPrefixDirective>; @ContentChildren(BitPrefixDirective) prefixChildren: QueryList<BitPrefixDirective>;
@ContentChildren(BitSuffixDirective) suffixChildren: QueryList<BitSuffixDirective>; @ContentChildren(BitSuffixDirective) suffixChildren: QueryList<BitSuffixDirective>;
private _disableMargin = false;
@Input() set disableMargin(value: boolean | "") {
this._disableMargin = coerceBooleanProperty(value);
}
get disableMargin() {
return this._disableMargin;
}
@HostBinding("class")
get classList() {
return ["tw-block"].concat(this.disableMargin ? [] : ["tw-mb-6"]);
}
ngAfterContentChecked(): void { ngAfterContentChecked(): void {
if (this.error) { if (this.error) {
this.input.ariaDescribedBy = this.error.id; this.input.ariaDescribedBy = this.error.id;