Skip to content

Commit

Permalink
feat: readonly state for password input (#2976)
Browse files Browse the repository at this point in the history
Co-authored-by: Akshat Patel <[email protected]>
  • Loading branch information
eduardmarcinco and Akshat55 authored Aug 30, 2024
1 parent eb64d50 commit 3be466f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/input/password-input-label.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,17 @@ export class PasswordInputLabelComponent extends BaseIconButton implements After
/**
* Reference to the wrapper element.
*/
@ViewChild("wrapper") wrapper: ElementRef<HTMLDivElement>;
@ViewChild("wrapper", { static: true }) wrapper: ElementRef<HTMLDivElement>;

/**
* Binding for applying class to host element.
*/
@HostBinding("class.cds--form-item") labelClass = true;
@HostBinding("class.cds--password-input-wrapper") passwordInputWrapper = true;
@HostBinding("class.cds--text-input-wrapper") textInputWrapper = true;
@HostBinding("class.cds--text-input-wrapper--readonly") get isReadonly() {
return this.wrapper?.nativeElement.querySelector("input")?.readOnly;
}

/**
* Constructor for PasswordInputLabelComponent.
Expand Down
10 changes: 6 additions & 4 deletions src/input/password.stories.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* tslint:disable variable-name */

import { moduleMetadata, Meta } from "@storybook/angular";
import { InputModule, PasswordInputLabelComponent } from ".";
import { FormsModule } from "@angular/forms";
import { Meta, moduleMetadata } from "@storybook/angular";
import { InputModule, PasswordInputLabelComponent } from ".";

export default {
title: "Components/Input/Password",
Expand Down Expand Up @@ -34,7 +34,8 @@ const Template = (args) => ({
[disabled]="disabled"
[theme]="theme"
[placeholder]="placeholder"
[autocomplete]="autocomplete">
[autocomplete]="autocomplete"
[readonly]="readonly">
</cds-password-label>
`
});
Expand All @@ -50,7 +51,8 @@ Basic.args = {
placeholder: "Placeholder",
autocomplete: "on",
theme: "dark",
size: "md"
size: "md",
readonly: false
};
Basic.argTypes = {
autocomplete: {
Expand Down

0 comments on commit 3be466f

Please sign in to comment.