mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 08:13:42 +00:00
* Adjust radio groups margin * Move hint margin to input field * Tweak field spacing * Add story for hint, and fix hint display * Fix label ssue * Revert input margin * Re-add margin to hint * Change font weight * Fix required placement * Add support for required * Change margin of radio group * Remove unnecessary div * Fix long inputs cutting off * Fix radio story * Remove newline --------- Co-authored-by: Will Martin <contact@willmartian.com>
50 lines
1.0 KiB
TypeScript
50 lines
1.0 KiB
TypeScript
import { Component, HostBinding, Input } from "@angular/core";
|
|
|
|
import { RadioGroupComponent } from "./radio-group.component";
|
|
|
|
let nextId = 0;
|
|
|
|
@Component({
|
|
selector: "bit-radio-button",
|
|
templateUrl: "radio-button.component.html",
|
|
})
|
|
export class RadioButtonComponent {
|
|
@HostBinding("attr.id") @Input() id = `bit-radio-button-${nextId++}`;
|
|
@HostBinding("class") get classList() {
|
|
return [this.block ? "tw-block" : "tw-inline-block", "tw-mb-2"];
|
|
}
|
|
|
|
@Input() value: unknown;
|
|
@Input() disabled = false;
|
|
|
|
constructor(private groupComponent: RadioGroupComponent) {}
|
|
|
|
get inputId() {
|
|
return `${this.id}-input`;
|
|
}
|
|
|
|
get name() {
|
|
return this.groupComponent.name;
|
|
}
|
|
|
|
get selected() {
|
|
return this.groupComponent.selected === this.value;
|
|
}
|
|
|
|
get groupDisabled() {
|
|
return this.groupComponent.disabled;
|
|
}
|
|
|
|
get block() {
|
|
return this.groupComponent.block;
|
|
}
|
|
|
|
protected onInputChange() {
|
|
this.groupComponent.onInputChange(this.value);
|
|
}
|
|
|
|
protected onBlur() {
|
|
this.groupComponent.onBlur();
|
|
}
|
|
}
|